summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-04-25 07:07:03 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-04-25 07:07:03 -0700
commit3eca0ce001125b1f7042d2d6fe036f036d0845aa (patch)
tree7ea981fde1b56e0af8d9b015def50b3d06d660e8 /share
parent182edce101eccdeb9da8679f857f096c5e60b7db (diff)
downloadtxr-3eca0ce001125b1f7042d2d6fe036f036d0845aa.tar.gz
txr-3eca0ce001125b1f7042d2d6fe036f036d0845aa.tar.bz2
txr-3eca0ce001125b1f7042d2d6fe036f036d0845aa.zip
compiler: replace "$" package hack.
When compile-file writes emits the file, it does so with *package* bound to a temporary package named "$" so that all the symbols get fully qualified. Problem is, this is a valid package name and is added to the package list. While the package exists, symbols such as $:a could be interned. If such symbols occur in code being compiled, they get emitted using unqualified names. Let's introduce an internal interface for making an anonymous package which isn't on the list of package, and which has a name that results in bad syntax if it occurs in print. * eval.c (eval_init): Register sys:make-anon-package intrinsic. * lib.c (make_package_common): New static function. (make_package): Package construction and initialization code moved into make_package_common. (make_anon_package): New function. * lib.h (make_anon_package): Declared. * share/txr/stdlib/compiler.tl (usr:compile-file): When writing out translation, bind *package* to anonymous package from sys:make-anon-package.
Diffstat (limited to 'share')
-rw-r--r--share/txr/stdlib/compiler.tl7
1 files changed, 3 insertions, 4 deletions
diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl
index ea9b932d..572cb396 100644
--- a/share/txr/stdlib/compiler.tl
+++ b/share/txr/stdlib/compiler.tl
@@ -1559,10 +1559,9 @@
((neq obj err-ret)))
(compile-form (sys:expand* obj)))
(let ((*print-circle* t)
- (*package* (make-package "$")))
- (unwind-protect
- (prinl out.(get) out-stream)
- (delete-package *package*))))
+ (*package* (sys:make-anon-package)))
+ (prinl out.(get) out-stream)
+ (delete-package *package*)))
(let ((parser (sys:get-parser in-stream)))
(when (> (sys:parser-errors parser) 0)