Global variables (modules) operate very differently from local variables. That is the big split. eval() only operates at the top level. Types are not really scopes at all, just data structures. The difference is that a variable reference (just "x" or "x=y") will never refer to anything inside a type or object.
On Sun, Feb 9, 2014 at 5:34 PM, Bill Janssen <[email protected]> wrote: > I'm still struggling with understanding Julia's scopes. Are they > consistent? Why does the following happen? I'd expect "y" to be lexically > bound by the let. This is version 0.2. > > julia> let y = 4; eval(symbol("y")); end > ERROR: y not defined > > In addition, one can refer to certain scopes (modules, types) with functions > such as isdefined(), but not to others (let scopes, for instance). Why is > that? >
