method hiding (or not) in derived classes

2008-04-19 Thread John M. Dlugosz
Perl 6 has a concept of a "candidate list".  The candidate list are those that 
could handle the call, typically inherited methods and multi variations.  

It seems that multi variations, at least with respect to the semicolon 
parameters, compare the actual type and drop out of the list if any don't match.

What about ordinary methods (and ordinary parameters of multis)?  Does the 
candidate list hold every method name that matches, or does it do simpler 
parameter matching based on number of arguments, required named arguments, etc.?

If that is the case, then a derived method might not hide a base class method 
if the parameter list is seriously incompatible.  More interestingly, 
left-to-right ordering of multiply-inherited base classes will be checked for 
applicability rather than  arbitrarily taking the leftmost.

--John


Critisizms on postcircumfix:<( )>

2008-04-19 Thread John M. Dlugosz
I think the idea of "The expected semantics of &.() is that of a type 
coercion..." confuses the notion of function call and conversion.  If anything 
other than a Code object has one, it is acting as a functor, or function-like 
object.  The meaning of Dog(args) is seemingly a class method anyway, not a 
normal instance method.  It was elsewhere said that the type name as a listop 
indicates conversion.  I think that should be taken to mean that the compiler 
uses whatever form of conversion function is available.  I think $obj(args) 
should mean whatever I want it to mean, like any other function.  An (untyped) 
variable $obj can call &.() with the same syntax it does with an object of type 
Code, no problem.

We already use the method .new to mean "create one of these using these 
arguments".  Sometimes that =is= logically a conversion.  In C++ that is 
assumed by default.  So why make a different function with different syntax?

I propose that any method that is logically a "conversion" can be marked with a 
property to say so, and the implementation will draw upon those when asked to 
perform a conversion.

 our C multi method ^new (D $oldguy) is conversion { ... }

(er, the default inherited .new doesn't prevent me from making a multi new in 
my class, right?)

Now I can say  $c = C.new($d);  and if I ever say $c = C $d; or my C $c = $d;  
it will know that this is the function to call.

--John