Method::Signatures 0.11, now with attribute support

schwern on 2008-09-27T21:22:03

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.


thanks

markjugg on 2008-09-28T01:39:36

This is quite a nice language upgrade!

Re:thanks

schwern on 2008-09-29T13:42:43

Thanks. The plan is to prototype it out in Method::Signatures and then implement it in 5.12.

Re: Devel::Declare in 5.12

markjugg on 2008-09-29T18:47:13

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

Re: Devel::Declare in 5.12

schwern on 2008-09-30T02:29:40

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. :)

Re: Devel::Declare in 5.12

markjugg on 2008-09-30T16:12:59

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!