sri96 / nila

Nila is a small Ruby inspired language to fix Javascript
https://github.com/sri96/nila
1 stars 0 forks source link

Nila's Lexical Scoping #15

Open adhithyan15 opened 10 years ago

adhithyan15 commented 10 years ago

Nila currently stands at a weird place when it comes to lexical scoping. Nila's lexical scoping is very inconsistent to the Ruby philosophy which it claims to follow. Ruby's lexical scoping is followed very closely by Coffeescript but Nila's lexical scoping is very similar to that of Python. Nila declares all the variables found inside a method or lambda block and doesn't allow for the outer variables of similar names to be accessed inside a method or lambda. Although this kind of lexical scoping might be acceptable for methods, it is not at all acceptable for lambdas. So please consider changing the rules so that lambdas share the same lexical scope as Ruby.But also allow for some way for developers to enable creation of local variables with the same name as the outer variable.

adhithyan15 commented 10 years ago

This is one of the design choices that we had made to offer a strict lexical scope. But we definitely do understand the implications of our choice. We will be offering a scope fix for lambda and blocks in 0.0.5.0.0. Methods will remain as a scope gate. We are also planning to introduce a new keyword called local which will allow you to create a new variable with the same name as the outer scope. Stay tuned!