Making preconditions better specified and faster

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Sun Dec 18 21:53:24 PST 2016


On Friday, 16 December 2016 at 10:28:03 UTC, qznc wrote:
> On Thursday, 15 December 2016 at 18:48:22 UTC, Andrei 
> Alexandrescu wrote:
>> https://issues.dlang.org/show_bug.cgi?id=16975
>
> Whenever I think about preconditions and speed, I think that 
> they should actually be put into the caller instead of into the 
> function/callee.

Not only faster, but this is the right thing to do. Failing 
precondition is a caller error, not a callee.

Beside optimization:
  - The error will be reported at the right place.
  - The compilation flags of the caller decide if the contract is 
checked, not the callee.



More information about the Digitalmars-d mailing list