Skip Menu |

This queue is for tickets about the Acme-Lambda CPAN distribution.

Report information
The Basics
Id: 26890
Status: resolved
Priority: 0/
Queue: Acme-Lambda

People
Owner: nelhage [...] mit.edu
Requestors: peter [...] makholm.net
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.01
Fixed in: (no value)



Subject: Acme::Lambda doesn't work.
Acme::Lambda doesn't seems to work as documented. The following script (almost cut and pasted from the documentation) is expected to print '16' but actually prints '0': makholm@makholm:~$ cat > lambda.pl #!/usr/bin/perl -l use Acme::Lambda; my $square = lambda { $_ * $_ }; print $square->(4); makholm@makholm:~$ perl lambda.pl 0 makholm@makholm:~$ Changing the lambda function so it says sub lambda { my $sub = shift; return sub { local $_ = shift; $sub->() }; } fixes the problem.
Subject: lambda.patch
--- Lambda.pm 2007-02-23 03:00:02.000000000 +0100 +++ LambdaBis.pm 2007-05-02 14:52:06.159328003 +0200 @@ -1,4 +1,4 @@ -package Acme::Lambda; +package Acme::LambdaBis; use warnings; use strict; @@ -11,7 +11,7 @@ sub lambda(&) { my $sub = shift; - return $sub; + return sub { local $_ = shift; $sub->() }; } *λ = \λ
Thanks for the bug report! I've uploaded 0.02, which fixes the problem (I modified your patch and amended the documentation slightly so that accessing more than one argument through @_ still works)