summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-02-25 19:37:28 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-02-25 19:37:28 -0800
commit0e956fe2a1e390ba433825aa9e1cf125174e68d5 (patch)
tree636da1786542e3069ce9dd5f0b1a85d413406145
parent9c580d08c3e92c17970fb8962a3c0f0f2b9cc5f1 (diff)
downloadtxr-0e956fe2a1e390ba433825aa9e1cf125174e68d5.tar.gz
txr-0e956fe2a1e390ba433825aa9e1cf125174e68d5.tar.bz2
txr-0e956fe2a1e390ba433825aa9e1cf125174e68d5.zip
* lib.c (obj_init): Revert qquote, unquote and splice
to the system namespace, for hygiene. * txr.1: Updated.
-rw-r--r--ChangeLog7
-rw-r--r--lib.c6
-rw-r--r--txr.146
3 files changed, 37 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 35f9553c..83e149e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2014-02-25 Kaz Kylheku <kaz@kylheku.com>
+ * lib.c (obj_init): Revert qquote, unquote and splice
+ to the system namespace, for hygiene.
+
+ * txr.1: Updated.
+
+2014-02-25 Kaz Kylheku <kaz@kylheku.com>
+
* eval.c (eval_init): HAVE_MAKEDEV not HAVE_MKDEV.
2014-02-25 Kaz Kylheku <kaz@kylheku.com>
diff --git a/lib.c b/lib.c
index 3c4b4636..15096f27 100644
--- a/lib.c
+++ b/lib.c
@@ -5094,9 +5094,9 @@ static void obj_init(void)
nongreedy_s = intern(lit("ng0+"), user_package);
compiled_regex_s = intern(lit("compiled-regex"), system_package);
quote_s = intern(lit("quote"), user_package);
- qquote_s = intern(lit("qquote"), user_package);
- unquote_s = intern(lit("unquote"), user_package);
- splice_s = intern(lit("splice"), user_package);
+ qquote_s = intern(lit("qquote"), system_package);
+ unquote_s = intern(lit("unquote"), system_package);
+ splice_s = intern(lit("splice"), system_package);
chset_s = intern(lit("chset"), system_package);
set_s = intern(lit("set"), user_package);
cset_s = intern(lit("cset"), user_package);
diff --git a/txr.1 b/txr.1
index 6d1c1085..ef9600c0 100644
--- a/txr.1
+++ b/txr.1
@@ -12906,12 +12906,12 @@ Example:
(quote (+ 2 2)) ;; yields (+ 2 2), not 4.
-.SS Operator qquote
+.SS Operator sys:qquote
.TP
Syntax:
- (qquote <form>)
+ (sys:qquote <form>)
.TP
Description:
@@ -12943,40 +12943,48 @@ when <val-x> is treated as a Lisp expression and evaluated.
.TP
Examples:
- (qquote a) -> a
+ (sys:qquote a) -> a
- (qquote (a b c)) -> (a b c)
+ (sys:qquote (a b c)) -> (a b c)
- (qquote (1 2 3 (unquote (+ 2 2) (+ 2 3)))) -> (1 2 3 4 (+ 2 3))
+ (sys:qquote (1 2 3 (sys:unquote (+ 2 2) (+ 2 3)))) -> (1 2 3 4 (+ 2 3))
- (quote (unquote (+ 2 2))) -> 4
+ (quote (sys:unquote (+ 2 2))) -> 4
In the second-to-last example, the 1 2 3 and the (+ 2 3) were taken verbatim.
But the (unquote (+ 2 2)) operator caused the evaluation of (+ 2 2) and the
substitution of the resulting value.
The last example shows that <form> can itself be an unquote operator.
-However, note: (quote (splice <form>)) is not valid.
+However, note: (sys:quote (sys:splice <form>)) is not valid.
Note: a way to understand the nesting behavior is a model of quasi-quote
expansion which recursively compiles any nested quasi quotes first, and then
treats the result of their expansion. For instance, in the processing of
-(qquote (qquote (unquote (unquote x)))), the quote operator finds the
-internal (qquote ...) and compiles it to code. During that recursive
-compilation, the syntax (unquote (unquote x)) is encountered.
+(sys:qquote (sys:qquote (sys:unquote (sys:unquote x)))), the quote operator
+finds the internal (sys:qquote ...) and compiles it to code. During that recursive
+compilation, the syntax (sys:unquote (sys:unquote x)) is encountered.
The inner quote processes the outer unquote which belongs to it,
and the (unquote x) becomes material embedded in the compilation,
which will then be found when the outer quasiquote takes the inner
compilation and processes its interior.
-.SS Operator unquote
+Note: qquote, and related symbols, are in the system namespace,
+and so carry the sys: package prefix. This is for hygiene. User code which
+uses the quasiquote syntax can use symbols like unquote without encountering
+problems. For instance the user who is not aware of the internal symbols
+might write '(foo unquote bar) which evaluates to the expected (foo unquote bar).
+Since unquote is not sys:unquote, this is not interpreted
+as '(foo . (unquote bar)) which corresponds to '(foo . ,bar).
+
+.SS Operator sys:unquote
.TP
Syntax:
- (qquote (... (unquote <form>) ...))
+ (sys:qquote (... (sys:unquote <form>) ...))
- (qquote (unquote <form>))
+ (sys:qquote (sys:unquote <form>))
.TP
Description:
@@ -12986,17 +12994,17 @@ binding in the global environment. It is a special syntax that is recognized
within a qquote form, to indicate forms within the quasiquote which are to be
evaluated and insertd into the resulting structure.
-The variant (qquote (unquote <form>)) is equivalent to <form>: the
+The variant (sys:qquote (sys:unquote <form>)) is equivalent to <form>: the
qquote and unquote "cancel out".
Nesting of qquotes and unquotes is explained in the qquote operator.
-.SS Operator splice
+.SS Operator sys:splice
.TP
Syntax:
- (qquote (... (splice <form>) ...))
+ (sys:qquote (... (sys:splice <form>) ...))
.TP
Description:
@@ -13006,15 +13014,15 @@ binding in the global environment. It is a special syntax that is recognized
within a qquote form, to indicate forms within the quasiquote which are to be
evaluated and inserted into the resulting structure.
-The variant (qquote (unquote <form>)) is not permitted and raises
+The variant (sys:qquote (sys:unquote <form>)) is not permitted and raises
an exception if evaluated. The splice syntax must occur within a list,
and not in the dotted position.
-The splice form differs from unquote in that (splice <form>)
+The splice form differs from unquote in that (sys:splice <form>)
requires that <form> must evaluate to a list. That list is
integrated into the surrounding list.
-Nesting of qquotes and unquotes is explained in the qquote operator.
+Nesting of qquotes and unquotes is explained in the sys:qquote operator.
.SH MACROS