[phobos] enforce() vs. assert() for range primitives

Don Clugston dclugston at googlemail.com
Wed Aug 18 23:04:52 PDT 2010


On 19 August 2010 02:27, Jonathan M Davis <jmdavisprog at gmail.com> wrote:
> On Wednesday, August 18, 2010 17:09:59 Michel Fortin wrote:
>> Le 2010-08-18 à 19:08, Jonathan M Davis a écrit :
>> > The ideal situation would be to use asserts in all cases where it's going
>> > to be bugs in the program rather than bad user input and that they go
>> > away in release mode.
>>
>> I'd say the ideal situation would be to have the 'in' contracts checked on
>> the caller's side. That way a program compiled in debug mode would still
>> check the input it sends to Phobos, and whether Phobos was compiled in
>> debug or release mode would only affect its internal checks, not the
>> checks about its inputs.
>
> That would be nice. I doubt that that could be done very reasonably, if at all.
> But it would make good sense. If you could do it, there would be code bloat in
> the debug version, but it would go away in release, so it shouldn't be a big
> deal. A great idea, but I rather doubt it'll happen. But as you said, it would
> be the ideal situation.

I'm not certain that the current scheme works correctly. There's an
extremely nasty bug:
3602 ICE(tocsym.c) compiling a class, if its super class has preconditions
as a result of in contracts being a nested function.


More information about the phobos mailing list