diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-12-18 22:31:30 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-12-18 22:31:30 -0800 |
commit | b81a5285f8b9b583c6933e7aa576f3ef0a3a8e82 (patch) | |
tree | 368b00af32d36f31702c19f123014cc4fcb75016 | |
parent | a188de0260fbe4f4c940963d0acc7210de4017c3 (diff) | |
download | txr-b81a5285f8b9b583c6933e7aa576f3ef0a3a8e82.tar.gz txr-b81a5285f8b9b583c6933e7aa576f3ef0a3a8e82.tar.bz2 txr-b81a5285f8b9b583c6933e7aa576f3ef0a3a8e82.zip |
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.
-rw-r--r-- | lib.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -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(')'); |