From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14262 invoked by alias); 28 Sep 2015 17:11:52 -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: 36676 Received: (qmail 9888 invoked from network); 28 Sep 2015 17:11:50 -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=yahoo.co.uk; s=s2048; t=1443459900; bh=Cs1cpJY6kgpJbZzt3Yxe7ztZSjpy6vmzatSlwXWYI0c=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=B5wvuohYGnk/JULaM8iIh9oKcle1kv9by47vZFy1Tg311l6YeB3oN0rqiahxRqNcYSZF1KT7oyD5VNhXnutlzBzSGqIuwfX20dfUVzTATvibWLCCiY5ElGXNVPsVXxgULPUwVx7IB/xtuGAukYg3u7gQi3sntXRYjU8SwJBU389DO6HodElycohFrx0XWPE36alvJbPaHi7aEiX4XdSdNyNzVUtZd42IHExI5bAuuJtuVQIEaBT4bZV6IvxrDLoGid3sGIuEfw23CGGOq4zSCqDrvBpzdgaHB++TsR5Cq2DErx9Me9dBRmXPg9n0UrohW5ltqhjVJjVB13BdeON5PA== X-Yahoo-Newman-Id: 795563.33910.bm@smtp141.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: B_ULw0cVM1koR.Xz1Qux6nnFBpNlk3M6lJAK_dfpdhY3SXc PW4l8EVvySJ6weZGz4EI8ePLQMtOOOblo2bww02p2Yw0VJBH5QhSnDgwnr.7 Xqu_sVghe6cXicnnakeMVeoeQI85MVLDN3dQmdjQWDPQPgFe9zKGrG8hm.Ru yxTERuKNk33_QORmn_tqKGxE39P0J1ZASuSdEWwz2BEyVNh5QycY1EE1n3x2 X3M4uaOvucXVX._CnLuQ5gq8abTbmu3tsHerUvEgylnEWq1Xsl98c15VYh2k xRFyLKUTXuYjWWuhgX7gJ8ZBPCPY8GmkjvQB7JCgSx.o1GeLlIWCJ1694MGT js.K5AQS0VbnlLO.n2jI0OuLPcUsdQoQUalBOnLyjRpVe0jhsVwDVh1Epge0 YS7ng0LJ4OuH2rNHINw.TF.YG9kcoNpxu4a09z0emEA2QwYSU4cMSqugv7QU YxdsaQqP5rhjCH1002LuP2rPAq7fmt9aIuCU3_0Z4hOJGYgm4kkZz0cIjhsF .tP9aei7K1ytMq_eYRN.XSxGBvoAFwA-- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- In-reply-to: <150924192305.ZM2680@torch.brasslantern.com> From: Oliver Kiddle References: <150924192305.ZM2680@torch.brasslantern.com> To: zsh-workers@zsh.org Subject: Re: Proof of concept: "static" parameter scope MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <21592.1443459899.1@thecus.kiddle.eu> Date: Mon, 28 Sep 2015 19:04:59 +0200 Message-ID: <21593.1443459899@thecus.kiddle.eu> 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. We might also want to hold on to -S for real static variables or perhaps file backed "shared" variables (as someone recently requested). > There are some tricks played to avoid creating new PM_* flag bits. If > this ceased to be a module and became a "real" builtin (something about > which I'm ambivalent) there are parts that could be simplified by using > another flag bit. I like the fact that this hasn't added a load of extra complexity to bin_typeset(). An extra flag wouldn't be too invasive if it helps the implementation. I can't think of a reason to suggest that it should cease to be a module if the implementation hasn't required it. It's also worth having the reserved word form as per your later patch even if it compromises the purity of the module separation. Despite throwing quite a few odd things at it, I've not been able to break it. It'd be nice if typeset -p could tell you that it is a static variable. Theres also ${(t)...}. > +Although var(name)tt(=)var(value) sytax may be used in the argument list typo: syntax > +itemiz(An exported static remains in the environment of inner scopes but > +appears unset for the current shell in those scopes.) > +enditemize() That doesn't seem ideal. It also seems that can be further affected if the variable is declared local in some inner scope. Oliver