For Programmers: Free Programming Magazines  


Home > Archive > Functional > September 2006 > Re: Nice historical explanation of when and why term "closure" came









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Nice historical explanation of when and why term "closure" came
Marcin 'Qrczak' Kowalczyk

2006-09-23, 7:00 pm

"Dr.Ruud" <rvtol+news@isolution.nl> writes:

>
> No, it doesn't do just that. my() does approximately what you describe.


No, 'my' introduces a new lexically scoped variable.

$x = 1;
sub f {print "$x\n"}
sub g {my $x = 2; f();}
g();
# result: 1
# (f and g operate on different $x variables)

$x = 1;
sub f {print "$x\n"}
sub g {local $x = 2; f();}
g();
# result: 2
# (f and g operate on the same $x variable)

--
__("< Marcin Kowalczyk
\__/ qrczak@knm.org.pl
^^ http://qrnik.knm.org.pl/~qrczak/
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com