From 01148ef9f86426f0b520752ae2f930c6c1c06903 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 22 Feb 2014 19:56:38 -0800 Subject: * eval.c (prinl, pprinl): New functions. (eval_init): Registered as intrinsics. * txr.1: Documented. --- ChangeLog | 7 +++++++ eval.c | 16 ++++++++++++++++ txr.1 | 15 +++++++++++---- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1664beed..d2351387 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2014-02-22 Kaz Kylheku + + * eval.c (prinl, pprinl): New functions. + (eval_init): Registered as intrinsics. + + * txr.1: Documented. + 2014-02-22 Kaz Kylheku * lib.c (obj_init): changing the quote, qquote, unquote diff --git a/eval.c b/eval.c index 13244706..9a30b391 100644 --- a/eval.c +++ b/eval.c @@ -2819,6 +2819,20 @@ static val and_fun(val vals) return item; } +static val prinl(val obj, val stream) +{ + val ret = obj_print(obj, stream); + put_char(chr('\n'), stream); + return ret; +} + +static val pprinl(val obj, val stream) +{ + val ret = obj_pprint(obj, stream); + put_char(chr('\n'), stream); + return ret; +} + void eval_init(void) { protect(&top_vb, &top_fb, &top_mb, &special, @@ -3128,6 +3142,8 @@ void eval_init(void) reg_fun(intern(lit("pprint"), user_package), func_n2o(obj_pprint, 1)); reg_fun(intern(lit("tostring"), user_package), func_n1(tostring)); reg_fun(intern(lit("tostringp"), user_package), func_n1(tostringp)); + reg_fun(intern(lit("prinl"), user_package), func_n2o(prinl, 1)); + reg_fun(intern(lit("pprinl"), user_package), func_n2o(pprinl, 1)); reg_fun(intern(lit("make-string-input-stream"), user_package), func_n1(make_string_input_stream)); reg_fun(intern(lit("make-string-byte-input-stream"), user_package), func_n1(make_string_byte_input_stream)); reg_fun(intern(lit("make-string-output-stream"), user_package), func_n0(make_string_output_stream)); diff --git a/txr.1 b/txr.1 index 8e663236..285b3bce 100644 --- a/txr.1 +++ b/txr.1 @@ -11150,13 +11150,15 @@ truncated off entirely, including the decimal point. .PP -.SS Functions print, pprint, tostring, tostringp +.SS Functions print, pprint, prinl, pprinl, tostring, tostringp .TP Syntax: (print []) (pprint []) + (prinl []) + (pprinl []) (tostring ) (tostringp ) @@ -11172,7 +11174,11 @@ a similar object of the same kind when it appears in TXR source code. The pprint function ("pretty print") does not strive for read-print consistency. For instance it prints a string object simply by dumping its characters, rather than by adding the surrounding quotes and rendering escape syntax for -special characters. +special characters. Both functions return . + +The prinl and pprinl functions are like print and pprint, except +that they issue a newline character after printing the object. +These functions also return . The tostring and tostringp functions are like print and pprint, but they do not accept a stream argument, instead printing to a freshly @@ -11183,10 +11189,11 @@ and calls to these functions: (format stream "~s" obj) <--> (print obj stream) (format t "~s" obj) <--> (print obj) + (format t "~s\en" obj) <--> (prinl obj) (format nil "~s" obj) <--> (tostring obj) -For pprint and tostringp, the equivalence is produced by using "~a" -in format rather than "~s". +For pprint, tostringp and pprinl, the equivalence is produced by using "~a" in +format rather than "~s". .SS Function streamp -- cgit v1.2.3