in reply to Re^4: Local for lexicals
in thread Local for lexicals

Maybe this is a repetition of a question already asked--possibly even asked and answered--but having re-read the thread, I cannot see it. So here goes:

{ #outer scope $lamb = lambda ( $x, $y, $z ) => sub { $x + $y } }

This is, in a sense, the crux of my problem—I don't want the values of $x, $y, and $z to leak from the inside out, or vice versa,

What are you trying to achieve that this doesn't?

my( $x, $y, $z ) = ( 1,2,3 ); my $lamb = do{ my( $x, $y, $z ) = ( $x, $y, $z ); lambda ( $x, $y, $z ) => sub { $x + $y } }

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP PCW

Replies are listed 'Best First'.
Re^6: Local for lexicals
by JadeNB (Chaplain) on Aug 12, 2009 at 19:17 UTC
    What are you trying to achieve that this doesn't?
    my( $x, $y, $z ) = ( 1,2,3 ); my $lamb = do{ my( $x, $y, $z ) = ( $x, $y, $z ); lambda ( $x, $y, $z ) => sub { $x + $y } }
    Unfortunately, I don't know quite what this does, so I can't answer! My question (at least, the part of my question that seems to have attracted the most attention) is how to write lambda in such a way that lambda( $x, $y, $z ) => sub { $x + $y } is the same as sub { $_[0] + $_[1] }. As far as I can tell, the code that you've written would be the same as
    my ( $x, $y, $z ) = ( 1, 2, 3 ); lambda ( 1, 2, 3 ) => sub { 1 + 2 }