lua-users home
lua-l archive

FOLDOC definition of lexical scoping changed

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


The original FOLDOC definition of lexical scoping implied that the
current version of Lua is not lexically scoped. It used to say:
 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.
In contrast, the Dragon book definition implied that Lua is lexically
scoped. From page 411 of "Compilers, Principles, Techniques, and
Tools", by Aho, Sethi, and Ullman, 1986, Addison-Wesley:
 The scope rules of a language determine the treatment of references
 to non-local names. A common rule, called the lexical- or
 static-scope rule, determines the declaration that applies to a
 name by examining the program text alone. Pascal, C, and Ada are
 among the many languages that use lexical scope, with an added
 "most closely nested" stipulation that is discussed below. An
 alternative rule, called the dynamic-scope rule, determines the
 declaration applicable to a name at run time, by considering the
 current activations. Lisp, APL, and Snobol are among the languages
 that use dynamic scope.
The FOLDOC definition of lexical scoping was written by Denis Howe. 
I showed him the Dragon book definition, and he changed his entry to:
 <programming> (Or "static scope") In a lexically scoped language,
 the scope of an identifier is fixed at compile time to some region
 in the source code containing the identifier's declaration. This
 means that an identifier is only accessible within that region
 (including procedures declared within it).
 This contrasts with dynamic scope where the scope depends on the
 nesting of procedure and function calls at run time.
 Statically scoped languages differ as to whether the scope is
 limited to the smallest block (including begin/end blocks)
 containing the identifier's declaration (e.g. C, Perl) or to whole
 function and procedure bodies (e.g. ?), or some larger unit of code
 (e.g. ?).
See http://www.foldoc.org/foldoc/foldoc.cgi?lexical+scope
By this definition, the current version of Lua is lexically scoped. 
Doug Howe's action suggest to me that the definition of lexical
scoping that implies the most closely nested stipulation is falling
out of favor. You can still find this usage in the functional
programming community. Just recently, I noticed that the 1998 book by
Guy Cousineau and Michel Mauny, titled "The Functional Approach to
Programming", uses the term in this way.
In any event, I think there is no ambiguity in saying that Lua
variables do not have static nested scope. This is what I would like
changed.
John

AltStyle によって変換されたページ (->オリジナル) /