Another idiom I wish were gone from phobos/druntime

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 5 02:25:31 PST 2015


On Thursday, February 05, 2015 21:01:19 Daniel Murphy via Digitalmars-d wrote:
> "Jonathan M Davis via Digitalmars-d"  wrote in message
> news:mailman.6014.1423124756.9932.digitalmars-d at puremagic.com...
> > The real killer feature would be if we could figure out how to make it so
> > that contracts are controlled by the call site instead of being compiled
> > out
> > when the function itself is compiled without assertions enabled. But I
> > have
> > no idea how we could do that given that we can have function prototypes
> > without the actual source code being visible at the call site.
>
> It's possible, it's just not easy.  Contracts would not be called if the
> prototype didn't have them, so di files would likely have the contracts
> retained.

Well, if we can change it so that whether the contracts are run or not is
determined by the caller and not the callee, then using them would
definitely be worth it. But as long as that's not the case, it's not at all
worth the visual noise IMHO to use in and out blocks IMHO. And if/once we
change it so that whether the in and out blocks are run is determined by the
caller, the visual noise will still be annoying enough to make it so that I
won't be in a hurry to add them unless they're adding real value rather than
just some additional, nice-to-have checks.

- Jonathan M Davis



More information about the Digitalmars-d mailing list