How do I use in contract with interface?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Wed Nov 15 17:09:42 UTC 2017


On Wednesday, November 15, 2017 11:21:16 Steven Schveighoffer via 
Digitalmars-d-learn wrote:
> On 11/15/17 11:19 AM, Steven Schveighoffer wrote:
> > But what doesn't make a lot of sense is the inability to declare the
> > inheritance of the current in-contract situation. If you have a complex
> > contract, then having to repeat it on every class seems unnecessarily
> > verbose. It's very easy to just say `in {}` if you now can accept all
> > possible parameters. The opposite is not as easy.
>
> I would bet money that at least 50% of the time contract inheritance is
> used, people use base contracts to mean THE contract, and don't put
> contracts on derived functions, and they don't even realize it.

I expect so. When the issue comes up, I frequently have to either think it
through or look up the rules if I want to remember what they are. But
honestly, I've given up on using contracts in general, and I rarely use
classes, so it's not something that I usually think about.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list