Trey Harris asked:
> Another one...
>
> class Foo is Bar;
>
> method a {
> setup();
> }
>
> 1;
> # EOF
>
> (Is the 1 still required?
No.
> I think I heard Damian say it was going away.)
Yes.
> The question is, is this valid, if Bar defines a sub/static method
> 'setup'?
If C<setup> is a C<sub>, yes.
But if it is a C<method>, you'd need:
method a {
.setup();
}
> Is my instict right that 'sub' in a class is a 'class/static method' in
> the terminology of other languages?
Not really. C<sub> denotes a helper subroutine.
Methods should always declared with the declarator C<method>.
> I'm wondering if the oddly redundant syntax we have now of:
>
> package Foo;
> use Bar;
> our @ISA = qw(Bar);
> sub a {
> my $self = shift;
> Bar::setup();
> }
> 1;
>
> Can go away.
Yep. In Perl 6 that would be:
class Foo is Bar {
method a {
Bar::setup();
}
}
or, if C<Bar::setup> is a *method*, rather than a subroutine:
class Foo is Bar {
method a ($self:) {
$self.setup();
}
}
or, because the invocant is implicitly the topic in a method, just:
class Foo is Bar {
method a {
.setup();
}
}
Damian