From bb0476aa11a6f4f24c16ddebcaf3917764655f45 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 13 Mar 2017 06:58:26 -0700 Subject: Print method can return : to decline printing. * struct.c (struct_inst_print): Check return value of print method call. If it is the colon keyword, then do not return but rather continue to the regular struct printing code. * txr.1: Documented. --- struct.c | 5 ++--- txr.1 | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/struct.c b/struct.c index 91e6807c..af2bdaaf 100644 --- a/struct.c +++ b/struct.c @@ -1316,9 +1316,8 @@ static void struct_inst_print(val obj, val out, val pretty, if (!nullocp(ptr)) { if (compat) funcall2(deref(ptr), obj, out); - else - funcall3(deref(ptr), obj, out, pretty); - return; + else if (funcall3(deref(ptr), obj, out, pretty) != colon_k) + return; } } diff --git a/txr.1 b/txr.1 index 2cb25577..3ec80d72 100644 --- a/txr.1 +++ b/txr.1 @@ -24112,7 +24112,23 @@ is used. The value returned by the .code print -method is ignored. +method is significant. If the special keyword symbol +.code : +(colon) is returned, then the system will print the object +in the default way, as if no +.code print +method existed: it is understood that the method declined +the responsibility for printing the object. + +If any other value is returned, then it is understood +that the method +.code print +method accepted the responsibility for printing the object, +and the system consequently will generate into +.meta stream +any output output pertaining to +.metn object 's +representation. .coNP Method @ lambda .synb -- cgit v1.2.3