On Mon Oct 13 14:24:15 2014, AMBS wrote:
Show quoted text> Hello
>
> Currently, lambda is (mostly) an ACME module.
>
> It would be great to make a little more powerful:
>
>
> my $code = λ $a { print "-- $a --"; };
>
> $code->("foo");
>
> That is, use Devel::Declare to obtain a list of variables, and make
> them act as a signature for the anonymous sub.
>
> I am planning this for so much time, but I can't find the time to
> learn Devel::Declare :-)
>
> Cheers :-)
You can do something very much like that by wrapping Function::Parameters:
package lambda;
use strict; use warnings;
use utf8;
use Function::Parameters ();
sub import {
utf8->import;
Function::Parameters->import({
'λ' => {
defaults => 'function_strict',
name => 'prohibited',
},
});
}
sub unimport {
Function::Parameters->unimport('λ');
}
'ok'
__END__
This is all untested, but it should give you syntax like
my $code = λ ($x) { "-- $x --" };