[mercury-users] ML_OMIT_ARRAY_BOUNDS_CHECKS for C# grade

Julien Fischer juliensf at csse.unimelb.edu.au
Sun Oct 7 15:53:04 AEDT 2012


Hi,

On Sat, 6 Oct 2012, Jeff Thompson wrote:

> Hello.  When making the C# grade, does it automatically set 
> ML_OMIT_ARRAY_BOUNDS_CHECKS?  (I assume it should because the backing C# 
> Array class already does bounds checks.)

Yes, it does but the underlying C# array class does not do the correct
thing so far as Mercury is concerned when the bounds check fails.  For
Mercury we want a index_out_of_bounds/0 exception to be raised.

> If not, where do I set this before making the C# grade?

You would need to pass it as an additional flag to the C# compiler, e.g.

     -define:ML_OMIT_ARRAY_BOUNDS_CHECKS

using for example mmc's --csharp-flags option, or the EXTRA_CSC_FLAGS
mmake variable ...

However, with recent versions of Mercury I simply wouldn't bother.  Just
use the unsafe_ of the various array operations if you are sure that the
bounds check will always succeed for calls to them.  This is what the array
module itself does internally.

Cheers,
Julien.
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list