On Sun, May 26, 2013 at 03:40:02PM +0000, Henrik Grubbstr�m (Lysator) @ Pike (-) developers forum wrote:
- When the variants have different modifiers (protected, private, etc).
it could be useful to make public and private versions of a function. if the call comes from outside, then less variants are available to choose from.
- When there's a function without the variant keyword.
that should be an error if we don't want to loose the benefit of an error telling us that a function was defined twice. otherwise, why even use a variant keyword at all.
- When overriding X from an inherit with a variant function.
- A non-variant function.
- A variant function with a new definition with the same type.
- A variant function with a new definition with a different type.
if the overriding function is not variant then it should just mask all variants. likewise if it is variant but the inherit is not.
this is the same case as the missing variant keyword above: unless all functions involved are variant the behaviour ought to be as if none are variant, which above leads to an error, and here it leads to overriding.
while i can see a theoretical use to make a variant of inherited functions, i think it's better to keep things simple.
what about for example the case that a non-disjunkt variant function is added in a newer version of the parent class? suddenly my functions are no longer called.
- Should the previous definition be accessible in any of the above cases, or only if there's an explicit trampoline?
what is an explicit trampoline in this context? (what is the difference to an implicit trampoline?)
- Multiple inherits of variant functions.
- With the same types.
- With different types.
the behaviour of one parent should not depend on other parents i think. so variants should have no effect here.
for disjunct types it could be interesting to choose the matching one instead of failing. however i'd see this as a seperate feature because i think it would be beneficial to make this work without needing the variant keyword.
if that is a bad idea without a variant keyword, then it is probably also a bad idea with a variant keyword because i think definitions in the parents should not influence the resolution order in the child. (unless it is something like final (or private, but private is equivalent to removing the function from the parent))
greetings, martin.