From 87d89d601fba2dd1acc20e723b922da0e7210f1b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 24 Jan 2021 11:12:47 -0800 Subject: printer: do not render @(rcons ...) in .. notation. This fixes the following print-read consistency issue. Both of these objects print as @a..@b. 1> '@(rcons a b) @a..b 2> '(rcons @a b) @a..b We want only the second case. After the this fix: 1> '(rcons @a b) @a..b 2> '@(rcons a b) @(rcons a b) * lib.c (obj_print_impl): In the sys:expr case, we check whether the head of the argument is rcons. If so, we adjust a few local variables and branch directly to the generic list case via goto to print the argument as (rcons ...) without conversion to dotdot range notation. --- lib.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib.c') diff --git a/lib.c b/lib.c index f31b8e79..4fdcaacf 100644 --- a/lib.c +++ b/lib.c @@ -12383,8 +12383,17 @@ val obj_print_impl(val obj, val out, val pretty, struct strm_ctx *ctx) put_char(chr('@'), out); obj_print_impl(arg, out, pretty, ctx); } else if (sym == expr_s && two_elem && consp(arg)) { + val inarg = car(arg); put_char(chr('@'), out); - obj_print_impl(arg, out, pretty, ctx); + if (inarg != rcons_s) { + obj_print_impl(arg, out, pretty, ctx); + } else { + obj = arg; + sym = inarg; + args = cdr(obj); + arg = car(obj); + goto list; + } } else if (sym == rcons_s && have_args && consp(cdr(args)) && !(cddr(args))) { @@ -12440,7 +12449,7 @@ val obj_print_impl(val obj, val out, val pretty, struct strm_ctx *ctx) args = cdr(args); } put_char(chr('`'), out); - } else { + } else list: { val iter; val closepar = chr(')'); val indent = zero; -- cgit v1.2.3