Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Proof of concept: "static" parameter scope




On 9/28/15 1:58 PM, Roman Neuhauser wrote:
# okiddle@xxxxxxxxxxx / 2015-09-28 19:04:59 +0200:
Bart wrote:
"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".
agree wholeheartedly with everything Oliver said.

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"?
I'm a fan of "my". Perl's "my" and "local" are exactly the example I use when explaining the behavior of zsh "local" variables to new users. This new scope seems to correspond pretty well to Perl's "my" lexical scoping.

Or maybe "auto"? The C "auto" storage class (the default one, scoped to a block in a function activation) corresponds pretty well to this new static scope, since it's scoped to a single function activation / call stack frame (as opposed to a stack frame and all its child frames).

Or maybe "reallylocal"?




Messages sorted by: Reverse Date, Date, Thread, Author