freebsd-ports/devel/p5-Class-Multimethods-Pure/pkg-descr
Cheng-Lung Sung 30906c9a2c Add p5-Class-Multimethods-Pure 0.11, method-ordered multimethod
dispatch.

PR:		ports/100375
Submitted by:	Gea-Suan Lin <gslin at gslin.org>
2006-07-17 01:09:47 +00:00

17 lines
524 B
Text

You can define multimethods with the "multi" declarator:
use Class::Multimethods::Pure;
multi collide => ('Bullet', 'Ship') => sub {
my ($a, $b) = @_; ...
};
multi collide => ('Ship', 'Asteroid') => sub {
my ($a, $b) = @_; ...
};
It is usually wise to put such declarations within a BEGIN block, so
they behave more like Perl treats subs (you can call them without
parentheses and you can use them before you define them).
WWW: http://search.cpan.org/dist/Class-Multimethods-Pure/