lua-users home
lua-l archive

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


"John D. Ramsdell" wrote:
> 
> "Jonathan  Branam" <sspeare@sspeare.com> writes:
> 
> > http://ase.isu.edu/ase01_07/ase01_07/bookcase/ref_sh/foldoc/14/62.htm
> > lexical scope
> > <programming> (Or "static scope") In a lexically scoped language, the scope
> > of an identifier is fixed at compile-time to be the smallest block
> > (begin/end or function/procedure body) containing the identifier's
> > declaration. This means that an identifier declared in some block is only
> > accessible within that block and from procedures declared within it.
> > Opposite of dynamic scope. See activation record.
> 
> Thank you for finding many references that support my notion of
> lexical scoping.  Thank you also for finding the particular definition
> I was looking for.  Notice that by this definition, Lua is not
> statically scoped.

First, this definition makes no distinction between lexical and static
scope.

Then, this definition takes more constraints on the lexical scope then
most other definitions - it makes the "most closely nested" rule a
requirement.  It excludes all languages that do not use this rule.
What are these languages?  Neither dynamic nor lexical or static.  Not
scoped at all?!?

Further: It says "...only accessible within that block and from procedures
within it."  Maybe it would be better to say "visible" than "accessible"[1].
And in Lua variables are visible from nested functions - only the access
to them is forbidden.

And last: this is from "The Free On-Line Dictionary of Computing" compiled
by hundreds of contributors.  It's hardly a normative reference; especially
this entry has more the nature of a glossary entry.  I guess, if I would
made a more formal chapter about lexical scoping it would be added. ;-)

Ciao, ET.


[1] the wording is a little bit vague anyway: it would not allow nested
blocks to access a variable.  Lua would not even have blocks because
they are not made with "begin/end".  ;-)  And functions are not allowed
either, only procedures...