develooper Front page | perl.perl6.language | Postings from August 2001

Re: explicitly declare closures???

Thread Previous | Thread Next
Dave Mitchell
August 28, 2001 06:51
Re: explicitly declare closures???
Message ID:
Ken Fox <> wrote:
> You really need to learn what a closure is. There's a very nice book
> called "Structure and Interpretation of Computer Programs" that can
> give you a deep understanding. **

Quite possibly I do. Anyway, I've now got the book on order :-)

> You're speaking in Perl implementation terms. I've already told you
> that if Perl acts the way you say it does, then Perl has buggy
> closures. You don't need to explain a bug to know that one exists!

Okay, to humour me for a mo', what should the following 2 examples
output if Perl were doing the "right" thing?

sub pr { print $_[0] || 'undef', "\n" }

{ my $x = 'X'; sub f {        $F = sub {pr $x} }}
f(); $F->();

{ my $y = 'Y'; sub g { pr $y; $G = sub {pr $y} }}
g(); $G->();


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About