[mercury-users] threading states

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Jul 28 17:17:28 AEST 2000

On 28-Jul-2000, Michael Day <mcda at students.cs.mu.oz.au> wrote:
> > The new MLDS-based back-end optimizes away the passing of
> > `io__state' and `store__store(S)', but it does not do so
> > for user-defined unit types.
> That's interesting, I thought io__state was equivalent to c_pointer,
> rather than being a unit type?

Yes, io__state is defined as

	:- type io__state ---> io__state(c_pointer).

If io__state was defined as a unit type, then the front end might get
too clever and decide that it could optimize away procedures that do
IO, since they would be declared to only output a unit type.

So the above definition of io__state using c_pointer ensures that the
compiler front-end treats the io__state as an abstract type whose
actual definition is in foreign code, thus ensuring that the compiler
front-end won't make any assumptions about it.

However, for the compiler back-end, we don't want to generate
code which actually passes the io__state arguments.  So, when we
get to the point of generating imperative code, we want to eliminate
the io__state arguments if possible.

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