zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: Proof of concept: "static" parameter scope
Date: Mon, 28 Sep 2015 18:23:27 -0700	[thread overview]
Message-ID: <150928182327.ZM29365@torch.brasslantern.com> (raw)
In-Reply-To: <21593.1443459899@thecus.kiddle.eu>
In-Reply-To: <20150928175834.GE3670@isis.sigpipe.cz>
In-Reply-To: <CAHYJk3Qg6Epk=ORaSqyOV49=brcOgxA+PvOU7Bnvg07gAk3CgQ@mail.gmail.com>

Rearranging a bit ...

On Sep 28,  7:04pm, Oliver Kiddle wrote:
}
} Despite throwing quite a few odd things at it, I've not been able to
} break it.

I tried to make Test/V10* pretty comprehensive.

} It'd be nice if typeset -p could tell you that it is a static variable.

Cf. previous discussion about printparamnode(), which as it stands has
always gotten "local" wrong as well.  Or more accurately, given that
"typeset" is equivalent to "local" when called in function scope, it
is "typeset" of globals that "typeset -p" has always gotten wrong.

} Theres also ${(t)...}.

Yes, this could also be fixed with an actual flag bit -- or by adding
another callback to the gsu structure, which could also potentially be
used to fix printparamnode(), but is a fairly large change.

} > +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.

Agreed, and the best way to handle it would be that statics can't be
exported, but since variables can be declared and exported in two
independent steps, I didn't want to meddle that deeply with "export".

At that point though, I hadn't had the idea of swapping out the actual
handler in the builtintab ... but I really think that particular hack
is to be strongly discouraged.

} It also seems that can be further affected if
} the variable is declared local in some inner scope.

Indeed, nothing prevents creating a local with the same name as a static
as long as the scope is not the same, and exported locals behave as they
always did.

As for naming ...

On Sep 28,  7:04pm, Oliver Kiddle wrote:
}
} 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.

On Sep 28,  9:42pm, Mikael Magnusson wrote:
} 
} 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?

The meaning in this zsh case is obviously "not dynamic" (because all
other variables except the positional parameters have dynamic scope).
C/C++ "static" encompasses both scoping and memory management semantics
and is mostly derived from the latter.

On Sep 28,  7:04pm, Oliver Kiddle wrote:
}
} [...]  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".

Possibly OK for a keyword, not so good for the name of a module.  One
ought to be able to get some idea of what's going to happen when the
module is loaded; "zsh/param/var" gives no hint, and looks redundant.

On Sep 28,  7:58pm, Roman Neuhauser wrote:
} Subject: Re: Proof of concept: "static" parameter scope
}
} one nitpick: "var" has no semantics regarding scope, which is not a
} problem per se, but with 'local' doing something (naively) unexpected,
} maybe a stronger signal would be in order?
} 
} i'd maybe suggest "private" instead, but the sweet succintness of "var"
} is really attractive.  hmm, what about "my"?

This is sort of like perl "my" but perl syntax lends itself to that as
a keyword a little better; "my -slew-of-option-letters thing" doesn't
roll so well and "zsh/param/my" is only a little better than "var".

On Sep 28,  9:42pm, Mikael Magnusson wrote:
} 
} 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.

Once again it's not the same as C++ "private" if that's a concern, but
I do lean in this direction.

Make up a completely new term?  "limited" ?  "bounded" ?  "scoped" ?


  reply	other threads:[~2015-09-29  1:23 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
2015-09-29  1:23     ` Bart Schaefer [this message]
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=150928182327.ZM29365@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --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).