From 08e356af25f0e6ab9c8ad1583181aa529c61ca91 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 10 Jan 2012 23:15:14 -0800 Subject: * eval.c (tostring, tostringp): New static functions. (eval_init): New functions registered. * txr.1: Stub sections created. * txr.vim: Updated. --- ChangeLog | 9 +++++++++ eval.c | 16 ++++++++++++++++ txr.1 | 2 +- txr.vim | 3 ++- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 00152406..92145108 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2012-01-10 Kaz Kylheku + + * eval.c (tostring, tostringp): New static functions. + (eval_init): New functions registered. + + * txr.1: Stub sections created. + + * txr.vim: Updated. + 2012-01-10 Kaz Kylheku Spat of new features having to do with lazy processing. diff --git a/eval.c b/eval.c index 3798dca5..53baae3b 100644 --- a/eval.c +++ b/eval.c @@ -1247,6 +1247,20 @@ static val lazy_mappendv(val fun, val list_of_lists) return lazy_appendv(lazy_mapcarv(fun, list_of_lists)); } +static val tostring(val obj) +{ + val ss = make_string_output_stream(); + obj_print(obj, ss); + return get_string_from_stream(ss); +} + +static val tostringp(val obj) +{ + val ss = make_string_output_stream(); + obj_pprint(obj, ss); + return get_string_from_stream(ss); +} + static val symbol_function(val sym) { return lookup_fun(nil, sym); @@ -1547,6 +1561,8 @@ void eval_init(void) reg_fun(intern(lit("format"), user_package), func_n2v(formatv)); reg_fun(intern(lit("print"), user_package), func_n2(obj_print)); reg_fun(intern(lit("pprint"), user_package), func_n2(obj_pprint)); + reg_fun(intern(lit("tostring"), user_package), func_n1(tostring)); + reg_fun(intern(lit("tostringp"), user_package), func_n1(tostringp)); 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 bfe68435..31c8fd73 100644 --- a/txr.1 +++ b/txr.1 @@ -5988,7 +5988,7 @@ Certain object types have a custom equal function. .SS Function format -.SS Functions print, pprint +.SS Functions print, pprint, tostring, tostringp .SS Function make-string-input-stream diff --git a/txr.vim b/txr.vim index 90a12203..96c0bf0a 100644 --- a/txr.vim +++ b/txr.vim @@ -47,7 +47,8 @@ syn keyword txl_keyword contained < >= <= max min search-regex match-regex syn keyword txl_keyword contained make-hash gethash sethash pushhash remhash syn keyword txl_keyword contained hash-count get-hash-userdata set-hash-userdata hashp maphash syn keyword txl_keyword contained hash-eql hash-equal eval *stdout* *stdin* -syn keyword txl_keyword contained *stderr* format print pprint make-string-input-stream +syn keyword txl_keyword contained *stderr* format print pprint tostring tostringp +syn keyword txl_keyword contained make-string-input-stream syn keyword txl_keyword contained make-string-byte-input-stream make-string-output-stream syn keyword txl_keyword contained get-string-from-stream make-strlist-output-stream syn keyword txl_keyword contained get-list-from-stream close-stream -- cgit v1.2.3