# A Perl 6 class
class Point {
has $.x;
has $.y is rw;
method clear () { $.x = 0; $.y = 0; }
}
####
# A Perl 5 class
package Point; {
use Object::InsideOut;
my @x :Field;
my @y :Field('Accessor' => 'y');
sub clear {
my $self = shift;
$x[$$self] = 0;
$y[$$self] = 0;
}
}
##
##
# A Perl 5 class -- take 2
package Point;
{
# same guts as before
}
# still part of package Point outside the braces
# but @x and @y can't be seen from out here
##
##
# A Perl 5 class -- take 3
package Foo; # just for later clarity
{
package Point;
# same guts as before
}
# Back to package Foo out here