User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cl:types:symbol [2017/05/01 21:00] (current)
Line 1: Line 1:
 +====== System Class SYMBOL ======
 +
 +====Class Precedence List==== ​
 +**symbol**, **[[CL:​Types:​t]]**
 +
 +====Description====
 +//​[[CL:​Glossary:​symbol|Symbols]]//​ are used for their //​[[CL:​Glossary:​object]]//​ identity to name various entities in Common Lisp, including (but not limited to) linguistic entities such as //​[[CL:​Glossary:​variables]]//​ and //​[[CL:​Glossary:​functions]]//​.
 +
 +//​[[CL:​Glossary:​symbol|Symbols]]//​ can be collected together into //​[[CL:​Glossary:​packages]]//​. A //​[[CL:​Glossary:​symbol]]//​ is said to be //​[[CL:​Glossary:​interned]]//​ in a //​[[CL:​Glossary:​package]]//​ if it is //​[[CL:​Glossary:​accessible]]//​ in that //​[[CL:​Glossary:​package]]//;​ the same //​[[CL:​Glossary:​symbol]]//​ can be //​[[CL:​Glossary:​interned]]//​ in more than one //​[[CL:​Glossary:​package]]//​. If a //​[[CL:​Glossary:​symbol]]//​ is not //​[[CL:​Glossary:​interned]]//​ in any //​[[CL:​Glossary:​package]]//,​ it is called //​[[CL:​Glossary:​uninterned]]//​.
 +
 +An //​[[CL:​Glossary:​interned]]//​ //​[[CL:​Glossary:​symbol]]//​ is uniquely identifiable by its //​[[CL:​Glossary:​name]]//​ from any //​[[CL:​Glossary:​package]]//​ in which it is //​[[CL:​Glossary:​accessible]]//​.
 +
 +//​[[CL:​Glossary:​symbol|Symbols]]//​ have the following attributes.
 +
 +For historical reasons, these are sometimes referred to as //​[[CL:​Glossary:​cells]]//,​ although the actual internal representation of //​[[CL:​Glossary:​symbol|symbols]]//​ and their attributes is //​[[CL:​Glossary:​implementation-dependent]]//​.
 +
 +\beginlist
 +
 +\itemitem{\b{Name}}
 +
 +The //​[[CL:​Glossary:​name]]//​ of a //​[[CL:​Glossary:​symbol]]//​ is a //​[[CL:​Glossary:​string]]//​ used to identify the //​[[CL:​Glossary:​symbol]]//​. Every //​[[CL:​Glossary:​symbol]]//​ has a //​[[CL:​Glossary:​name]]//,​
 +
 +and the consequences are undefined if that //​[[CL:​Glossary:​name]]//​ is altered.
 +
 +The //​[[CL:​Glossary:​name]]//​ is used as part of the external, printed representation of the //​[[CL:​Glossary:​symbol]]//;​ see section {\secref\CharacterSyntax}. The //​[[CL:​Glossary:​function]]//​ **[[CL:​Functions:​symbol-name]]** returns the //​[[CL:​Glossary:​name]]//​ of a given //​[[CL:​Glossary:​symbol]]//​.
 +
 +A //​[[CL:​Glossary:​symbol]]//​ may have any //​[[CL:​Glossary:​character]]//​ in its //​[[CL:​Glossary:​name]]//​.
 +
 +===Package===
 +The //​[[CL:​Glossary:​object]]//​ in this //​[[CL:​Glossary:​cell]]//​ is called the //​[[CL:​Glossary:​home package]]// of the //​[[CL:​Glossary:​symbol]]//​. If the //​[[CL:​Glossary:​home package]]// is **[[CL:​Constant Variables:​nil]]**,​ the //​[[CL:​Glossary:​symbol]]//​ is sometimes said to have no //​[[CL:​Glossary:​home package]]//​.
 +
 +When a //​[[CL:​Glossary:​symbol]]//​ is first created, it has no //​[[CL:​Glossary:​home package]]//​. When it is first //​[[CL:​Glossary:​interned]]//,​ the //​[[CL:​Glossary:​package]]//​ in which it is initially //​[[CL:​Glossary:​interned]]//​ becomes its //​[[CL:​Glossary:​home package]]//​. The //​[[CL:​Glossary:​home package]]// of a //​[[CL:​Glossary:​symbol]]//​ can be //​[[CL:​Glossary:​accessed]]//​ by using the function **[[CL:​Functions:​symbol-package]]**.
 +
 +If a //​[[CL:​Glossary:​symbol]]//​ is //​[[CL:​Glossary:​uninterned]]//​ from the //​[[CL:​Glossary:​package]]//​ which is its //​[[CL:​Glossary:​home package]]//,​ its //​[[CL:​Glossary:​home package]]// is set to **[[CL:​Constant Variables:​nil]]**. Depending on whether there is another //​[[CL:​Glossary:​package]]//​ in which the //​[[CL:​Glossary:​symbol]]//​ is //​[[CL:​Glossary:​interned]]//,​ the symbol might or might not really be an //​[[CL:​Glossary:​uninterned]]//​ //​[[CL:​Glossary:​symbol]]//​. A //​[[CL:​Glossary:​symbol]]//​ with no //​[[CL:​Glossary:​home package]]// is therefore called //​[[CL:​Glossary:​apparently uninterned]]//​.
 +
 +The consequences are undefined if an attempt is made to alter the //​[[CL:​Glossary:​home package]]// of a //​[[CL:​Glossary:​symbol]]//​
 +
 +external in the //​[[CL:​Glossary:​package]]//​ ''​**common-lisp**''​ or the //​[[CL:​Glossary:​package]]//​ ''​**keyword**''​.
 +
 +===Property list===
 +The //​[[CL:​Glossary:​property list]]// of a //​[[CL:​Glossary:​symbol]]//​ provides a mechanism for associating named attributes with that //​[[CL:​Glossary:​symbol]]//​. The operations for adding and removing entries are //​[[CL:​Glossary:​destructive]]//​ to the //​[[CL:​Glossary:​property list]]//. Common Lisp provides //​[[CL:​Glossary:​operators]]//​ both for direct manipulation of //​[[CL:​Glossary:​property list]]// //​[[CL:​Glossary:​object|objects]]//​ (//e.g.// see **[[CL:​Functions:​getf]]**,​ **[[CL:​Functions:​remf]]**,​ and **[[CL:​Functions:​symbol-plist]]**) and for implicit manipulation of a //​[[CL:​Glossary:​symbol]]//'​s //​[[CL:​Glossary:​property list]]// by reference to the //​[[CL:​Glossary:​symbol]]//​ (//e.g.// see **[[CL:​Functions:​get]]** and **[[CL:​Functions:​remprop]]**). The //​[[CL:​Glossary:​property list]]// associated with a //​[[CL:​Glossary:​fresh]]//​ //​[[CL:​Glossary:​symbol]]//​ is initially //​[[CL:​Glossary:​null]]//​.
 +
 +===Value===
 +If a symbol has a value attribute, it is said to be //​[[CL:​Glossary:​bound]]//,​ and that fact can be detected by the function **[[CL:​Functions:​boundp]]**. The //​[[CL:​Glossary:​object]]//​ contained in the //​[[CL:​Glossary:​value cell]]// of a //​[[CL:​Glossary:​bound]]//​ //​[[CL:​Glossary:​symbol]]//​ is the //​[[CL:​Glossary:​value]]//​ of the //​[[CL:​Glossary:​global variable]]//​ named by that //​[[CL:​Glossary:​symbol]]//,​ and can be //​[[CL:​Glossary:​accessed]]//​ by the function **[[CL:​Functions:​symbol-value]]**. A //​[[CL:​Glossary:​symbol]]//​ can be made to be //​[[CL:​Glossary:​unbound]]//​ by the function **[[CL:​Functions:​makunbound]]**.
 +
 +The consequences are undefined if an attempt is made to change the //​[[CL:​Glossary:​value]]//​ of a //​[[CL:​Glossary:​symbol]]//​ that names a //​[[CL:​Glossary:​constant variable]]//,​ or to make such a //​[[CL:​Glossary:​symbol]]//​ be //​[[CL:​Glossary:​unbound]]//​.
 +
 +===Function===
 +If a symbol has a function attribute, it is said to be //​[[CL:​Glossary:​fbound]]//,​ and that fact can be detected by the function **[[CL:​Functions:​fboundp]]**. If the //​[[CL:​Glossary:​symbol]]//​ is the //​[[CL:​Glossary:​name]]//​ of a //​[[CL:​Glossary:​function]]//​ in the //​[[CL:​Glossary:​global environment]]//,​ the //​[[CL:​Glossary:​function cell]]// contains the //​[[CL:​Glossary:​function]]//,​ and can be //​[[CL:​Glossary:​accessed]]//​ by the function **[[CL:​Functions:​symbol-function]]**. If the //​[[CL:​Glossary:​symbol]]//​ is the //​[[CL:​Glossary:​name]]//​ of either a //​[[CL:​Glossary:​macro]]//​ in the //​[[CL:​Glossary:​global environment]]//​ (see **[[CL:​Functions:​macro-function]]**) or a //​[[CL:​Glossary:​special operator]]//​ (see **[[CL:​Functions:​special-operator-p]]**),​ the //​[[CL:​Glossary:​symbol]]//​ is //​[[CL:​Glossary:​fbound]]//,​ and can be //​[[CL:​Glossary:​accessed]]//​ by the function **[[CL:​Functions:​symbol-function]]**,​ but the //​[[CL:​Glossary:​object]]//​ which the //​[[CL:​Glossary:​function cell]]// contains is of //​[[CL:​Glossary:​implementation-dependent]]//​ //​[[CL:​Glossary:​type]]//​ and purpose. A //​[[CL:​Glossary:​symbol]]//​ can be made to be //​[[CL:​Glossary:​funbound]]//​ by the function **[[CL:​Functions:​fmakunbound]]**.
 +
 +The consequences are undefined if an attempt is made to change the //​[[CL:​Glossary:​functional value]]// of a //​[[CL:​Glossary:​symbol]]//​ that names a //​[[CL:​Glossary:​special form]]//.
 +
 +Operations on a //​[[CL:​Glossary:​symbol]]//'​s //​[[CL:​Glossary:​value cell]]// and //​[[CL:​Glossary:​function cell]]// are sometimes described in terms of their effect on the //​[[CL:​Glossary:​symbol]]//​ itself, but the user should keep in mind that there is an intimate relationship between the contents of those //​[[CL:​Glossary:​cells]]//​ and the //​[[CL:​Glossary:​global variable]]//​ or global //​[[CL:​Glossary:​function]]//​ definition, respectively.
 +
 +//​[[CL:​Glossary:​symbol|Symbols]]//​ are used as identifiers for //​[[CL:​Glossary:​lexical variable|lexical variables]]//​ and lexical //​[[CL:​Glossary:​function]]//​ definitions,​ but in that role, only their //​[[CL:​Glossary:​object]]//​ identity is significant. Common Lisp provides no operation on a //​[[CL:​Glossary:​symbol]]//​ that can have any effect on a //​[[CL:​Glossary:​lexical variable]]//​ or on a lexical //​[[CL:​Glossary:​function]]//​ definition.
 +
 +====See Also====
 +  * {\secref\SymbolTokens}
 +  * {\secref\PotentialNumbersAsTokens}
 +  * {\secref\PrintingSymbols}
 +
 +\issue{CHARACTER-PROPOSAL:​2-6-3} \issue{CHARACTER-PROPOSAL:​2-6-2} \issue{LISP-SYMBOL-REDEFINITION:​MAR89-X3J13}