Part of a series of talk to help you write your first Perl 6 program today. So its basic syntax and concepts of its object orientation and a comparison to the widely used P5 OO system Moose which is similar by no accident.
41. In Perl 5
package Spaceship;
use Moo;
has 'speed' => (
is => 'ro';
isa => sub { die "…"
unless looks_like_number($_[0]);
});
sub stop {
$self = shift;
$self->speed = 0;
}
42. In Perl 5
use MooseX::Declare;
class Spaceship {
has 'speed' => (
is => 'ro';
isa => 'Int';
);
method stop {
$self->speed = 0;
}
}
121. Methods
WHAT short name
WHICH object ID (type)
WHO package, long name in str context
WHERE memory address
HOW
object of meta class
WHEN (reserved for events?)
WHY
(reserved for documentation)
WHENCE autovivification of closures
122. Methods
WHAT short name
WHICH object ID (type)
WHO package, long name in str context
WHERE memory address
HOW
object of meta class
WHEN (reserved for events?)
WHY
(reserved for documentation)
WHENCE autovivification of closures
123. Methods
WHAT short name
WHICH object ID (type)
WHO package, long name in str context
WHERE memory address
HOW
object of meta class
WHEN (reserved for events?)
WHY
(reserved for documentation)
WHENCE autovivification of closures