diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-11-10 06:57:06 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-11-10 06:57:06 -0800 |
commit | 7c2b95c04cd3a0f566d076fa1ac2d8d93721b2ec (patch) | |
tree | 13ffcb7b051d146b71cda49f62ee576b32fac359 /eval.c | |
parent | a14217b8a4e507a7f75ccc8aa587a44ef0df2414 (diff) | |
download | txr-7c2b95c04cd3a0f566d076fa1ac2d8d93721b2ec.tar.gz txr-7c2b95c04cd3a0f566d076fa1ac2d8d93721b2ec.tar.bz2 txr-7c2b95c04cd3a0f566d076fa1ac2d8d93721b2ec.zip |
Implementing package foreign symbol concept.
* eval.c (eval_init): Register new intrinsics:
package-local-symbols, package-foreign-symbols, use-sym,
unuse-sym, use-package, unuse-package, unintern.
* gc.c (mark_obj): Mark new hidhash member of
struct package.
* lib.c (make_package): Initialize new hidhash
member of struct package.
(lookup_package): New static function.
(find_package): Allow string or symbol argument.
(get_package): New static function.
(delete_package, package_symbols): Use get_package for
flexible package argument; delete_package removes
symbols from other packages via unuse_package.
(package_local_symbols, package_foreign_symbols): New
functions.
(use_sym, unuse_sym): New functions.
(resolve_package_designators): New static function.
(use_package, unuse_package): New functions.
(symbol_present): New static function.
(intern): Revised with get_package for flexible
package argument.
(unintern): New function.
(rehome_sym): Use get_package. Semantics revised.
(obj_print_impl): Use symbol_present function to
determine whether object is visible in *package* and
can be printed without a prefix, rather than naive
home package test.
* lib.h (struct package): New member, hidhash.
(package_local_symbols, package_foreign_symbols, use_sym,
unuse_sym, use_package, unuse_package, unintern): Declared.
* txr.1: Documentation updated. Extended section introducing
the design of packages, and argument conventions. New
functions described. Existing function descriptions revised,
particularly rehome-sym. Missing description of
delete-package added.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -5211,7 +5211,14 @@ void eval_init(void) reg_fun(intern(lit("package-alist"), user_package), func_n0(package_alist)); reg_fun(intern(lit("package-name"), user_package), func_n1(package_name)); reg_fun(intern(lit("package-symbols"), user_package), func_n1(package_symbols)); + reg_fun(intern(lit("package-local-symbols"), user_package), func_n1(package_local_symbols)); + reg_fun(intern(lit("package-foreign-symbols"), user_package), func_n1(package_foreign_symbols)); + reg_fun(intern(lit("use-sym"), user_package), func_n2o(use_sym, 1)); + reg_fun(intern(lit("unuse-sym"), user_package), func_n2o(unuse_sym, 1)); + reg_fun(intern(lit("use-package"), user_package), func_n2o(use_package, 1)); + reg_fun(intern(lit("unuse-package"), user_package), func_n2o(unuse_package, 1)); reg_fun(intern(lit("intern"), user_package), func_n2o(intern, 1)); + reg_fun(intern(lit("unintern"), user_package), func_n2o(unintern, 1)); reg_fun(intern(lit("rehome-sym"), user_package), func_n2o(rehome_sym, 1)); reg_fun(intern(lit("symbolp"), user_package), func_n1(symbolp)); reg_fun(intern(lit("symbol-name"), user_package), func_n1(symbol_name)); |