D modeling
Bert
Bert at gmail.com
Wed Jul 3 13:34:38 UTC 2019
On Wednesday, 3 July 2019 at 04:58:00 UTC, Jesse Phillips wrote:
> On Tuesday, 2 July 2019 at 18:27:32 UTC, CheeseWiz wrote:
>>
>> The OP contains a working example.
>
> I don't want to pull all the pieces together.
There are no pieces to put together. It is just a direct copy and
paste. I pasted directly the source code in to the editor... you
have to do is find the first place(which starts with import) and
scroll do the last line(which is the last } of main). You are
making it far more difficult than it is.
The only difference is to get it truly working you have to add 2
lines of code to add the contravariance.
> Meta programing wouldn't likely help, there are too many rules
> about how your interface and inheritance needs to combine with
> the parent model that any meta programming would hide the
> intent.
Maybe, maybe not. There are not too many rules though. It's
simply providing the right overrides and such
> I still don't believe interfaces are needed, nor your example
> of multiple inheritance.
Interfaces are required because D does not support MI of classes.
You will not be able to substitute one model for the other
without inheritance. It's required.
Any any object in the derived model HAS TO derive from the base
model and the parent in the derived model. That is the whole
point. That is multiple inheritance. It can't be done any other
way, but D only lets one inherent multiply using interfaces.
You won't be able to get around that if this is going to be done
using oop.
Now, maybe one can hack things and not use inheritance between
models and then force some type of substitution scheme that
works... but that is for someone else to figure out.
Everything actually works out in D, it's just verbose and
cumbersome and for complex models it is error prone. Hence the
only thing to do is find a better way to deal with it.
More information about the Digitalmars-d
mailing list