Function intern

Syntax:

intern string &optional package symbol, status

Arguments and Values:

string—a string.

package—a package designator. The default is the current package.

symbol—a symbol.

status—one of :inherited, :external, :internal, or nil.

Description:

11.2.0 20intern enters a symbol named string into package. If a symbol whose name is the same as string is already accessible in package, it is returned. If no such symbol is accessible in package, a new symbol with the given name is created and entered into package as an internal symbol, or as an external symbol if the package is the keyword package; package becomes the home package of the created symbol.

11.2.0 21 11.2.0 22The first value returned by intern, symbol, is the symbol that was found or created. Sandra thinks, and I agree, that this is confused and doesn't belong here. -kmp 14-Feb-92 \issue{CHARACTER-PROPOSAL:2-1-1} It is \term{implementation-dependent} but consistent with \funref{read}, which \term{implementation-defined} \term{attributes} are removed. \endissue{CHARACTER-PROPOSAL:2-1-1}The meaning of the secondary value, status, is as follows:

:internal

The symbol was found and is directlypresent in package as an internal symbol.

:external

The symbol was found and is directlypresent as an external symbol.

:inherited

The symbol was found and is inherited via use-package (which implies that the symbol is internal).

nil

No pre-existing symbol was found, so one was created.

10.3.0 6 On Sandra's advice, I stole this paragraph from MAKE-SYMBOL with mods to make it fit better here. -kmp 14-Feb-92It is implementation-dependent whether the string that becomes the new symbol's name is the given string or a copy of it. Once a string has been given as the string argument to intern in this situation where a new symbol is created, the consequences are undefined if a subsequent attempt is made to alter that string.

Examples:

 (in-package "COMMON-LISP-USER") → #<PACKAGE "COMMON-LISP-USER">
 (intern "Never-Before") → |Never-Before|, NIL
 (intern "Never-Before") → |Never-Before|, :INTERNAL 
 (intern "NEVER-BEFORE" "KEYWORD") → :NEVER-BEFORE, NIL
 (intern "NEVER-BEFORE" "KEYWORD") → :NEVER-BEFORE, :EXTERNAL

Side Effects:

None.

Affected By:

None.

Exceptional Situations:

None.

See Also:

find-symbol, read, symbol, unintern, Section 2.3.4 (Symbols as Tokens)

Notes:

11.0.0 51intern does not need to do any name conflict checking because it never creates a new symbol if there is already an accessible symbol with the name given.

X3J13 Cleanup Issue