Dynamic scoping, in contrast to the more popular static scoping, can be more easily used to modify another piece of code, which perhaps cannot be directly modified for technical or legal reasons.
A child function calls evilFunction. With dynamic scoping, the parent function rebinds evilFunction to something safe, then calls the child function inside the new dynamic scope.
Can this capability be achieved in a primarily statically scoped programming language? Let's say DLLs don't count because they are too obvious.
How do we avoid the complete breakdown of ability to do static analysis once dynamic scoping is permitted?
(I think Tcl permits directly modifying the symbol table.)
Potential major problems in code with inversion of control, e.g., callbacks, where the child can modify the parent's code.
No comments :
Post a Comment