How do I use in contract with interface?

Steven Schveighoffer schveiguy at yahoo.com
Wed Nov 15 15:33:50 UTC 2017


On 11/15/17 10:14 AM, Jonathan M Davis wrote:

>  So, it's pointless to put an in contract on an
> interface's function unless you're trying to ensure that nothing in derived
> contracts is any stricter than that contract, which in practice likely means
> that it's pointless to put an in contract on an interface function.
> 

Just tested this, and actually, if you put no contract on an interface 
function, it negates any contracts on the implementing functions. So 
there definitely is a use for the in contract on an interface -- if you 
plan on defining contracts on implementing types.

I'm curious why the absence of an in contract disables all other in 
contracts. I would have expected it to simply have no effect.

-Steve


More information about the Digitalmars-d-learn mailing list