Ken Fox [EMAIL PROTECTED] wrote:
We must be very careful not to confuse closure with Perl's
current implementation of closure. You've stumbled onto a bug in
Perl, not discovered a feature of closures. Perl's closures
were horribly buggy until release 5.004. (Thanks Chip!)
Er, no its not a
Dave Mitchell wrote:
The whole point is that closed variables *aren't* 'just local variables'.
The inner $x's in the following 2 lines are vastly different:
sub foo { my $x= ... { $x } }
sub foo { my $x= ... sub { $x } }
You really need to learn what a closure is. There's a
Ken Fox [EMAIL PROTECTED] 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
Dave Mitchell [EMAIL PROTECTED] wrote:
John Porter [EMAIL PROTECTED] wrote:
Dave Mitchell wrote:
I think closures are a lot harder (or at least subtler) than
people think ...
... The scenario you gave seems rather far-fetched to me, in terms
of real-world programming.
Perhaps,
Dave Mitchell [EMAIL PROTECTED] wrote:
John Porter [EMAIL PROTECTED] wrote:
Dave Mitchell wrote:
I think closures are a lot harder (or at least subtler) than
people think ...
... The scenario you gave seems rather far-fetched to me, in terms
of real-world programming.
Perhaps,
Dave Mitchell [EMAIL PROTECTED] wrote:
John Porter [EMAIL PROTECTED] wrote:
Dave Mitchell wrote:
I think closures are a lot harder (or at least subtler) than
people think ...
... The scenario you gave seems rather far-fetched to me, in terms
of real-world programming.
Perhaps,
Paul Johnson [EMAIL PROTECTED] wrote:
Try changing your original example from
sub foo {
to
*foo = sub {
and you'll see that everything works as expected.
add a BEGIN so that instantion happens at the same time that a named
sub would be:
BEGIN { * foo = sub { } }
and the