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

Ralph Becket rafe at cs.mu.OZ.AU
Mon Nov 18 10:38:23 AEDT 2002


Michael Day, Monday, 18 November 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?

These structures may be constructed at run-time - unlike ML, we don't
monomorphise a program during compilation.

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

It was a pragmatic decision.  It allows one do write traditional
functional programs, largely without having to worry about modes.

The new sub-typing scheme being worked on by Mark Brown may make
even that special case go away, although it's not clear to me
whether it'll handle uniqueness or not.

The problem is that workout out a non-cumbersome mode system that
admits efficient analysis is still something of a research problem.

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

I quite like the idea of using a type class to get around awkward mode
problems.

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