Another idiom I wish were gone from phobos/druntime
via Digitalmars-d
digitalmars-d at puremagic.com
Sun Feb 8 03:30:22 PST 2015
On Thursday, 5 February 2015 at 00:37:31 UTC, Adam D. Ruppe wrote:
> On Thursday, 5 February 2015 at 00:35:50 UTC, bearophile wrote:
>> Contracts can be read by tools, and they are part of the
>> function signature. Contracts should be encouraged and
>> increased, not discouraged.
>
>
> I agree. Moreover, if the assert fails in the contract, in
> theory, we can point the error at the user's code. An assert
> inside the function is the function's responsibility. An assert
> in an in contract is the caller's responsibility. They're
> semantically different (even if dmd treats them the same way)
FWIW (only reading this discussion now, sorry if it has already
been stated by someone else), this was also talked about at the
Berlin meeting, with the same conclusion. IIRC someone was
disappointed that failure on the caller's side to pass correct
parameters to a library with contracts caused AssertErrors to be
thrown inside the callee, making it seem it was the library's
fault.
More information about the Digitalmars-d
mailing list