Eden: Deviamos criar a "Moose Advocate" Você já foi falar de Roles... deixa o novato pesquisar um pouco!!! Mas, muito bom seu artigo. Nota 10.
abs. On Fri, 2012-09-07 at 03:07 -0300, Eden Cardim wrote: > >>>>> "thiagoglauco" == thiagoglauco <[email protected]> writes: > > thiagoglauco> Com Moose seu pacote Shapes ficaria assim: > thiagoglauco> package Shapes; > thiagoglauco> use Moose; > > thiagoglauco> has x => ( isa => "Int", > thiagoglauco> reader => "get_x", > thiagoglauco> writer => "set_x" ); > > thiagoglauco> has y => ( isa => "Int", > thiagoglauco> reader => "get_y", > thiagoglauco> writer => "set_y" ); > > thiagoglauco> sub moveTo { > > thiagoglauco> my ($self, $deltax, $deltay) = @_; > thiagoglauco> $self->set_x( $self->get_x + $deltax ); > thiagoglauco> $self->set_y( $self->get_y + $deltay ); > > thiagoglauco> } > > Escrevi um artigo explicando uma implementação alternativa disso: > http://bit.ly/OeMRAe > =begin disclaimer Sao Paulo Perl Mongers: http://sao-paulo.pm.org/ SaoPaulo-pm mailing list: [email protected] L<http://mail.pm.org/mailman/listinfo/saopaulo-pm> =end disclaimer
