All package variables can be accessed everywhere. As I said
> > This means that package vars can be manipulated outside the sub.
> your example of a global variable uses our, which creates a lexically-scoped variable.
Now this is indeed "irrelevant". They create a lexical alias to a package var.
They are still globally accessible via full-qualified name.
> And did you read the page?
I even cited the original sources.
... my original question wasn't answered, if "a function using global variables (which are "non local") is a closure"
Given that the original sources talk about binding "free variables" which are "bound" I tend to say "kind of". They are bound in the Perl's Op-Tree to their symbol table entry.
But a (the?) central idea of closures is that of encapsulation and protection of those variables from external manipulations and other side effects. And this is not given with with package variables.
A way out of this conundrum is to realize that Perl is not Lisp, and that "Closure" in Perl's context is a short for "lexical closure".
Let's have a look what Larry says in Perl Glossary
But this definition is certainly stressing the "lexical" character of closures, with variables which survive even out-of-scope.
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
In reply to Re^7: Yet Another Program on Closures ~ Steven Lembark ~ TPRC 2025 - YouTube
by LanX
in thread Yet Another Program on Closures ~ Steven Lembark ~ TPRC 2025 - YouTube
by LanX
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |