D modeling

FeepingCreature feepingcreature at gmail.com
Tue Jul 2 13:52:17 UTC 2019


On Tuesday, 2 July 2019 at 01:21:56 UTC, CheeseWiz wrote:
> 3. Oop contravariance breaks the model logic and mixes 
> dependencies. It is a non-issue in modeling. In D it requires 
> us to cast everywhere. This is the main issue. You can see the 
> issue at work using IsItTasty functions. It's simple, 
> Contravariance prevents us staying with the derived model, we 
> have to use the base model(for return types, same applies to 
> arguments with covariance). But when we are in a derived model 
> we are in it, we are using everything in the derived model that 
> belongs to it(and behind them is the base model, but we do not 
> directly refer to the base model), at least that would be the 
> plan.
>

Quite the opposite! Covariance actually saves you.

struct ModelB
{	
     interface iAnimal : ModelA.iAnimal
     {
         override iFood LikesWhichFood();
     }


More information about the Digitalmars-d mailing list