User Tools

Site Tools


ch2_3_pack_sym

This is an old revision of the document!


Package and symbol operations

Functions that deal with symbols alone or in the context of packages. Here we just describe the functions in terms of input and output. Further explanation will be in different section.

SYMBOL-VALUE and SYMBOL-FUNCTION

Return the symbol's value resp. function object bound in global context. Both accept one argument that must be symbol.

>(symbol-value 'pi)       ; PI is global variable
3.14159
 
>(symbol-function 'cons)  ; CONS is standard function
#<function CONS>

SYMBOL-NAME

Expects one argument that must be symbol. Returns the symbol's name as string.

>(symbol-name 'pi)       ; PI is global variable
"PI"

FIND-SYMBOL

Finds symbol by name in a package. Expects one or two string arguments. First is symbol name and the second is optional package name. If the package name is not supplied, dynamic current package is used. Returns the symbol if it is found, otherwise NIL. If it is found, also prints the symbol's relation to the package. Note that in Common LISP, this function returns two values, the second is a keyword which characterizes the relation. LabLISP function prints the same keyword, but it is not output of the function, because LabLisp does not support multiple values yet.

>(find-symbol "PI")            ; USER package will be searched
:INHERITED                     ; it is inherited from base package LABLISP
PI
 
>(find-symbol "PI" "LABLISP")  ; now we search in LABLISP package
:EXTERNAL                      ; there the symbol is external
PI

MAKE-SYMBOL

INTERN

SYMBOL-PACKAGE

PACKAGE-NAME

FIND-PACKAGE, MAKE-PACKAGE, IN-PACKAGE, LIST-ALL-PACKAGES, USE-PACKAGE, UNUSE-PACKAGE

IMPORT, EXPORT, UNINTERN, UNEXPORT

PACKAGE-USE-LIST. PACKAGE-USED-BY-LIST, PACKAGE-INTERNAL-SYMBOLS, PACKAGE-EXTERNAL-SYMBOLS,

ch2_3_pack_sym.1619078270.txt.gz · Last modified: 2021/04/22 01:57 by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki