Another idiom I wish were gone from phobos/druntime

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 5 04:48:57 PST 2015


On Thursday, February 05, 2015 12:34:34 Kagamin via Digitalmars-d wrote:
> On Thursday, 5 February 2015 at 09:43:53 UTC, Jonathan M Davis
> wrote:
> > There is no such difference in the current implementation.
> > assertions inside
> > of in and out blocks are no different from assertions inside of
> > the
> > functions themselves with regards to when they are compiled in
> > or not.
>
> Good point. One problem is that base asserts throw exceptions on
> loosening contract on overriding method. Asserts in contracts can
> behave differently, e.g. derived contract can call base contract
> with a parameter asking to not throw on failure.

Virtual functions is the _one_ place where using in and out blocks actually
makes a difference, and at the moment, it's the only reason that it makes
sense for them to exist in the language IMHO - though that definitely
changes if we're able to make it so that whether the contracts are run is
determined by the caller rather than whoever compiled the function itself.

- Jonathan M Davis



More information about the Digitalmars-d mailing list