diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-08-19 07:12:24 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-08-19 07:12:24 -0700 |
commit | fc44a670c11fb653b3600327082eeb8df8b82563 (patch) | |
tree | 97a04b679704c75bbabb1b37cdd52258cd732b6c /txr.1 | |
parent | c38f93bc7f763ae776c7e68de120faea169d7f05 (diff) | |
download | txr-fc44a670c11fb653b3600327082eeb8df8b82563.tar.gz txr-fc44a670c11fb653b3600327082eeb8df8b82563.tar.bz2 txr-fc44a670c11fb653b3600327082eeb8df8b82563.zip |
new functions: find-symbol and find-symbol-fb.
Turns out, there is already a find_symbol in lib.c, completely
unused.
* eval.c (eval_init): Register find-symbol and find-symbol-fb
intrinsics.
* lib.c (find_symbol): Fix this hitherto unused function to do
correct defaulting of the package argument and, to accept an
additional argument specifying the not-found value.
(find_symbol_fb): New function.
* lib.c (find_symbol): Declaration updated.
(find_symbol_fb): Declared.
* txr.1: Documented.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 58 |
1 files changed, 58 insertions, 0 deletions
@@ -51096,6 +51096,64 @@ is not found in the package as either an interned or hidden symbol, then the function has no effect and returns .codn nil . +.coNP Functions @ find-symbol and @ find-symbol-fb +.synb +.mets (find-symbol < name >> [ package <> [ notfound-val ]]) +.mets (find-symbol-fb < name >> [ package <> [ notfound-val ]]) +.syne +.desc +The +.code find-symbol +and +.code find-symbol-fb +functions search +.meta package +for a symbol called +.metn name . +That argument must be a character string. + +If the +.meta package +argument is omitted, the parameter defaults to the +current value of +.codn *package* . + +If the symbol is found in +.meta package +then it is returned. + +If the symbol is not found in +.metn package , +then the function +.code find-symbol-fb +also searches the packages listed in the fallback list of +.meta package +are searched, in order. Only these packages themselves are searched, +not their own fallback lists. If a symbol called +.meta name +is found, the search terminates and that symbol is returned. + +The function +.code find-symbol +only searches +.metn package , +ignoring its fallback list. + +If a symbol called +.meta name +isn't found, then these functions return +.meta notfound-val +is returned, which defaults to +.codn nil . + +Note: an ambiguous situation exists when +.meta notfound-val +is a symbol, such as its default value +.codn nil , +because if that symbol is successfully found, +it is indistinguishable from +.metn notfound-val . + .coNP Function @ rehome-sym .synb .mets (rehome-sym < symbol <> [ package ]) |