in reply to Re^2: Nesting Functions
in thread Nesting Functions
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Nesting Functions
by Eily (Monsignor) on Jul 19, 2019 at 13:32 UTC | |
by LanX (Saint) on Jul 19, 2019 at 13:48 UTC | |
by choroba (Cardinal) on Jul 19, 2019 at 14:12 UTC | |
by LanX (Saint) on Jul 19, 2019 at 14:22 UTC | |
by Eily (Monsignor) on Jul 19, 2019 at 14:23 UTC | |
by hippo (Archbishop) on Jul 19, 2019 at 14:38 UTC | |
by Anonymous Monk on Jul 21, 2019 at 22:32 UTC | |
by LanX (Saint) on Jul 19, 2019 at 14:39 UTC | |
by Eily (Monsignor) on Jul 19, 2019 at 14:58 UTC | |
| |
by LanX (Saint) on Jul 19, 2019 at 22:42 UTC | |
|
Re^4: Nesting Functions
by LanX (Saint) on Jul 19, 2019 at 14:15 UTC |