summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-11-27 07:54:37 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-11-27 07:54:37 -0800
commitb54e6564dade78d3cd673e4640a85c652d3ac656 (patch)
treec1ffc47b885ab30ec81dfe946ac9ef614064571f
parent9ea1afcf8a9240ed2ab746e608ae904ba36d1f83 (diff)
downloadtxr-b54e6564dade78d3cd673e4640a85c652d3ac656.tar.gz
txr-b54e6564dade78d3cd673e4640a85c652d3ac656.tar.bz2
txr-b54e6564dade78d3cd673e4640a85c652d3ac656.zip
Don't throw when printing (sys:quasi . atom).
We do not have perfect read/print consistency for quasiliterals. Programs can construct quasiliterals which cause the printer to throw exceptions, or which don't print such that the same object is read back. However, at least we can handle some trivial cases. In particular, the object (sys:quasi . #<function>) occurs in the system, as the top-level binding of the quasi operator. With this change, we can print that instead of throwing. * lib.c (obj_print_impl): Check that a quasiliteral or quasi-list-literal is a list with at least one argument. Don't print (sys:quasi) or (sys:quasi . non-nil-atom) in the notation.
-rw-r--r--lib.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib.c b/lib.c
index 299263e6..ea16348c 100644
--- a/lib.c
+++ b/lib.c
@@ -9575,11 +9575,11 @@ val obj_print_impl(val obj, val out, val pretty, struct strm_ctx *ctx)
put_string(lit("."), out);
iter = next;
}
- } else if (sym == quasi_s) {
+ } else if (sym == quasi_s && consp(cdr(obj))) {
put_char(chr('`'), out);
out_quasi_str(obj, out, ctx);
put_char(chr('`'), out);
- } else if (sym == quasilist_s) {
+ } else if (sym == quasilist_s && consp(cdr(obj))) {
val args = cdr(obj);
put_string(lit("#`"), out);
if (args) {