bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: static vs. dynamic scoping


From: Marc Herbert
Subject: Re: static vs. dynamic scoping
Date: Wed, 10 Nov 2010 10:37:00 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101027 Fedora/3.1.6-1.fc13 Thunderbird/3.1.6

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?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]