[m-rev.] for review: uint operations in array.m
Zoltan Somogyi
zoltan.somogyi at runbox.com
Sat Jan 3 03:10:59 AEDT 2026
On Sat, 3 Jan 2026 02:02:21 +1100, Julien Fischer <jfischer at opturion.com> wrote:
> You will need to be particularly careful with this. Our target
> languages impose a number of constraints on arrays.
> The main two that are relevant here are that
>
> 1. In C# and Java, array index expressions have type int; indexes
> of other integral types will be implicitly converted (where allowed).
I left the predicates implemented using foreign_procs using ints. None
have been changed to use uints.
> Obviously, some operations, such as size/1 will always be safe. I've noted
> one group below that definitely are not in their present form and I think
> correctness arguments need to be made for some of the others.
Which others?
> > +uinit(Size, Item, Array) :-
> > + array.init_2(uint.cast_to_int(Size), Item, Array).
>
> As I mentioned above, this will be a problem. Consider, the following on a
> system where int and uint are 32-bit:
>
> array.uinit(2147483648u, "foo", Array)
>
> Ditto for all of the predicates and functions that create an array from a given
> size in some way (e.g. generate and friends).
Thanks for catching that. The attached interdiff covers those predicates.
Do you have comments on the rest of the diff?
Zoltan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: INTERDIFF
Type: application/octet-stream
Size: 3258 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20260103/8aff6edf/attachment.obj>
More information about the reviews
mailing list