Stephane Chazelas dixit:

>Because the "unset" was done in a separate function, instead of
>having an unset $a, we've got the $a of the outer scope.

Ouch. That’s extremely surprising.

By contrast, in mksh, there is simply no way, period, to get to
the global variable, or a variable from an intermediate scope,
if the local scope (or one below the intermediate but above the
local one) has hidden it.

Even mksh’s “global” builtin does not access the global scope.
It’s simply a “typeset” that’s not also “local”.

This was quite a thing to think about when introducing namerefs
to mksh, but I believe I found a way to make it work by convention:
every function in a nameref-using construct must prefix all locals
with its function name, so they never conflict. (That’s not to say
one cannot use namerefs without that, I do, e.g. in “uhr”, but e.g.
in a generic framework this is required.)

The idea behind this is probably: scopes can be nested (except ksh93),
and it doesn’t really make much sense to treat only one of the parent
scopes (the global one) special. In most programming languages, you
lose access to global names once you have a local one with the same
name.

bye,
//mirabilos
-- 
“ah that reminds me, thanks for the stellar entertainment that you and certain
other people provide on the Debian mailing lists │ sole reason I subscribed to
them (I'm not using Debian anywhere) is the entertainment factor │ Debian does
not strike me as a place for good humour, much less German admin-style humour”

Reply via email to