22 Apr 21:18
Proposal: some changes to streams
From: Slava Pestov <slava@...>
Subject: Proposal: some changes to streams
Newsgroups: gmane.comp.lang.factor.general
Date: 2008-04-22 19:20:30 GMT
Subject: Proposal: some changes to streams
Newsgroups: gmane.comp.lang.factor.general
Date: 2008-04-22 19:20:30 GMT
Hi all,
Right now we have an 'stdio' variable and various words which operate
on it,
: read stdio get stream-read ;
: readln stdio get stream-readln ;
: write stdio get stream-write ;
: print stdio get stream-print ;
with-stream rebinds it and closes it after, with-stream* rebinds it
without closing.
This makes for very nice and concise code, but there's one problem
with it and that it cannot express the case where you want to read
from one file and write to another at the same time. Instead, you need
to do something like this,
"in.txt" utf8 <file-reader> [
"out.txt" latin1 <file-writer> [
<duplex-stream> [
...
] with-stream*
] with-disposal
] with-disposal
Or if you want to read from a file and print to the console in the
same code,
stdio get
(Continue reading)
On Apr 22, 2008, at 2:40 PM, Eduardo Cavazos wrote:
> Why couldn't the above example be written like this:
>
> "in.txt" utf8 <file-reader>
> "out.txt" latin1 <file-writer>
> <duplex-stream>
> [ ... ]
> with-stream
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
RSS Feed