[m-dev.] for review: stream I/O
Fergus Henderson
fjh at cs.mu.OZ.AU
Tue Oct 3 21:51:09 AEDT 2000
On 03-Oct-2000, Michael Day <mcda at students.cs.mu.oz.au> wrote:
>
> > Well, if you don't know the scope of the stream, I think it should
> > always be possible to write your program in continuation-passing
> > style, so that if necessary all the code between the point where
> > the stream is opened and the end of `main' ends up being inside
> > the scope of the `with_stream'. This won't necessarily be convenient,
> > but I think it should be possible...
>
> Is it possible to open and close overlapping streams with with_stream?
>
> eg:
>
> open A
> open B
> do stuff with A and B
> close A
> close B
No. But you can write
with_stream(pred(A) -->
with_stream(pred(B) -->
do stuff with A and B
)
)
which is equivalent to
open A
open B
do stuff with A and B
close B
close A
The order of the closes is not likely to be important, is it?
I guess the more difficult situation is when you have something like
open A
open B
do stuff with A and B
close A
open C
do stuff with B and C
close B
open D
do stuff with C and D
...
... O(N) steps later ...
...
do stuff with X and Y
close X
open Z
do stuff with Y and Z
close Y
close Z
In this case, if you use `with_stream', you may have to delay the
close of A by O(N) steps.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list