Inheritance and in-contracts
Joseph Rushton Wakeling via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Dec 5 15:26:47 PST 2014
On 05/12/14 23:45, Ali Çehreli via Digitalmars-d-learn wrote:
> This is a known problem with contract inheritance. The following bug report
> mentions the ugly hack of defining assert(0) as the derived's 'in' contract:
>
> https://issues.dlang.org/show_bug.cgi?id=6856
Thanks for the clarification. This is a not-nice situation; FWIW I would second
Don's proposal that the absence of an explicit in-contract on the derived-class
method ought to indicate inheritance of the base contract.
I guess the assert(false) method will do, but I find it as ugly as you do :-(
One further annoyance, pointed out to me by a colleague earlier today: given
that base and derived in-contracts basically come down to,
try
{
Base.in()
}
catch (Throwable)
{
Derived.in()
}
... aren't there some nasty consequences here for memory allocation and the
generation of garbage?
More information about the Digitalmars-d-learn
mailing list