Method::Signatures, now with 581% more debugger!

schwern on 2008-10-28T08:33:54

I'm happy to announce that with the latest release of Method::Signatures the last major bugs have been fixed. This is through no fault of my own, but Florian and Rhesa's latest work on Devel::Declare.

Method::Signatures now works with the debugger. This was the big one keeping it from any hope of being taken seriously for production use. Apparently Florian found some "this should never have worked" code in Devel::Declare that was causing the problem.

The debugger sees what's in the source file, not the generated code, which is good. But it has to step through each of the hidden statements, which is not so good. Suggestions on what to do about that welcome.

The other issue is now method declarations happen at compile-time, just like regular subroutines. This is thanks to a fresh Devel::BeginLift patch. While not a big deal for production, it was one of those "I have no idea how to fix this" problems.

All the really terrifying guts which were formally cut & pasted & hacked from a Devel::Declare test file have now been packed back into Devel::Declare and maintained by Rhesa. This lets all the fledgling signature modules share their fixes and lets others experiment.

[If it hasn't hit CPAN yet, get it from github]

There's one major technical issue left. Data::Alias, which provides the fast guts for "is alias" and "\@foo", doesn't work on Windows before 5.10. Unless that's fixed Method::Signatures is going to be a troublesome dependency for Windows users. One option is if Data::Alias doesn't work to fall back to Data::Bind, which does work but its a lot slower. I already do that with Readonly::XS, its an optional dependency because it has a silly test bug in 5.10.

So, let me know if anyone is crazy enough to be using this in production. And please keep sending test patches (or just fork it on github and send me a pull request), especially for signatures that shouldn't work but don't throw a sensible error.

PS If Method::Signatures interests you, but you want something a little simpler and with less dependencies, try Method::Signatures::Simple. Same backend as Method::Signatures, but only Devel::Declare as a dependency.


great

markjugg on 2008-10-28T15:43:27

Awesome. Thanks for the work.

Win32

chorny on 2008-10-28T19:33:33

Latest version of Devel::Declare that works on 5.8.8 on Windows is 0.002000, so current issue is Devel::Declare, not Data::Alias.

P.S. Data::Alias will work on 5.8.9/Win32.

Re:Win32

schwern on 2008-10-28T21:39:26

Yeah, there's something wrong with the linking against B::Hook::OP::Check.
Ticket here.

Lite vs. Simple

srezic on 2008-10-31T22:30:47

Shouldn't it be called Method::Signatures::Lite?

Re:Lite vs. Simple

schwern on 2008-10-31T23:31:53

I guess that depends on how you define "Lite" and "Simple" which are pretty ambiguous. The fad now-days seems to be towards "Simple" which usually means "simpler interface, but less features".

It's not as ambitious as Method::Signatures, and it's missing a lot of features. This greatly simplifies the code, since it doesn't have to do any fancy parsing of the prototype. It makes it much more predictable as to what the result will be, and can reach stability faster (pending Devel::Declare stability). It just takes the prototype and puts it on the LHS of an @_ assignment.

use Method::Signatures::Simple;
 
method foo($foo, $bar) {
    ...
}

becomes

sub foo {
    my $self = shift;
    my($foo, $bar) = @_;
 
    ...
}

and that's that. It's an 80/20 solution.