diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-06-16 06:14:29 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-06-16 06:14:29 -0700 |
commit | 60301ab68ec6a6b7ecb72f83d411c651e029a587 (patch) | |
tree | 9682a11bc65ebb42ef012a13c10b6f61cfff08df /share | |
parent | 40c1dee7647ddb7d4768a2eadf9915ab29e62f59 (diff) | |
download | txr-60301ab68ec6a6b7ecb72f83d411c651e029a587.tar.gz txr-60301ab68ec6a6b7ecb72f83d411c651e029a587.tar.bz2 txr-60301ab68ec6a6b7ecb72f83d411c651e029a587.zip |
txr-case: upkeep.
* share/txr/stdlib/txr-case.tl (txr-case-impl): If the input
is a stream, then convert it to a lazy list of lines, so that
running multiple functions against it produces sane,
backtracking behavior, like a @(cases) construct.
* tests/011/txr-case.expected: Updated.
* tests/011/txr-case.txr: Now actually contains a test case
for txr-case.
* txr.1: Address an issue reported by Paul A. Patience: the
input to match-fun, txr-if and txr-when may be a stream. That
has always been the case in the implementation. Also document
that when the input is a single string, it is treated as a
list. Document the new requirement in txr-case that a stream
is converted into lazy list of lines.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/txr-case.tl | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/share/txr/stdlib/txr-case.tl b/share/txr/stdlib/txr-case.tl index 4f51ea48..244c58b7 100644 --- a/share/txr/stdlib/txr-case.tl +++ b/share/txr/stdlib/txr-case.tl @@ -65,4 +65,6 @@ (defmacro txr-case (input-expr . clauses) (let ((input (gensym "input-"))) ^(let ((,input ,input-expr)) + (if (streamp ,input) + (set ,input (get-lines ,input))) (txr-case-impl ,input ,*clauses)))) |