Eric Blake: > On the Austin Group mailing list, David Korn (of ksh93 fame) > complained[1] that bash's 'local' uses dynamic scoping, but that ksh's > 'typeset' uses static scoping, and argued that static scoping is saner > since it matches the behavior of declarative languages like C and Java > (dynamic scoping mainly matters in functional languages like lisp):
Most languages avoid dynamic scoping, including (functional) Scheme. Among the few languages that support dynamic scoping a number of them offer static scoping as well, so people can write simpler, deterministic and readable code. > Therefore, the behavior of f2 [in dynamic scoping] depends on where f2 > is called which means Referential Transparency (a sane Good Thing) is broken. > 2. User aspect: > Is anyone aware of a script that intentionally uses the full power of > dynamic scoping available through 'local'... Yes dynamic scoping is more powerful: insanely more powerful. David Korn: > In the fifteen years that ksh93 has been available, there have been > two reports of scripts that have broken from changing to static > scoping. Chris F.A. Johnson: > I find the bash behaviour more logical, and I do use it in scripts. Examples?