[m-dev.] Re: [mercury-users] with_stream

Michael Day mikeday at corplink.com.au
Thu Nov 16 10:39:32 AEDT 2000


> That won't work, since `change_stream' followed by `write' will result
> in side effects to things other than the state of the original stream.
> In other words `change_stream' is impure.

I don't quite follow. I left out extra io__state arguments in the original
example, is that the problem?

predicate(S0, S, IO0, IO) :-
	do_stuff(S0, S1),
	( if some_condition_holds then
		change_stream("some other filename", S1, S2, IO0, IO1),
	else
		S2 = S1, IO1 = IO0
	),
	do_stuff(S2, S3),
	predicate(S3, S, IO1, IO).

This assumes that a stream is a handle to its state (like a C FILE) and
the handles can be reassigned (like using freopen). How exactly is it
impure?

Michael


--------------------------------------------------------------------------
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