Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re^3: Local for lexicalsby ikegami (Patriarch) |
on Aug 12, 2009 at 21:00 UTC ( [id://788051]=note: print w/replies, xml ) | Need Help?? |
So what you really want are anon subs with named arguments. Have you looked at
Unfortunately, the following doesn't work
I also tried Sub::Signatures and Perl6::Subs. Both accept anonymous subs with named parameters. Neither pass the alias test. Maybe one of them can be fixed. Maybe it works with one of the other modules. Update: To spend the least amount of effort, your best bet is to fork signatures. It hooks itself into the parser to change
into
By changing what gets injected (my (...) = @_;) to something like the following, you can achieve aliasing (which also fixes tied vars):
It might be best to use copying semantics by default, while adding a mechanism to specify aliasing ("is rw"?). That would allow you to extend signatures instead of replacing it.
In Section
Seekers of Perl Wisdom
|
|