[mercury-users] Lies, Damn lies, and Purity Declarations

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Apr 15 18:34:41 AEST 2002


On 15-Apr-2002, Michael Day <mikeday at bigpond.net.au> wrote:
> 
> :- func very_unsafe_make_io = io.
> 
> :- pragma foreign_proc("C", very_unsafe_make_io = (IO::out), [promise_pure],
> 	"IO = NULL;").
> 
> This function returns the same value every time it is called. The value it
> returns does not depend on external state. I promise to the compiler that
> it's pure. Am I lying?

The value returned does depend on external state.
Values of type `io' represent the state of the entire universe.
The calling convention for values of type `io' is that they are
passed and returned in the actual universe; the `IO' variable in the
C code does not contain the whole value of type `io'.

So yes, you're lying.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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