in reply to Re: How to bring in multimethods
in thread How to bring in multimethods
When I call it with Exporter like this:
package Methods { use strict; use warnings; use feature qw(isa); use Logic::Easy; use Exporter qw(import) no warnings qw(redefine); our @EXPORT_OK = qw(frobnicate); sub frobnicate : Multi(frobnicate) { SIG [$o] where {$o isa 'Foo'}; qq(foo); } sub frobnicate : Multi(frobnicate) { SIG [$o] where {$o isa 'Bar'}; qq(bar); } 1; } __END__
#!/usr/bin/env perl use strict; use warnings; use lib q(.); use Bar; use Foo; use Methods qw(frobnicate); use feature qw(say); my $gizmo = Foo->new(); my $mojo = Bar->new(); # dd $gizmo, $mojo; say frobnicate($_) for ($gizmo, $mojo); __END__
I get:
karl@h3002993:~/src/perl/mmdemo$ ./run.pl Logic::Easy control failed at Methods.pm line 16. at Methods.pm line 16. </p>
The same result with say frobnicate($gizmo);. With say frobnicate($mojo); i get bar.
With the loop and Methods::frobnicate($_) i get the expected result.
«The Crux of the Biscuit is the Apostrophe»
|
|---|