3 ms·
Sometimes (mainly in testing code), I've practically reinvented dynamic scoping: If you ever want to do "call function f(), but for this single call, redirect a
by AgentME 8y ago
Sometimes (mainly in testing code), I've practically reinvented dynamic scoping: If you ever want to do "call function f(), but for this single call, redirect accesses of global.xyz to the value mockXyz instead", then what you're doing is essentially dynamic scoping. Sometimes it would have been better if f() just took xyz as an argument, but in some cases I can't help but think the dynamic-scoping-style solution is all-around simpler.
But I am so glad that dynamic scoping isn't the default scoping style for variables in sane languages.