interfaces and contracts - new pattern

Adam D. Ruppe destructionator at
Tue Dec 3 02:57:13 UTC 2019

On Monday, 2 December 2019 at 22:31:08 UTC, Ola Fosheim Grøstad 
> Interesting, could be useful, but now you have to remember to 
> add "in(false)".

Yeah, it is kinda tempting to propose a language change, where an 
override method does this by default if nothing else is 
specified. I think it would probably usually be the right thing 
to do, and then you'd opt into extending it all the way by doing 
`in(true)` instead.

> I wonder if this could somehow be wrapped up in a clean way 
> using meta-programming so you always get the "in(false)"?

I don't think so, contracts are invisible to reflection right now 
(unless there's a trick I don't know). Maybe a language change is 
warranted though, I don't really know, especially since this 
thing is possible today.

More information about the Digitalmars-d-announce mailing list