Another idiom I wish were gone from phobos/druntime

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 4 17:07:55 PST 2015


On 2/4/15 4:47 PM, deadalnix wrote:
> 1/ the initial is overly long because the styling is wasteful.
>
> void foo() in {
>    ...
> } body {
>    ...
> }
>
> Is simply one line more than not using contracts.

Would introduce an exception to our brace-on-its-line rule.

I need to take issue with "that code is not using contracts". Using 
assert _is_ using contracts.

> 2/ The semantic is not 100% equivalent (well at least the intended
> semantic) as the in contract should be chosen based on the static type
> while the implementation on the dynamic one. That mean the contract
> should tun in the caller.

Yah, I agree "in" is useful for overridable functions. In fact I'd say 
it's useful _only_ for overridable functions.


Andrei


More information about the Digitalmars-d mailing list