On 09/29/2015 08:40 PM, Bart Schaefer wrote:
} } I just learned that it's possible to declare a function within another } function. A strange liberty. Interpreted language.
Yes. It's so easy to forget that.
Now that is mind expanding. If you tried that in C you'd collapse the universe. Interpreted .... sure, it can saw off the branch it's sitting on because there is no tree. Each command is past when it's past so that must mean that the address of first foo ... is there ... yes of course there is, the thing is in memory ... just aborts when second foo comes along. It will expect grammatical completion of first foo for the sake of etiquette. And when foo calls itself, it calls new foo which is not recursive. I am not yet able to snatch the pebble out of your hand, but that'sfunction foo { echo defining bar function bar { echo hello from bar } echo redefining foo function foo { echo hello from new foo bar } # this looks like infinite recursion, # but it is not, because foo was redefined foo }
a zsh koan.