Against enforce()

Daniel Gibson metalcaedes at gmail.com
Thu Mar 17 08:36:11 PDT 2011


Am 17.03.2011 06:59, schrieb Simen kjaeraas:
> On Thu, 17 Mar 2011 03:03:23 +0100, Daniel Gibson
> <metalcaedes at gmail.com> wrote:
>
>> You're right. I just realized it and wanted to reply that correction
>> to myself but you were faster :)
>> I agree, that *is* helpful.
>> A side note: The documentation says the value is returned if it's
>> "non-zero".
>> enforce() also throws on null (for classes, probably also for
>> pointers) and false (for bool..) - this should probably be mentioned
>> in the docs ;-)
>
> null and false are also zero. :p
>

Technically yes, but it'd be more clear to specifically mention them.
Also "the value is returned" could imply that enforce doesn't work with 
references (=> objects)..
I think enforce's behaviour on bools, objects and pointers would be 
easier to understand if null and false were mentioned :)


More information about the Digitalmars-d mailing list