At 10:51 AM 5/31/01 -0700, Randal L. Schwartz wrote:
>There's a school of (mis-)thought that "a coderef is a closure".  I
>don't know how that got started, but it's wrong.  A closure is created
>only when lexical variables go out of scope.  So a coderef without
>external references is *not* a closure, and a named subroutine *can*
>be a closure.

Exactly.  To quote Damian Conway's "Object-Oriented Programming with Perl", 
p. 56:

"To hear some people talking about closures, you'd think they were 
discussing quantum physics, brain surgery, or VCR programming.  In reality, 
the idea of closures is incredibly simple and obvious, once the technical 
jargon has been stripped from it.

"In Perl, a closure is just a subroutine that refers to one or more lexical 
variables declared outside the subroutine itself."

Perhaps we've exposed the beginners to enough of the seamy underbelly of 
Perl experts disagreeing among themselves, assuming any are still following 
this thread...

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com

Reply via email to