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 ]

schwern (1528)

schwern
  (email not shown publicly)
http://schwern.net/
AOL IM: MichaelSchwern (Add Buddy, Send Message)
Jabber: schwern@gmail.com

Schwern can destroy CPAN at his whim.

Journal of schwern (1528)

Saturday September 27, 2008
04:22 PM

Method::Signatures 0.11, now with attribute support

[ #37555 ]

With mst's help, Method::Signatures can now handle attributes!

method echo($arg) : Whatever {
    return $arg;
}

There are some edge cases which will screw up the parsing, see below.

In other news, mst suggested this new syntax.

method $foo($arg) {
    return $arg;
}

be equivalent to:

*$foo = method($arg) {
    return $arg;
}

which is clever and cuts out a lot of the "no strict" dance. Thoughts?

For attribute parsing, currently it just looks for the last { on the
"line" but the definition of "line" is hazy.

So while this works:

method echo($arg) : Whatever
{
    return $arg;
}

And so does this:

method echo($arg) : Whatever({ foo => 23 }) {
    return $arg;
}

This does not:

method echo($arg) : Whatever { return {} }

I need to work on a better parser. Fortunately there might be a way to do with without having to completely parse Perl.

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.
  • This is quite a nice language upgrade!
    • Thanks. The plan is to prototype it out in Method::Signatures and then implement it in 5.12.

      • You mean, there are already plans to fold the Devel::Declare magic into 5.12. At least supporting subroutine signatures would be great.

        • I mean put in a real method keyword and function signatures straight into the language. No screwing around with tokenizer hacks.

          And by "the plan" I mean "my plan". rgs might have something to say about it. :)

          • I frankly get more excited about this kind of evolution that the full Perl 6 upgrade, which I expect will take years longer before I can use it for real work with reasonable performance.

            Thanks for the clarification!