lua-users home
lua-l archive

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


John D. Ramsdell wrote:
> I think focusing efforts on making the Lua bytecode interpreter
> properly tail recursive is far more important that simplifying the
> Lua language by making it lexically scoped.

I don't agree about the "far more" part... if Lua had full lexcial scoping,
my existing programs would immediately benefit as I could remove all those
ugly manual closures I build with tables.  Newcomers to Lua wouldn't have to
struggle with the mystery of upvalues.

> By the way, I read the December 27, 2000 draft of the book
> on Lua.  I was not pleased to see the claims made on pages 22
> and 45, that Lua is lexically scoped.  On page 45, you wrote
> that Lua functions "...have a form of proper lexical scoping through
> upvalues".  Lexical scoping is discipline for resolving variable
> references based on block structure.  With lexical scoping, a
> reference to a variable within a block refers to the binding defined
> is the nearest enclosing block.  In Lua, an inner-function does not
> have access to the local variables in the function in which it is
> defined, it only has access to a copy of the variables.  Therefore,
> Lua is not lexically scoped.

Previously I had written a page of notes about Lua's scoping issues
(http://lua.swiki.net/13).  By your definition, if !set was removed from
Scheme the resulting language would not be lexcially scoped.  Granted Lua's
lexical scoping is severely limited, but it is lexical scoping.  Note that
Python just added lexcal scoping to the language, and it does not allow
rebinding just like Lua's upvalues.

-John