lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Jay Carlson comments on John Ramsdell:
>> By the way, the more I think about the suspected Python method for
>> making that language lexically scoped, the more I like it.  That is, I
>> like the idea that a language is lexically scoped, but as sacrifice to
>> allow efficient implementations, variables become immutable whenever
>> they are referenced by a closure.
>This gives me the creeps.  To understand whether something is writable or
>not you can't just look at its declaration; you have to inspect all of the
>code inside its defining block.

I wholeheartedly agree, the current solution at least clearly marks those
upvalues as something special and readonly.

In my personal opinion, the current solution of upvalues in lua is quite
sufficient.
The only thing i'd like to see is upvalues from more than 1 level above:

local var
function level1()
  function level2()
    print(%var) -- or, as an uglier solution: print(%%var)
  end
  ...
end

currently, you have to propagate such values by hand:

local var
function level1()
  local _var = %var
  function level2()
    print(%_var)
  end
  ...
end

just my 2 (euro)cents,
Peter