Nick Mudge <firstname.lastname@example.org> wrote:
| I've looked around on the Internet for a good definition of what
| exactly "lexical" means in the context of programming, but I have not
| found one, or at least it is not clear.
Well, the first & most basic thing is that the adjective "lexical"
literally means "of or relating to words" or more generally, to text.
E.g., "lexical analysis" is the process of reading a text and
breaking it up into its constituent "lexical tokens" (sometimes
called just "tokens") which then are handed to the "syntactic parser"
(or just "parser") for "syntax analysis". You can Google for those
terms yourself to find out more.
But from your question I suspect you're really asking about
"lexical variables" and "lexical scope", sometimes [as in the
following URL] also called "static scope", see:
especially the "History" paragraph.
You can also look up most of these terms in the CLHS Glossary:
The story begins with the notion of a "scope":
scope n. the structural or textual region of code in which
references to an object, a binding, an exit point, a tag,
or an environment (usually by name) can occur.
Something is "lexically scoped" if you can determine all of the
places where that something is "in scope", that is, has a certain
value, simply by examining the source text -- you don't have to
actually run the program. In Common Lisp, it's defined this way:
lexical scope n. scope that is limited to a spatial or textual
region within the establishing form. ...
Said another way, with "dynamic binding" [see the CLHS], to know
what a (dynamic) variable is going to contain you have to know the
actual runtime (dynamic) history of execution up until the place
*and* exact time you're asking the question. But with lexical
scoping, you can know just by looking at the program text [lexicum].
Having absorbed that, you now probably have enough context to go
read this entire section of the CLHS [although skip or skim the
subsection on "Environment Objects" until later in your studies]:
3.1.1 Introduction to Environments
A binding is ... [trimmed].
An environment is ... [trimmed].
Bindings in an environment are partitioned into namespaces.
126.96.36.199 The Global Environment
188.8.131.52 Dynamic Environments
184.108.40.206 Lexical Environments
220.127.116.11 Environment Objects
Rob Warnock <email@example.com>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607