Reputation: 345
I try to understand lexical-scoping. In lexical-scoping, I have this code, C like syntax:
main{
f1(){
int y = 8;
}
int y = 1; //*
f1();
}
After the execution of f1()
line, will the value of y
variable in main (I put * next of it) remain 1 or change to 8?
Upvotes: 0
Views: 73
Reputation: 163357
It will remain 1. You have two completely distinct variables. Changes to one do not affect the other.
Upvotes: 1