summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-01-10 23:15:14 -0800
committerKaz Kylheku <kaz@kylheku.com>2012-01-10 23:15:14 -0800
commit08e356af25f0e6ab9c8ad1583181aa529c61ca91 (patch)
tree29bad6267f5b5a846dbcaf8555045dc9cb66f8c1
parent09c6384d6bb4e3c44bf64299657f492ad4bf756a (diff)
downloadtxr-08e356af25f0e6ab9c8ad1583181aa529c61ca91.tar.gz
txr-08e356af25f0e6ab9c8ad1583181aa529c61ca91.tar.bz2
txr-08e356af25f0e6ab9c8ad1583181aa529c61ca91.zip
* eval.c (tostring, tostringp): New static functions.
(eval_init): New functions registered. * txr.1: Stub sections created. * txr.vim: Updated.
-rw-r--r--ChangeLog9
-rw-r--r--eval.c16
-rw-r--r--txr.12
-rw-r--r--txr.vim3
4 files changed, 28 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 00152406..92145108 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2012-01-10 Kaz Kylheku <kaz@kylheku.com>
+ * 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 <kaz@kylheku.com>
+
Spat of new features having to do with lazy processing.
* eval.c (prog1_s, gen_s, generate_s, delay_s, promise_s): New symbol
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