diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-03-06 07:35:15 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-03-06 07:35:15 -0800 |
commit | 24b4b36628fd2ab3d3ff946907ad3a88e325a772 (patch) | |
tree | 0c05defafd9814dd57fb515f910859a84740aac5 /txr.1 | |
parent | bd49a5f0328a2a4091af212961d4d6581d159f67 (diff) | |
download | txr-24b4b36628fd2ab3d3ff946907ad3a88e325a772.tar.gz txr-24b4b36628fd2ab3d3ff946907ad3a88e325a772.tar.bz2 txr-24b4b36628fd2ab3d3ff946907ad3a88e325a772.zip |
* eval.c (apply_intrinsic, lazy_mapcar): Changed linkage to external.
* eval.h (apply_intrinsic, lazy_mapcar): Declarations added.
* stream.c (open_files, open_file_star): New functions.
(stream_init): Registered new functions as intrinsics.
* txr.1: Documented open-files and open-files*. Added to make-catenated-stream documentation.
* genvim.txr: Replace bunch of code with open-files.
* txr.vim: Regenerated.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -11799,6 +11799,49 @@ Note that the operations can fail due to being unsupported. It is the caller's responsibility to make sure all of the streams in the list are compatible with the intended operations. +If the stream list is empty then an empty catenated stream is produced. +Input operations on this stream yield nil, and the unget-char +and unget-byte operations throw an exception. + +.SS Functions open-files and open-files* + +.TP +Syntax: + + (open-files <path-list> [<alternative-stream>]) + (open-files* <path-list> [<alternative-stream>]) + +.TP +Description: + +The open-files and open-files* functions create a list of streams by invoking the open-file +function on each element of <path-list>. These streamas are turned into a catenated +stream as if applied as arguments to make-catenated-stream. + +The effect is that multiple files appear to be catenated together into a single +input stream. + +If the optional <alternative-stream> argument is supplied, then if <path-list> is empty, +that argument is returned instead of an empty catenated stream. + +The difference between open-files and open-files* is that open-files creates all of the +streams up-front. So if any of the paths cannot be opened, the operation throws. +The open-files* variant is lazy: it creates a lazy list of streams out of the +path list. The streams are opened as needed: before the second stream is opened, +the program has to read the first stream to the end, and so on. + +.TP +Example: + +Collect lines from all files that are given as arguments on the command line. If +there are no files, then read from standard input: + + @(next @(open-files *args* *stdin*)) + @(collect) + @line + @(end) + + .SS Function read .TP |