From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18718 invoked by alias); 28 Sep 2015 19:43:00 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 36683 Received: (qmail 14087 invoked from network); 28 Sep 2015 19:42:58 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 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== MIME-Version: 1.0 X-Received: by 10.140.145.145 with SMTP id 139mr25961576qhr.100.1443469373655; Mon, 28 Sep 2015 12:42:53 -0700 (PDT) In-Reply-To: <21593.1443459899@thecus.kiddle.eu> References: <150924192305.ZM2680@torch.brasslantern.com> <21593.1443459899@thecus.kiddle.eu> Date: Mon, 28 Sep 2015 21:42:53 +0200 Message-ID: Subject: Re: Proof of concept: "static" parameter scope From: Mikael Magnusson To: Oliver Kiddle Cc: zsh workers Content-Type: text/plain; charset=UTF-8 On Mon, Sep 28, 2015 at 7:04 PM, Oliver Kiddle 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. -- Mikael Magnusson