Re: static vs. dynamic scoping
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?
Inconsistency of physical / logical directory structure and tab completion
$ tree -p . ├── [-rwxrwxr-x] out_bin ├── [-rw-rw-r--] out_not_bin ├── [drwxrwxr-x] out_of_recursion └── [drwxrwxr-x] recursion ├── [-rwxrwxr-x] bin ├── [lrwxrwxrwx] in -> ../recursion/ ├── [-rw-rw-r--] not_bin └── [drwxrwxr-x] without 4 directories, 4 files let's go into recursion dir $ cd recursion/ $ pwd -L && pwd -P /home/rrakus/tmp/symlink-test/recursion /home/rrakus/tmp/symlink-test/recursion try to tab-complete commands - [TAB] means hitting the tab twice $ ../[TAB] out_bin out_of_recursion/ recursion/ $ ./ bin in/ without/ So far, everything is ok. Now go into dir in, which is symlink to ../recursion/ - current dir $ cd in/ $ pwd -L && pwd -P /home/rrakus/tmp/symlink-test/recursion/in /home/rrakus/tmp/symlink-test/recursion And now try the tab-completion as above $ ../[TAB] <--- bug here? $ ./[TAB] bin in/ without/ Is that bug? Or expected behaviour? ../out_bin will correctly run that binary $ ../out_bin HELLO $ cat ../out_bin echo HELLO However try to complete file names $ cat ../[TAB] bin in/ not_bin without/ Trying glob completion works $ ../*[TAB] ../out_bin ../out_of_recursion ../recursion However, simple file completion uses logical dir struct, but glob completion physical $ pwd -L && pwd -P /home/rrakus/tmp/symlink-test/recursion/in /home/rrakus/tmp/symlink-test/recursion $ ls ../[TAB] bin in/ not_bin without/ $ ls ../* out_bin out_not_bin out_of_recursion recursion set -P will turn everything to consistent state, however is the above considered as expected behaviour or is that a bug? RR
Re: Inconsistency of physical / logical directory structure and tab completion
On 11/10/2010 05:25 PM, Roman Rakus wrote: $ tree -p . ├── [-rwxrwxr-x] out_bin ├── [-rw-rw-r--] out_not_bin ├── [drwxrwxr-x] out_of_recursion └── [drwxrwxr-x] recursion ├── [-rwxrwxr-x] bin ├── [lrwxrwxrwx] in -> ../recursion/ ├── [-rw-rw-r--] not_bin └── [drwxrwxr-x] without Ah, there are missing spaces (at least I see them): $ tree -p . ├── [-rwxrwxr-x] out_bin ├── [-rw-rw-r--] out_not_bin ├── [drwxrwxr-x] out_of_recursion └── [drwxrwxr-x] recursion ├── [-rwxrwxr-x] bin ├── [lrwxrwxrwx] in -> ../recursion/ ├── [-rw-rw-r--] not_bin └── [drwxrwxr-x] without Hopefully it is better. RR
Re: static vs. dynamic scoping
On Wed, Nov 10, 2010 at 6:37 PM, Marc Herbert wrote: > Chris F.A. Johnson: > > I find the bash behaviour more logical, and I do use it in scripts. > > Examples? > > http://fvue.nl/wiki/Bash:_Passing_variables_by_reference , I like that.