zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Oliver Kiddle <okiddle@yahoo.co.uk>
Cc: zsh workers <zsh-workers@zsh.org>
Subject: Re: Proof of concept: "static" parameter scope
Date: Mon, 28 Sep 2015 21:42:53 +0200	[thread overview]
Message-ID: <CAHYJk3Qg6Epk=ORaSqyOV49=brcOgxA+PvOU7Bnvg07gAk3CgQ@mail.gmail.com> (raw)
In-Reply-To: <21593.1443459899@thecus.kiddle.eu>

On Mon, Sep 28, 2015 at 7:04 PM, Oliver Kiddle <okiddle@yahoo.co.uk> 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


  parent reply	other threads:[~2015-09-28 19:43 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-25  2:23 Bart Schaefer
2015-09-25  9:15 ` Peter Stephenson
2015-09-26  5:23   ` Bart Schaefer
2015-09-30 19:38   ` Peter Stephenson
2015-10-01  0:27     ` Bart Schaefer
2015-10-03 19:19       ` Peter Stephenson
2015-10-03 23:43         ` Autoloaded keywords (Re: Proof of concept: "static" parameter scope) Bart Schaefer
2015-10-05 21:55         ` Proof of concept: "static" parameter scope Daniel Shahaf
2015-10-05 22:17           ` Bart Schaefer
2015-10-05 22:36             ` Daniel Shahaf
2015-10-05 23:01               ` Bart Schaefer
2015-10-06  8:40           ` Peter Stephenson
2015-09-28 17:04 ` Oliver Kiddle
2015-09-28 17:58   ` Roman Neuhauser
2015-09-29 23:31     ` Andrew Janke
2015-09-30  3:06       ` Bart Schaefer
2015-09-28 19:42   ` Mikael Magnusson [this message]
2015-09-29  1:23     ` Bart Schaefer
2015-09-29  8:39       ` Peter Stephenson
2015-09-29 22:34       ` Daniel Shahaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHYJk3Qg6Epk=ORaSqyOV49=brcOgxA+PvOU7Bnvg07gAk3CgQ@mail.gmail.com' \
    --to=mikachu@gmail.com \
    --cc=okiddle@yahoo.co.uk \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).