In this case, f would use the global declaration of a . Nearly all languages use lexical scope. Under dynamic scope rules, variables are identified by looking backwards through the program execution to find the most recently executed declaration. In this case, f would use the local declaration of a within g . Early versions of LISP and some scripting languages use dynamic scope.
Dynamic scope makes procedures act like macros.
Each actual argument is evaluated to a value before call. On entry, value is bound to formal parameter just like a local variable. Updating formal parameter doesn't affect actuals in calling procedure. Implement by copying. On entry, the formal is bound to the address, which must be dereferenced to get value, but can also be updated .