alwaysAssert() [was: Against enforce()]

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Mar 17 17:10:16 PDT 2011


On 03/17/2011 06:38 PM, dsimcha wrote:
> On 3/17/2011 7:12 PM, Walter Bright wrote:
>>
>> Sure, but there is plenty wrong with using enforce() for bug detection
>> even if alwaysAssert does not exist. For one thing, such uses encourage
>> others to misunderstand and misuse enforce.
>>
>> Additionally, alwaysAssert is an obvious one liner. I think such things
>> need to be very frequently used to consider them part of the standard
>> library. Otherwise, we risk Phobos becoming a morass of trivia.
>
> What makes you think it wouldn't be used very frequently? It seems silly
> to me to turn off asserts in non-performance-critical bits of code just
> because I don't want bounds checking or the more expensive asserts.

To me it sounds perfectly normal that there are integrity checks that 
you want to keep at all times, whereas others you only want to keep in a 
debug build.

Andrei


More information about the Digitalmars-d mailing list