Re: scope of variables
- Posted by jimcbrown (admin) Dec 30, 2010
- 2937 views
I desagree with you on this. The rules of lexical scoping are so that you can define a variable of the same name inside narrower scope and this new variable will shadow the outer one.
look at others languages that implement scoping at block level (at think lua does) and you'll see that it is done as I says.
I also think that Euphoria should be consistent with many other languages. Namely that 'if', 'else', 'while', 'loop', and 'for' statements begin a new block and that blocks have their own scope.
However this type of lexical scoping is not one of Nature's Axioms and instead is left up to the language designer. So it is perfectly reasonable to leave Euphoria as is, unless we, as a community, decide that it should change.
I agree 100% with Derek on this. Derek, you put it better than I ever could have.