Talk:Catcall Test Proposal
--Colin-adams 00:09, 6 November 2007 (PST): Can you give an example of when using the variant
keyword makes sense?
As for the frozen
keyword, doesn't this break the open/closed principle yet again (I know the example shows an attribute, but the wording suggests a routine could also be marked with a frozen type - does this limit redeclaration)?
What is supposed to happen in the multiple constraint case (if the compiler didn't have a limitation)?
- --Schoelle 03:26, 6 November 2007 (PST): The
variant
keyword is nearly the same as the wildcard types introduced in Java. The only difference is the use of a global analysis (i.e. non-modular) to check certain corner cases that are valid although generics are used in the arguments.
- --manus 11:53, 6 November 2007 (PST):
- The
variant
keyword has to be used whenever you want to preserve today's generic conformance rules. For example assigning aLIST [STRING]
to aLIST [ANY]
is possible today, but with the new rule, only if you declare it asLIST [variant ANY]
. - The
frozen
keyword is not preventing you from redefining a feature, just its signature. So if it breaks the open/closed prinicple, then it just does it very slightly. I would say it is a small price to pay for not having catcalls. - For the multiple constraint case, if the descendant type base class is
class A [G -> {B,C}]
I need to define a type that matches the constraint and being a descendant type. If there are no classes in the universe that inherits from both B and C, such a type cannot be constructed and thus the compiler limitation which will report a potential catcall. Possibly, we could find all the classes that are matching the constraint and use them as base types. For the moment we haven't done it, because it is still experimental and there is little code with multiple constraint.
- The
--Clemahieu 21:51, 6 November 2007 (PST) I forgot where it was stated but it was something to the effect of "If a language isn't type safe in all instances, it's not really type safe"
Maybe we can eventually solve all catcall issues but covariant redefinition seems like it's taking a lot of resources to try and make work safely.
Didn't someone state that most covariant problems can be solved type safely with generics? Honestly that's what I use instead of covariance.