Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

perigrin (3495)

perigrin
  {chris} {at} {prather.org}
http://chris.prather.org/
AOL IM: marceusx (Add Buddy, Send Message)

After Middle School Chris bounced through various high schools around the state of Florida for a bit. He ended up getting a BA (in English) from the University of Central Florida at about the time others his age were getting their MAs. His (now) wife, their child, and he went to Europe for a bit (there was a programming job in Scotland) and came back unemployed where upon he got offered a job in St. Paul. He moved on from that job after a few years to one where he was paid to do the things he previously did as a hobby. That sounds much more exciting than it really was. Really his life is based on two kids, two cats, and a bunny.

Journal of perigrin (3495)

Friday April 03, 2009
07:44 PM

What a Moose programmer would think...

[ #38749 ]

So I’ve been integrating Ash Berlin’s work on making MooseX::POE work with MooseX::Declare. One of the things I came across was that the method keyword didn’t work as I expected.

I figured that something like:

class Counter { use MooseX::POE; method START { $self->yield('increment_counter'); } event 'counter' => method { $self->counter($self->counter + 1); }; }

would DWIM. But currently a method without a parameter list is slightly undefined. It happens to default to the same as an empty parameter list (ie method ($self:) { ... }) but Florian and Ash both agreed that perhaps that wasn’t the best choice. To my mind I think that the right choice is that method { ... } should be the equivlent of method ($self, @_) { ... }. That is it should alias the invocant and pass through the rest of the args as a slurpy array.

Then tonight I was reading the Perl 6 Design Minutes for 26 March 2009 and found the following:

Patrick:

  • if you have a method declared without a parameter list, does it get @_ like a sub, or no parameters?

Larry:

  • I've been thinking it comes in the same way Perl 5 does it
  • hadn't bothered to try to think about it the other way

Patrick:

  • Rakudo assumes @_

Larry:

  • but it leaves out the invocant
  • that's the difference
  • I haven't decided
  • it's further from what a Perl 5 programmer might expect
  • but it might be more useful

I think it’s closer to what a Perl 5 Moose programmer expects than Larry thinks.

UPDATED: upon talking with Ash I've clarified what I meant to say. Never blog while tired.

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.