Stories
Slash Boxes
Comments

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Tuesday July 07, 2009
06:31 AM

Perl 6 Roles Question

[ #39241 ]

Imagine a PracticalJoke class. It needs a non-lethal explode() from a Spouse role and a timed fuse() from a Bomb role. Unfortunately, each role provides the both methods. With Moose, this is trivial to resolve:

package PracticalJoke;
use Moose;
with 'Bomb'  => { excludes => 'explode' };
    'Spouse' => { excludes => 'fuse' };

How the heck do I do that with Perl 6? No matter how many times I read Synopsis 14, I can't figure out how that would work.

role Bomb {
    method fuse ()    { say '3 .. 2 .. 1 ..' }
    method explode () { say 'Rock falls. Everybody dies!' }
}

role Spouse {
    method fuse ()    { sleep rand(20); say "Now!" }
    method explode () { say 'You worthless piece of junk! Why I should ...' }
}

class PracticalJoke does Bomb does Spouse {
    ???
}

What have I missed?

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Reading the Synopsis and the role conflict spectest [pugscode.org] doesn't suggest anything other than resolving it yourself:

    class PracticalJoke does Bomb does Spouse {
        method fuse() {
            return self.Bomb::fuse();
        }
        method explode() {
            return self.Spouse::explode();
        }
    }

  • Before Moose, Perl6 was the great hope to fix a lot of the ugliness with Perl's OO. Perl 6 was like Perl 5 but more. However with all the community effort going into Moose and related MooseX stuff, I'm concerned that a lot of the great ideas in Perl6 are going to always remain too fair behind. It's starting to seem like Perl6 is like Perl5 but different. I wonder if there's some way to increase the communication between the Moose group and the people doing OO Perl6 stuff. There's a lot of little things
    --
    Waiting on the Road to Eventually, I lost my Place On Line
    • Perl 5 is pluggable, and Moose is a great "external" improvement.

      Perl 6 is (in the realm of object orientation without question) even better and more pluggable than Perl 5, and you wonder that the default isn't is as good isn't as good as Perl 5 with a bunch of the best modules available?

      I think thats an understandable position, but don't forget that Perl 6 leaves room for improvement. It shouldn't be all that hard to write a module that allows additional syntax like

      class Foo does SomeRole :except<metho