[mercury-users] some [T] ...

Michael Day mikeday at yeslogic.com
Mon Nov 18 10:27:08 AEDT 2002


> Values of type foo are represented by a pointer to a cell containing two words.
> The first word is the "typeclass_info" pointer,  which records information
> about the `foo(T)' instance, including the type_info for T and function
> pointers for each of the methods of foo(T).  The second word is the
> value of type T.  It is not necessarily a pointer.

So the typeclass_info would point to a structure that is shared between
all values of foo that have the same type T?

> Another alternative is to pass around a func -- if the function has mode
> func(in, in, ...) = out then in recent (ROTD) versions of Mercury you
> can just use mode `in' or `out'.

Sadly, I need to thrash the io state with this thing :)

The function-considered-ground feature really seems like a bandaid applied
to a sucking chest wound when it comes to making data structures
containing higher order stuff.

Anyway, two words would be perfect storage for a foo, although now that I
think about it I suppose that could be reduced to one by making a custom
store with a get predicate with the appropriate mode to return another
predicate, but that's probably overkill.

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