[mercury-users] Mode System Hassles

Ralph Becket rbeck at microsoft.com
Tue Oct 19 20:15:41 AEST 1999


It's becoming apparent to me that the mode system may *have* to be extended
to somehow include parametric modes.  I suspect that all sorts of things are
not going to work with nested unique modes when they arrive unless something
is done about the mode system.

Example: I've written some code using arrays of arrays of ints.  The various
modes of such an object are, following the mode declarations in array.m,

:- mode aarray_di == di(uniq_array(uniq_array)).
:- mode aarray_ui == in(uniq_array(uniq_array)).
:- mode aarray_uo == out(uniq_array(uniq_array)).

The clanger happens when I try to call array__lookup/2, which has mode

:- mode array__lookup(array_ui, in) = out is det.

If X is an aarray object, then `Y = array__lookup(X, 123)' leaves Y with
inst ground, rather than uniq_array which is what I need if I'm going to
do anything with Y!

Example: try using list__foldl/4 on mostly-unique structures.  The library
writer didn't think of supplying/think it necessary to supply such a mode.
Bit of a pain in the neck if you want that functionality, though; it really
hinders code reuse.

Now, I'm aware that I'm trying to finesse in nested unique mode stuff before
it's ready, but (a) this stuff isn't actually using unique modes because
array.m doesn't and (b) I don't see how nested arrays can be made work *at
all*
in the general case without parametric modes.  This is a very serious
problem,
IMHO.

Question: if we abandon the (IMO not v. useful & poss. harmful) goal of
passing around partially instantiated structures, doesn't the whole mode
thing become much simpler?

Cheers,

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