Re:Show HN: Go-git – low-level and extensible Git client lib...
by pcwalton on Wednesday February 17, 2016 @03:26AM
(#11116230)
Yeah, I shouldn't have used the term "dynamic scope" there. PHP has dynamic environments that can be mutated at runtime, which languages like JS don't (well, outside of direct eval).
Global is just a flat namespace. Functions have their own, separate flat namespace each. I tried the following in a REPL:
function two() { echo $a; }
function one() { $a = 1; two(); }
one();
as the standard dynamic scope example, and I get an "undefined variable" error. Did that use to be dynamic? (I wouldn't be surprised, though, especially given PHP's implementation history...)
There is an explicit "static" modifier that looks dynamic, but I couldn't get it to run that way. It seems to just retain state in recursive calls of the same function, or something?
[edit:] (And PHP doesn't predate Javascript, but regardless, "no first-class functions" isn't "no lexical scope".)