summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-11-11 22:57:26 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-11-11 22:57:26 -0800
commitb530453f8e0331955b40c741a3b5dcb4bf6084d8 (patch)
treed5cbb337e16a5936e50448cf4ce596b98019682a /share
parent37c881d461e55d5c5115c6c6ed397a3df8913fd2 (diff)
downloadtxr-b530453f8e0331955b40c741a3b5dcb4bf6084d8.tar.gz
txr-b530453f8e0331955b40c741a3b5dcb4bf6084d8.tar.bz2
txr-b530453f8e0331955b40c741a3b5dcb4bf6084d8.zip
New :use-from clause in defpackage.
* share/txr/stdlib/package.tl (defpackage): Implemented new :use-from clause. * txr.1: Documented :use-from and made some improvements to the defpackage documentation.
Diffstat (limited to 'share')
-rw-r--r--share/txr/stdlib/package.tl24
1 files changed, 23 insertions, 1 deletions
diff --git a/share/txr/stdlib/package.tl b/share/txr/stdlib/package.tl
index 4c423145..1827628f 100644
--- a/share/txr/stdlib/package.tl
+++ b/share/txr/stdlib/package.tl
@@ -37,6 +37,23 @@
(name-str (sys:name-str 'package name))
(exp-clauses (append-each ((c clauses))
(tree-case c
+ ((keyword package . rest)
+ (caseql keyword
+ (:use-from
+ ^((let ((p (find-package ',package)))
+ (unless p
+ (throwf 'eval-error
+ "~s: no such package: ~s"
+ 'defpackage ',package))
+ (each ((n ',(mapcar (op sys:name-str 'symbol)
+ rest)))
+ (let ((s (intern n p)))
+ (unless (eq (symbol-package s) p)
+ (throwf 'eval-error
+ "~s: won't use non-local ~s from ~s"
+ 'defpackage s p))
+ (use-sym s ,pkg))))))
+ (t :)))
((keyword . rest)
(caseql keyword
(:use
@@ -50,7 +67,12 @@
(let ((s (intern n ,pkg)))
(unless (eq (symbol-package s) ,pkg)
(unuse-sym s ,pkg)
- (intern n ,pkg))))))))
+ (intern n ,pkg))))))
+ (:use-from
+ (throwf 'eval-error
+ "~s: :use-from clause needs package argument"
+ 'defpackage))
+ (t :)))
(atom
(throwf 'eval-error "~s: invalid clause: ~s"
'defpackage atom))))))