Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Common Lisp
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Determiners of scope=== The circumstances which determine scope in Common Lisp include: * the location of a reference within an expression. If it's the leftmost position of a compound, it refers to a special operator or a macro or function binding, otherwise to a variable binding or something else. * the kind of expression in which the reference takes place. For instance, <code>(go x)</code> means transfer control to label <code>x</code>, whereas <code>(print x)</code> refers to the variable <code>x</code>. Both scopes of <code>x</code> can be active in the same region of program text, since tagbody labels are in a separate namespace from variable names. A special form or macro form has complete control over the meanings of all symbols in its syntax. For instance, in <code>(defclass x (a b) ())</code>, a class definition, the <code>(a b)</code> is a list of base classes, so these names are looked up in the space of class names, and <code>x</code> isn't a reference to an existing binding, but the name of a new class being derived from <code>a</code> and <code>b</code>. These facts emerge purely from the semantics of <code>defclass</code>. The only generic fact about this expression is that <code>defclass</code> refers to a macro binding; everything else is up to <code>defclass</code>. * the location of the reference within the program text. For instance, if a reference to variable <code>x</code> is enclosed in a binding construct such as a [[let expression|<code>let</code>]] which defines a binding for <code>x</code>, then the reference is in the scope created by that binding. * for a variable reference, whether or not a variable symbol has been, locally or globally, declared special. This determines whether the reference is resolved within a lexical environment, or within a dynamic environment. * the specific instance of the environment in which the reference is resolved. An environment is a run-time dictionary which maps symbols to bindings. Each kind of reference uses its own kind of environment. References to lexical variables are resolved in a lexical environment, et cetera. More than one environment can be associated with the same reference. For instance, thanks to recursion or the use of multiple threads, multiple activations of the same function can exist at the same time. These activations share the same program text, but each has its own lexical environment instance. To understand what a symbol refers to, the Common Lisp programmer must know what kind of reference is being expressed, what kind of scope it uses if it is a variable reference (dynamic versus lexical scope), and also the run-time situation: in what environment is the reference resolved, where was the binding introduced into the environment, et cetera.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Common Lisp
(section)
Add topic