symbolsymbol, t
11.0.0 11 10.3.0 2 10.3.0 3 11.0.0 12 Some stuff about INTERN, IMPORT, SHADOWING-IMPORT, UNINTERN, etc. was commented out.
Symbols are used for their object identity to name various entities in Common Lisp, including (but not limited to) linguistic entities such as variables and functions.
Symbols can be collected together into packages. A symbol is said to be interned in a package if it is accessible in that package; the same symbol can be interned in more than one package. If a symbol is not interned in any package, it is called uninterned.
An interned symbol is uniquely identifiable by its name from any package in which it is accessible.
!!! Sandra: I REALLY dislike this terminology. Can't we call these "attributes" rather than "components" and leave out the discussion of "cells" entirely?
My attempt at simplifying some of this convoluted discussion of ``cells'' follows. --sjl 16 Mar 92 \term{Symbols} have the following components, or \term{cells}. (In each case, it is \term{implementation-dependent} how these \term{cells} are represented. For example, they might be explicitly represented as a ``slots'' in the \term{symbol} itself, or they might be represented as external associations between the \term{symbol} and the \term{cell} \term{value} (if any) in some \term{environment} or table, or in some cases they might not be explicitly represented at all.)
Symbols have the following attributes. "historically" => "historical" per Boyer/Kaufmann/Moore #11 (by X3J13 vote at May 4-5, 1994 meeting) -kmp 9-May-94For historical reasons, these are sometimes referred to as cells, although the actual internal representation of symbols and their attributes is implementation-dependent.
The name of a symbol is a string used to identify the symbol. Every symbol has a name, and the consequences are undefined if that name is altered. The name is used as part of the external, printed representation of the symbol; see Section 2.1 (Character Syntax). The function symbol-name returns the name of a given symbol. I replaced this on suggestion of KAB. It doesn't match CHARACTER-PROPOSAL 2.6.2,
so who knows how it got here. -kmp 21-Jan-92
The \term{characters} in a \term{symbol}'s \term{name} must be \term{graphic},
and may come from any supported \term{character} \term{repertoire}.A symbol may have any character in its name.
10.3.0 1 10.0.0 3 10.0.0 4 10.1.0 1 10.1.0 2 10.1.0 3
10.0.0 4 10.3.0 4 11.0.0 8 11.0.0 10 11.0.0 28
The object in this cell is called the home package of the symbol. If the home package is nil, the symbol is sometimes said to have no home package.
When a symbol is first created, it has no home package. When it is first interned, the package in which it is initially interned becomes its home package. The home package of a symbol can be accessed by using the function symbol-package.
If a symbol is uninterned from the package which is its home package, its home package is set to nil. Depending on whether there is another package in which the symbol is interned, the symbol might or might not really be an uninterned symbol. A symbol with no home package is therefore called apparently uninterned.
The consequences are undefined if an attempt is made to alter the home package of a symbol Added per Sandra -kmp 13-Dec-91
``accessible'' is wrong here -- sjl 16 Mar 92
accessibleexternal in the common-lisp package or the keyword package.
10.1.0 4
The property list of a symbol provides a mechanism for associating named attributes with that symbol. The operations for adding and removing entries are destructive to the property list. Common Lisp provides operators both for direct manipulation of property list objects (e.g., see getf, remf, and symbol-plist) and for implicit manipulation of a symbol's property list by reference to the symbol (e.g., see get and remprop). The property list associated with a fresh symbol is initially null. !!! Sandra: What about the property list of symbols in the COMMON-LISP package?
10.0.0 8
!!! Sandra: You could avoid this awkwardness [in sentence 1] by not talking about
cells at all! All you have to say is:
"If a symbol has a value attribute, it is said to be bound ..."
!!! KAB: Does this first sentence really have to be said?
My attempt at rewording this is below. --sjl 16 Mar 92
Conceptually, every \term{symbol} has a \term{value cell}, although
no \term{implementation} is required to explicitly represent it as an \term{object}.
A \term{symbol}'s \term{value cell} might or might not contain an \term{object}.
If it does contain an \term{object}, it is said to be \term{bound},If a symbol has a value attribute, it is said to be bound, and that fact can be detected by the function boundp. The object contained in the value cell of a bound symbol is the value of the global variable named by that symbol, and can be accessed by the function symbol-value. A symbol can be made to be unbound by the function makunbound.
The consequences are undefined if an attempt is made to change the value of a symbol that names a constant variable, or to make such a symbol be unbound.
!!! Sandra: See comment on "Value" above.
!!! KAB: Does this first sentence really have to be said?
My attempt at rewording this is below. --sjl 16 Mar 92
Conceptually, every \term{symbol} has a \term{function cell}, although
no \term{implementation} is required to explicitly represent it as an \term{object}.
A \term{symbol}'s \term{function cell} might or might not contain an \term{object}.
If it does contain an \term{object}, it is said to be \term{fbound},If a symbol has a function attribute, it is said to be fbound, and that fact can be detected by the function fboundp. If the symbol is the name of a function in the global environment, the function cell contains the function, and can be accessed by the function symbol-function. If the symbol is the name of either a macro in the global environment (see macro-function) or a special operator (see special-operator-p), the symbol is fbound, and can be accessed by the function symbol-function, but the object which the function cell contains is of implementation-dependent type and purpose. A symbol can be made to be funbound by the function fmakunbound.
The consequences are undefined if an attempt is made to change the functional value of a symbol that names a special form.
Operations on a symbol's value cell and function cell are sometimes described in terms of their effect on the symbol itself, but the user should keep in mind that there is an intimate relationship between the contents of those cells and the global variable or global function definition, respectively.
Symbols are used as identifiers for lexical variables and lexical function definitions, but in that role, only their object identity is significant. Common Lisp provides no operation on a symbol that can have any effect on a lexical variable or on a lexical function definition.
Section 2.3.4 (Symbols as Tokens), Section 2.3.1.1 (Potential Numbers as Tokens), Section 22.1.3.3 (Printing Symbols)