in reply to Re^9: Unclear about 'our' (updated)
in thread Unclear about 'our'
And I think the example I showed proves my point, that the var from the outer scope is bound to the sub.
> In the context of Perl, perlglossary does say that a closure is "An anonymous subroutine that,
One of my biggest problems with the perldocs is that it's a collection² from different authors and sources.
I like to quote perlglossary myself, because it's from Larry himself. But it's from the appendix of one of his books. And he sometimes values easy wording with puns over being consistent. (update: phrase reworded)
But the implementation of lexical closures is the same for all subs.
I envy other languages which have a more formal approach to language definition. The ECMA process dragged JS out of the mud. And those PEP discussions in Python look³ decent.
AFAIK was closure invented in the context of Lisp, hence well° defined there.
°) another extreme is PHP where "closure" always means (meant?) "anonymous sub", no matter if there are any vars involved. (I think they fixed the docs in the meantime, but this should prove my point that docs can't always reinvent fixed terminology)
²) inconsistent
³) "at least look" (I can only judge by the optics here)
Cheers Rolf
(addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
Wikisyntax for the Monastery
|
|---|