[m-dev.] Re: Sort of array bug.
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Feb 7 10:43:43 AEDT 2001
On 06-Feb-2001, Ralph Becket <rbeck at microsoft.com> wrote:
> >From Fergus Henderson on 06/02/2001 15:14:10
> > arrays don't use unique modes. This implies that the compiler will
> > order the first ("FAULTY") example just using ordinary left-to-right
> > ordering, as constrained by the ordinary in/out modes, but ignoring
> > uniqueness. So
>
> Thanks! I need a `--do-what-I-mean' flag on the compiler.
>
> > > Assuming this isn't my bug (I've spent half a day getting this
> > > far...) I reckon some kind of public warning is in order!
> >
> > Good idea. A comment at the top of library/array.m is probably
> > the right place to document it. There should be a similar comment
> > for bitmap and hash_table.
>
> This sound all right (at the top of array.m with references to it
> in bitmap.m and hash_table.m)?
>
> % WARNING!
> %
> % Arrays are currently not unique objects - until this situation is
> % resolved it is up to the programmer to ensure that arrays are used
> % in such a way as to preserve correctness. In the absence of mode
> % reordering, one should therefore assume that evaluation will take
> % place in left-to-right order. For example, the following code will
> % probably not work as expected (f is a function, A an array, I an
> % index, and X an appropriate value):
> %
> % Y = f(A ^ elem(I) := X, A ^ elem(I))
> %
> % The compiler is likely to compile this as
> %
> % V0 = A ^ elem(I) := X,
> % V1 = A ^ elem(I),
> % Y = f(V0, V1)
> %
> % and will be unaware that the first line should be ordered
> % *after* the second. The safest thing to do is write things out
> % by hand in the form
> %
> % A0I = A0 ^ elem(I),
> % A1 = A0 ^ elem(I) := X,
> % Y = f(A1, A0I)
That looks great.
> Of course, this is another place where ordered conjunction would be
> handy :)
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list