[mercury-users] with_stream
Michael Day
mikeday at corplink.com.au
Wed Nov 15 18:31:28 AEDT 2000
> Regarding the with_stream predicate proposed by Fergus in the recent
> stream library debate, it seems that it would unnecessarily complicate
> interactive applications that do not know ahead of time how long they will
> hold a stream open.
Alternatively, if a stream is considered to be a handle to some piece of
state rather than state itself, that would seem to permit the creation of
a change_stream predicate called from within with_stream that closes the
current stream and opens a new one.
with_stream("some filename", predicate, io__states)
predicate(S0, S) :-
do_stuff(S0, S1),
( if some_condition_holds then
change_stream("some other filename", S1, S2),
else
S2 = S1
),
do_stuff(S2, S3),
predicate(S3, S).
Presumably change_stream would need to open the new stream *before*
closing the current stream, in case the new stream doesn't open. This
might complicate the implementation of with_stream, though I'm not sure
how much yet. But it or something like it seems necessary if with_stream
is not to drive people crazy.
Any thoughts?
Michael
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list