ch2_3_pack_sym
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
ch2_3_pack_sym [2021/04/22 01:37] – created admin | ch2_3_pack_sym [2025/01/29 08:35] (current) – admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
**//Package and symbol operations// | **//Package and symbol operations// | ||
- | Functions that deal with symbols alone or in the context of packages. | + | 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. |
'' | '' | ||
Line 11: | Line 11: | ||
3.14159 | 3.14159 | ||
- | > | + | > |
#< | #< | ||
</ | </ | ||
- | SYMBOL-NAME | + | '' |
- | FIND-SYMBOL | + | Expects one argument that must be symbol. Returns the symbol' |
- | MAKE-SYMBOL | + | <code lisp> |
+ | > | ||
+ | " | ||
+ | </ | ||
+ | |||
+ | '' | ||
+ | |||
+ | Finds symbol by name in a package. Expects one string argument - the symbol name - and optional argument which is a package designator. Package designator can be string or symbol or package object itself. If the package name is not supplied, dynamic current package is used. Returns the symbol if it is found, otherwise '' | ||
+ | |||
+ | <code lisp> | ||
+ | > | ||
+ | PI | ||
+ | : | ||
+ | |||
+ | > | ||
+ | PI | ||
+ | : | ||
+ | </ | ||
+ | |||
+ | It is prefered to call the packages by string names, when we explicitly know it. It is also possible to use a symbol, with the name same as the name of the package. But it is important to know that the package is not bound to the symbol. | ||
+ | |||
+ | <code lisp> | ||
+ | (find-symbol " | ||
+ | </ | ||
+ | |||
+ | The name of the symbol '' | ||
+ | |||
+ | <code lisp> | ||
+ | (find-symbol " | ||
+ | </ | ||
+ | |||
+ | Here the symbol '' | ||
+ | |||
+ | '' | ||
+ | |||
+ | Creates new symbol with given name, outside of any package (homeless). Expects one string argument. | ||
+ | |||
+ | <code lisp> | ||
+ | > | ||
+ | #:BLA ; the prefix means that the symbol is homeless | ||
+ | </ | ||
+ | |||
+ | The example above creates the symbol, it is returned, but then it is discrded, because it has no owner and no binding. | ||
+ | |||
+ | '' | ||
+ | |||
+ | Like '' | ||
+ | |||
+ | <code lisp> | ||
+ | >(intern " | ||
+ | BLA | ||
+ | NIL ; NIL means that it is a new symbol | ||
+ | |||
+ | >(intern " | ||
+ | BLA | ||
+ | : | ||
+ | </ | ||
+ | |||
+ | '' | ||
+ | |||
+ | Expects single argument that must be symbol. Returns the symbol' | ||
+ | |||
+ | <code lisp> | ||
+ | > | ||
+ | #<The LABLISP package> | ||
+ | </ | ||
+ | |||
+ | '' | ||
+ | |||
+ | Expects single argument that must be package object. Returns the name as string. | ||
+ | |||
+ | <code lisp> | ||
+ | > | ||
+ | " | ||
+ | </ | ||
+ | |||
+ | '' | ||
+ | |||
+ | Expects one argument that must be package designator. Package designator can be string or symbol or package object itself. Returns the package object, if it exists. | ||
+ | |||
+ | <code lisp> | ||
+ | > | ||
+ | #<The USER package> | ||
+ | </ | ||
+ | |||
+ | '' | ||
+ | |||
+ | Expects single argument that must be string. Creates and returns new package with that name, unless it already exists - in that case complains and returns '' | ||
+ | |||
+ | <code lisp> | ||
+ | > | ||
+ | #<The P1 package> | ||
+ | </ | ||
+ | |||
+ | '' | ||
+ | |||
+ | Expects single argument that must be string. Switches the current package (dynamic variable '' | ||
+ | |||
+ | <code lisp> | ||
+ | > | ||
+ | #<The P1 package> | ||
+ | </ | ||
+ | |||
+ | '' | ||
+ | |||
+ | No arguments, returns list of all packages in the environment. | ||
+ | |||
+ | <code lisp> | ||
+ | > | ||
+ | (#<The USER package> #<The LABLISP package> #<The KEYWORD package> | ||
+ | </ | ||
+ | |||
+ | '' | ||
+ | |||
+ | Adds one or more packages to be used by a target package. Exported symbols from the source package(s), will be accessible through the target package. First argument is package designator or list of package designators. Second argument is optional target package designator, default is the dynamic current package.((dynamic current package means package bound to *PACKAGE* symbol in dynamic environment)) | ||
+ | |||
+ | Beware of name conflicts! | ||
+ | |||
+ | <code lisp> | ||
+ | > | ||
+ | T | ||
+ | </ | ||
+ | |||
+ | '' | ||
+ | |||
+ | Removes one or more packages from a target package' | ||
+ | |||
+ | <code lisp> | ||
+ | > | ||
+ | T | ||
+ | </ | ||
+ | |||
+ | '' | ||
+ | |||
+ | Lists all packages that are used by a target package. Single argument is target package designator. The argument is optional, defaults to the dynamic current package. | ||
+ | |||
+ | Following two examples assume the situation after the '' | ||
+ | |||
+ | <code lisp> | ||
+ | > | ||
+ | (#<The P1 package> #<The LABLISP package> | ||
+ | </ | ||
+ | |||
+ | '' | ||
+ | |||
+ | Lists all packages that use a target package. Single argument is target package designator. The argument is optional, defaults to the dynamic current package. | ||
+ | |||
+ | <code lisp> | ||
+ | > | ||
+ | (#<The P2 package> | ||
+ | </ | ||
+ | |||
+ | |||
+ | '' | ||
+ | |||
+ | Symbol becomes internal of the target package, if the symbol was // | ||
+ | |||
+ | Beware of name conflicts! | ||
+ | |||
+ | |||
+ | '' | ||
+ | |||
+ | Removes symbol from package, so it is no longer accessible as internal or external symbol. If the package is the symbol' | ||
+ | |||
+ | The name '' | ||
+ | |||
+ | '' | ||
+ | |||
+ | Makes inherited or internal symbol to be external in given package. If the symbol is inherited, '' | ||
+ | |||
+ | Beware of name conflicts! | ||
- | INTERN | + | '' |
- | SYMBOL-PACKAGE | + | Undoes '' |
- | PACKAGE-NAME | + | '' |
- | FIND-PACKAGE, MAKE-PACKAGE, | + | Lists all internal symbols of a target package. Single argument is target package designator. The argument is optional, defaults to the dynamic current package. |
- | IMPORT, EXPORT, UNINTERN, UNEXPORT | + | '' |
- | PACKAGE-USE-LIST. PACKAGE-USED-BY-LIST, | + | Lists all external symbols of a target package. Single argument is target package designator. The argument is optional, defaults to the dynamic current package. |
ch2_3_pack_sym.1619077067.txt.gz · Last modified: 2021/04/22 01:37 by admin