[mercury-users] with_stream

Michael Day mikeday at corplink.com.au
Wed Nov 8 22:31:29 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.

For instance, a daemon that writes log messages to a file. Perhaps the
entire body of code is wrapped inside a with_stream that opens the log
file. But then someone wishes to add functionality to enable the log file
to be changed on the fly, perhaps when the disk fills up or when the
number of entries pass a certain number. This requires breaking out of
whatever recursive loop the daemon is in, exiting the with_stream and
calling a new one. Not too bad, but what if several resources can be
arbitrarily changed in this way? The only solution seems to be to open the
new streams without closing the old ones, similar to the deferred close of
the overlapping streams:

	open A
	open B
	close A
	open C
	close B
	open D...

which is not particularly palatable, or structure all the code around
with_stream, returning lambda predicates (closures? continuations? what's
the word for this?) which seems like it will have a rather pervasive and
not altogether pleasant influence on code design.

In short, can with_stream work in situations when the life time of a
resource is not known?

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