That's more or less how lexicals are realized in Perl.
A Pad° is a hash like structure ("namespace") like a package. (with the difference that it doesn't have globs)
Every scope has it's own pad, nesting scopes results in a chain of pads to be investigated.
You may want to play a bit with PadWalker
> Python doesn't have lexicals.
Python has closures, closures require lexicals.
> there is no equivalent to my in python.
Implementation of semantic matters not syntax or naming.
the first assignment in a "scope" is an implicit declaration in Python.
Sometimes it's a my sometimes an our .
The mess starts because you can't use something like strict* to catch typos and Py3 needed to introduce nonlocal to mark assignments which are not declarations.
"Explicit is better than implicit" ... LOL
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
°) Pad: = short for perlguts#Scratchpads
*) which JS successfully copied because it has var and even let now.
In reply to Re^3: Nesting Functions
by LanX
in thread Nesting Functions
by betmatt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |