Garrett asked:
> Any word from on high whether subroutine signatures will apply to
> methods in Perl6?
Well, I hardly qualify as "on high" ("on *a* high" perhaps?) but I can
definitely say this: They will and they won't. ;-)
At compile-time, signatures can only be honoured if the compiler can
know about them. That will almost certainly require that the variable
holding the object reference be typed into an "interface" class (a la
http://dev.perl.org/rfc/265.html), and that the variables passed as
arguments be typed as well.
For example:
class Canine is interface;
sub bark_at(Canine $self, Feline $provocation) {...}
class Dog;
use base 'Canine';
sub bark_at(Canine $self, Feline $provocation) {...}
class Feline;
class Cat;
use base 'Feline';
module main;
my Dog $spot = Dog.new;
my $rover = Dog.new;
my Feline $fluffy = Cat.new;
my $felix; = Cat.new;
...
$spot.bark_at($fluffy); # method sig checked at compile-time
$rover.bark_at($fluffy); # method sig checked at run-time
# (type of $rover not known till then)
$spot.bark_at($felix); # method sig checked at compile-time
# (type of $felix not known till then)
$rover.bark_at($felix); # method sig checked at run-time
# (type of both not known till then)
One might also envisage a C<use strict 'typing'> pragma to require that
all lexicals be typed.
Damian