in reply to Re: Toggling between two values
in thread Toggling between two values
Your "closure" sub isn't actually a closure; to be a closure it would not only have to access outside lexicals (like yours does), but also be anonymous.No, "closure" and "named" are orthogonal properties. In the following, the named subroutine gimme is a closure:
Yes, there's some Perl literature that mixes up the two concepts of anonymous and closure because they are often correlated, but really they are separate properties.BEGIN { my $number = 0; sub gimme { ++$number; } }
Although I do feel a bit weird correcting chip on this point. {grin}
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: •Re: Re: Toggling between two values
by chip (Curate) on May 05, 2003 at 17:38 UTC | |
by merlyn (Sage) on May 05, 2003 at 17:46 UTC | |
by chip (Curate) on May 05, 2003 at 18:02 UTC | |
by jdporter (Paladin) on May 05, 2003 at 20:03 UTC | |
by chip (Curate) on May 05, 2003 at 20:21 UTC | |
by jdporter (Paladin) on May 06, 2003 at 12:46 UTC | |
by chip (Curate) on May 07, 2003 at 21:08 UTC |