Paul Johnson <paul@pjcj.net> wrote: > Actually, foo() is not a closure. A closure is an anonymous subroutine > and foo() clearly has a name. Damain's definition of a closure includes named subs: "In Perl, a closure is just a subroutine that refers to one or more lexical variables declared outside the subroutine itself" - OO perl, p 56. > Now, if you were proposing that named subroutines should behave like > closures in this regard, which is what Piers and probably most others > were expecting, I suspect that you would probably get broad agreement. I'm not sure I understand this bit - named subs are really no different from anon subs in respect to closures, except that named subs get instantianted once - at compile time, and anon subs may get instantiated multiple times, thus creating multiple private copies of the outer lexicals. But once you throw in BEGIN and eval, the distinction starts to blur. Dave MThread Previous | Thread Next