type: function (subr) location: built-in source file: xlbfun.c Common LISP compatible: similar supported on: all machines
(intern <name-str> ) <name-str> - a string expression
The INTERN function takes a string name - <name-str> and creates a new interned symbol. What this means is that the symbol <name-str> will be placed into the symbol hash table *OBARRAY*. It's value will be unbound. It's property list will be NIL (empty). If the symbol already exists, no error or action is taken and the old values and property lists remain intact. The INTERN function returns the symbol as its result.
(defun lookin (sym) ; create a function to (aref *obarray* ; look inside *OBARRAY* (hash sym (length *obarray*)))); and look for a specific ; symbol - returns a list ; (lookin "FINGERS") ; see if "FINGERS" is a symbol ; returns (:START1) - it isn't (intern "FINGERS") ; intern "FINGERS" as a symbol ; returns FINGERS (lookin "FINGERS") ; returns (FINGERS :START1) (print fingers) ; error: unbound variable ; it exists, but has no value ; (lookin "TOES") ; returns NIL - doesn't exist toes ; error: unbound variable (lookin "TOES") ; returns (TOES) ; the act of looking for a ; value or using a symbol ; causes it to be INTERNed ; (lookin "KNEECAPS") ; returns (MAX MAPLIST) - ; KNEECAPS doesn't exist (setq kneecaps 'a-bone) ; create symbol with a value (lookin "KNEECAPS") ; returns (KNEECAPS MAX MAPLIST)
NOTE: When you INTERN a symbol like "fingers", this gets placed in the *OBARRAY* symbol table as a lower case symbol. Note that this is different from doing an INTERN on "FINGERS". "fingers" and "FINGERS" are two different symbols in *OBARRAY*. Remember also that normal symbols created by XLISP are upper case names. So, an intern of 'fingers or 'FINGERS are normal symbols, and will be the upper-case symbol FINGERS.
COMMON LISP COMPATIBILITY: Common LISP allows an optional package specification, which XLISP does not support.