From 051bf360110a5b9649fe9a2b5b35b2dcfed868d6 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 28 Mar 2015 07:34:01 -0700 Subject: * eval.c (eval_init): register get-lines as having one optional argument. * lib.c (lazy_stream_cons): Default the argument to std_input. * txr.1: Document that the stream is optional in get-lines. --- ChangeLog | 9 +++++++++ eval.c | 2 +- lib.c | 2 ++ txr.1 | 10 ++++++++-- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 229245fa..a8ddd5fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2015-03-28 Kaz Kylheku + + * eval.c (eval_init): register get-lines as having one optional + argument. + + * lib.c (lazy_stream_cons): Default the argument to std_input. + + * txr.1: Document that the stream is optional in get-lines. + 2015-03-24 Kaz Kylheku * Makefile (enforce): Update error error message. diff --git a/eval.c b/eval.c index 5b8dcad8..c4196e72 100644 --- a/eval.c +++ b/eval.c @@ -4226,7 +4226,7 @@ void eval_init(void) reg_fun(intern(lit("break-str"), user_package), func_n2(break_str)); reg_fun(intern(lit("lazy-stream-cons"), user_package), func_n1(lazy_stream_cons)); - reg_fun(intern(lit("get-lines"), user_package), func_n1(lazy_stream_cons)); + reg_fun(intern(lit("get-lines"), user_package), func_n1o(lazy_stream_cons, 0)); reg_fun(intern(lit("lazy-str"), user_package), func_n3o(lazy_str, 1)); reg_fun(intern(lit("lazy-stringp"), user_package), func_n1(lazy_stringp)); reg_fun(intern(lit("lazy-str-force-upto"), user_package), func_n2(lazy_str_force_upto)); diff --git a/lib.c b/lib.c index 9be90ea6..d6f44dad 100644 --- a/lib.c +++ b/lib.c @@ -5171,6 +5171,8 @@ static val lazy_stream_func(val env, val lcons) val lazy_stream_cons(val stream) { + stream = default_arg(stream, std_input); + if (real_time_stream_p(stream)) { return make_lazy_cons(func_f1(stream, simple_lazy_stream_func)); } else { diff --git a/txr.1 b/txr.1 index 6cff30e4..8c654150 100644 --- a/txr.1 +++ b/txr.1 @@ -15034,14 +15034,20 @@ another lazy cons (as in the example under .coNP Functions @ lazy-stream-cons and @ get-lines .synb .mets (lazy-stream-cons << stream ) -.mets (get-lines << stream ) +.mets (get-lines <> [ stream ]) .syne .desc The .code lazy-stream-cons and .code get-lines -functions are synonyms. Thus, the following +functions are synonyms, except that the +.meta stream +argument is optional in +.code get-lines +and defaults to +.codn *stdin* . +Thus, the following description of .code lazy-stream-cons also applies to -- cgit v1.2.3