On Wednesday, 4 February 2015 17:46:58 UTC, Christoph Ortner wrote:
>
> On Wednesday, 4 February 2015 16:59:14 UTC, Avik Sengupta wrote:
>
>> I don't understand your domain of course, but the way I'd do this would
>>> be a slight variant of OPTION 1
>>>
>>> get_forces(a::AbstractAtom) = error("All AbstractAtom subtypes should
>>> implement get_forces")
>>> get_forces(a::Atom) = get_forces(a.calc)
>>>
>>>
>> this is indeed what I've done at the moment. Good to hear that this is
>> not completely idiotic.
>>
>
> Ok, actually this is slightly different - so I don't understand why this
> would help? Is it just the fact that not all implementations of
> AbstractAtoms need to have a field `calc`?
>
>
Well, yes, that is one reason, but that may or may not be true in your
case. Mainly, the idea is to ensure that if some subtype fails to
implement its get_forces method, then the error message will be explicit
about what should be fixed.
> thought one problem with not having "proper" inheritance is that this
doesn't really help?
I meant more about commonality of behaviour.