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

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.
  • I have a little module that does exactly that for a little while now and didn't think anyone else was that crazy :)

    I played the game even a bit more in the last weeks:

        sub foo :Method( Int $foo, Object $bar! ) {
                self->baz();
                print class, ': ', args->foo;
        }

    Called via:

        $object->foo( foo => 23, bar => $bar_obj );

    "args" returns just a container object, that uses autoload to simulate accessors. That's just to capture typos. It's mostly following the Perl 6 signature idea (at least the current one).

    One problem is that it just can do positional or named arguments, not mixed:

        sub snafu :PosMethod( $foo, $bar ) {
              print args->foo, args->bar;
        } ...
        $object->snafu( 1, 2 );

    Thanks to the Alias module it's also possible to do a :Method( Int $foo is rw ) and use the args call to change the original value. Everything else is just a copy, of course. Haven't gotten Readonly right til now.
    --
    Ordinary morality is for ordinary people. -- Aleister Crowley
    • "args" returns just a container object, that uses autoload to simulate accessors. That's just to capture typos. It's mostly following the Perl 6 signature idea (at least the current one).

      Hmmm, it may pair nicely with Moose [cpan.org]: although the latter claims not to be a Perl 6 implementation in Perl 5, it is admittedly heavily inspired by Perl 6 itself, and to some extent imports Perl 6 semantics, with special emphasis on OO features, in Perl 5. Also, it seems that unlike e.g. v6 [cpan.org], it is much less experimental a

      --
      -- # This prints: Just another Perl hacker, seek DATA,15,0 and print q... ; __END__