-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
Hello Julia developers,
congratulations with your great new language. I was singing 'O Julia' out loud all day yesterday.
But now my bug report. Notwithstanding the let, global and local keywords, it seems there is not always a clear distinction in Julia between variable declaration and assignment. This breaks encapsulation and can lead to hard to find bugs.
function some_scope()
...
... many lines of code
...
f = () -> x = 42 # Not clear if this declares a local variable or assigns to one from the enclosing scope.
end
Matlab's scoping rules we don't even need to discuss [1], Coffeescript is a disaster [2], please don't copy Ruby on this one [3], Perl and Javascript are ok as long as you don't forget your my's and var's (or use strict), Python fixed it in version 3 [4], and one could say Scheme got it right the first time in 1970 [5].
What is the reasoning behind Julia's intricate scoping rules?
[1] http://www.mathworks.nl/help/techdoc/matlab_prog/f4-39683.html#f4-73993
[2] jashkenas/coffeescript#712
[3] http://www.rubyist.net/~matz/slides/rc2003/mgp00010.html
[4] http://www.python.org/dev/peps/pep-3104/
[5] http://news.ycombinator.com/item?id=3379962