From b81a5285f8b9b583c6933e7aa576f3ef0a3a8e82 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 18 Dec 2015 22:31:30 -0800 Subject: Print some instances of qref as dot notation. We must preserve ambiguity-free read-print consistency. * lib.c (simple_qref_args_p): New static function. (obj_print_impl): Check for qref and print as dot notation if its argument list satisfies simple_qref_args_p. --- lib.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lib.c') diff --git a/lib.c b/lib.c index 7b5df796..05ccb45a 100644 --- a/lib.c +++ b/lib.c @@ -8124,6 +8124,21 @@ static void obj_init(void) prog_string = string(progname); } +static val simple_qref_args_p(val args, val pos) +{ + if (nilp(args)) { + return if2(ge(pos, two), t); + } else if (!consp(args)) { + return nil; + } else { + val arg = car(args); + if (symbolp(arg) || (consp(arg) && car(arg) != qref_s)) { + return simple_qref_args_p(cdr(args), succ(pos)); + } + return nil; + } +} + val obj_print_impl(val obj, val out, val pretty) { val ret = obj; @@ -8174,6 +8189,15 @@ val obj_print_impl(val obj, val out, val pretty) obj_print_impl(second(obj), out, pretty); put_string(lit(".."), out); obj_print_impl(third(obj), out, pretty); + } else if (sym == qref_s && simple_qref_args_p(cdr(obj), zero)) { + val iter, next; + for (iter = cdr(obj); iter; iter = next) { + next = cdr(iter); + obj_print_impl(car(iter), out, pretty); + if (next) + put_string(lit("."), out); + iter = next; + } } else { val iter; val closepar = chr(')'); -- cgit v1.2.3