[m-rev.] for review: add array.generate/2 and array.generate_foldl/5
Julien Fischer
juliensf at csse.unimelb.edu.au
Tue May 24 17:33:59 AEST 2011
On Tue, 24 May 2011, Paul Bone wrote:
> On Sun, May 22, 2011 at 01:57:14AM +1000, Julien Fischer wrote:
>>
>> Branches: main
>>
>> Add procedures to the array module for creating and filling new arrays in a
>> single call. (This avoids situations where the elements of a newly created
>> array are set to initial value which is then immediately overwritten.)
>>
>> library/array.m:
>> Add the function array.generate/2 and the predicate
>> array.generate_foldl/5.
>>
>> Add an XXX regarding some C# foreign code in this module.
>>
>> NEWS:
>> Announce the new predicate and function.
>>
>> tests/hard_coded/Mmakefile:
>> tests/hard_coded/array_gen.{m,exp}:
>> Test the new functionality.
>>
>
> This is cool, thanks.
Thanks - I've committed this with the following change to make things
safer in debugging grades:
diff -u library/array.m library/array.m
--- library/array.m 21 May 2011 14:54:32 -0000
+++ library/array.m 24 May 2011 07:30:06 -0000
@@ -1160,8 +1160,19 @@
does_not_affect_liveness],
"
ML_alloc_array(Array, Size + 1, MR_ALLOC_ID);
- Array->size = Size;
- Array->elements[0] = FirstElem;
+
+ /*
+ ** In debugging grades we fill the array with the first element
+ ** in case the return value of a call to this predicate is examined
+ ** in the debugger.
+ */
+ #if defined(MR_EXEC_TRACE)
+ ML_init_array(Array, Size, FirstElem);
+ #else
+ Array->size = Size;
+ Array->elements[0] = FirstElem;
+ #endif
+
").
:- pragma foreign_proc("C#",
unsafe_init(Size::in, FirstElem::in) = (Array::array_uo),
I spoke to Peter Wang yesterday about the C# XXX and will fix that in
subsequent change.
Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list