Zsh Mailing List Archive
Messages sorted by:
Re: static vs. dynamic scoping
- X-seq: zsh-workers 28400
- From: Peter Stephenson <Peter.Stephenson@xxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: static vs. dynamic scoping
- Date: Wed, 10 Nov 2010 11:10:25 +0000
- In-reply-to: <4CD9C64E.8060307@xxxxxxxxxx>
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:email@example.com>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: Cambridge Silicon Radio
- References: <4CD9C64E.8060307@xxxxxxxxxx>
I might as well copy what I sent to the Austin group list this
morning for the majority not following that...
The "other" matters referred to are, to summarise very briefly,
causes x to be set to "a b". Currently POSIX implies it doesn't.
From: Peter Stephenson <pws@xxxxxxx>
Subject: Re: Word splitting in 'export' arguments and adding local
Date: Wed, 10 Nov 2010 10:13:20 +0000
On Tue, 09 Nov 2010 22:34:22 -0500
Chet Ramey <chet.ramey@xxxxxxxx> wrote:
> Bash uses dynamic scoping and, as I have existing users and scripts
> that take advantage of it, I have no intention of changing that. I
> know zsh uses dynamic scoping and there are scripts that make
> extensive use of it.
That's correct about zsh: the completion functions supplied with the
shell rely (very) heavily on dynamic scoping and we certainly wouldn't
be changing that. I can't see any likelihood of writing a completely
different additional implementation of local variables with static
scoping for POSIX mode.
It might be possible as an option to hide and uncover variables when
entering nested functions to simulate static scoping without a complete
rewrite, but I really haven't thought it through and it's not likely to
be a high priority. It might also be worth reminding people that POSIX
support was rather an afterthought for zsh but we try to keep that mode
working where possible.
I don't think any of the other matters being discusses here are a big
issue for zsh in POSIX mode, however. If you happen to be investigating
this in zsh, the following options are relevant:
turn on splitting of substitutions as done by default in other shells
turn off argument splitting on assignments for typeset, local, etc.
if SH_WORD_SPLIT is on. Note this is not turned on automatically
in POSIX mode (for reasons anyone following this thread will realise).
~-expansion (and zsh-specific =-expansion, if applicable) are active
after all "=", and also after following :, regardless of the command.
The example in the manual is
expands both ~'s. The effect of this option has expanded somewhat
during the life of zsh. (I'm not suggesting this would ever be
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
Messages sorted by: