[mercury-users] string

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Dec 4 05:11:11 AEDT 1999

On 03-Dec-1999, Ralph Becket <rbeck at microsoft.com> wrote:
> This does remind me of something I wanted to suggest on this mailing list a
> while back.  A couple of times now I've come across the need for a fixed
> vector type.  For example, I'm working on a Prolog-like term library where
> functors are objects with a name field and a list of arguments.  Since the
> arguments are immutable, representing them as lists seems a bit heavyweight
> (I use up an extra cons cell for each argument).  Arrays would be handy, but
> then you get into all sorts of mode problems (oh for parametric modes!)
> Hmm, maybe it'd be an idea to write an immutable vector type module on top
> of arrays, using dodgy C stuff to convince the compiler that the vectors
> needn't be unique objects.

I think the ordinary `array' type should work just fine if you want
immutable arrays.  Just declare your arrays to have mode `in'
(or let the compiler's mode inference infer it, for that matter).
I'm pretty sure that the complications with regard to modes that you
are talking about only arise if you are trying to do destructive update.

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