Zsh Mailing List Archive
Messages sorted by:
Re: Proof of concept: "static" parameter scope
- X-seq: zsh-workers 36683
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- Subject: Re: Proof of concept: "static" parameter scope
- Date: Mon, 28 Sep 2015 21:42:53 +0200
- Cc: zsh workers <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=f9RkOVHE8thTpUALfZrm3a4O8w9r+syXT6PuHr83JhU=; b=d/mg46Y2Ln6OFSGmBmzDozoZjb3lMafpZwBbPQ9u7Cam08DKPIVy+XWrqUgGXG180v jdSmY0fF7T9bPocAW6pyqp0QXdEWpU6RO3qGfZz+Eu51zrunIFRmDWXJOCIehIDQnpU9 Q4rK/6o67nKTQtfheRMI5ITd1k9B/Y0V3xWbieAfACdQTcgameGaUbiyaE9XP3aSEBCD 3PhwCLs9fgGStiwQHVY2Xnme0oVxvyggTaS2lMFkmYwxFxT8NDxFOai81Ibw3DsgkkGW HJ0THJrMD1PL6oaP86Iify68cdkUGjC4+CQZljFjGL5HDuSy764E1uQ+zzfCstgZpnJS ZJWQ==
- In-reply-to: <email@example.com>
- 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
- References: <150924192305.ZM2680@torch.brasslantern.com> <firstname.lastname@example.org>
On Mon, Sep 28, 2015 at 7:04 PM, Oliver Kiddle <okiddle@xxxxxxxxxxx> wrote:
> Bart wrote:
>> The patch below creates a module "zsh/param/static" which supports a
>> single builtin command "static". The included doc section describes
>> "static" in detail, but briefly, it works like the "local" builtin
>> except that variables so declared are not dynamically visible to any
>> called functions.
> Very nice.
>> "Called functions" includes recursive calls to the function itself, so
>> this doesn't work like C "static". Therefore I'm in the market for a
>> better name.
> The trouble with "static" is that people with a C or C++ background will
> expect something different. It might be better to find a new word in the
> thesaurus that doesn't carry the baggage of another common meaning. Note
> that, as you mention in the documentation patch, ksh93 has a typeset
> -S option which does do C like static variables. Aside from confusing
> users, the Zsh use of the term "parameter" seems even more tenuous when
> applied to lexically scoped variables because they can't be used as
> named parameters. So instead of "static" I would simply suggest "var".
> This name does take the emphasis away from the scope but that could be a
> good thing in terms of encouraging it's use. It is actually "local" with its
> obscure dynamic scoping that really needs the more elaborate explanation
> in the documentation. And "typeset" isn't a good name because
> typesetting evokes things like LaTeX.
I think the "local" scope is actually extremely simple to understand,
it goes out of scope when the current function ends, period. In C it
is much more complicated, it goes out of scope when you leave a block,
it goes out of scope when you call a function but then goes back into
scope when you return, possibly multiple times, you can 'goto' out and
in to scope. I suppose it's also a matter of perspective.
Also, "static" already means at least 3 different things in C, it
doesn't make any sense to expect it to mean any particular one of
these things in zsh?
What about "private" instead of static though? If the intention is to
hide it from called functions, it is somewhat closer to that concept,
if not just the normal word.
Messages sorted by: