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

Re: [PATCH] Remove support for named references to subscripted variables



OK, thanks for clarity; no, that is not the difference I was thinking of.

There are still differences between the two functions but I assumed that both should agree on what qualifies as a regular variable name, i.e., one that can be used on the left of the equal sign in a typeset or in an assignment.

With the introduction of namespaces, it's no longer clear to me what qualifies as a valid variable name. Here are example of valid names (on the left of an equal sign in a typeset):

    foo  foo.  foo.bar  foo.456  foo.4ar
   .foo       .foo.bar .foo.456


And here examples of invalid names:

        .foo.                   .foo.4ar  .  foo..
         123.  123.bar  123.456  123.4ar .. .foo..
   .123 .123. .123.bar .123.456 .123.4ar
    1oo  1oo.  1oo.bar  1oo.456  1oo.4ar
   .1oo .1oo. .1oo.bar .1oo.456 .1oo.4ar

Given the description of namespaces in section 15.1, I'm surprised that ".foo" and "foo." are valid. I would have expected that names with namespaces must always contain two non-empty identifiers.

I'm also a little surprised that the second identifier may start with a digit. I'll admit that there is nothing in the documentation that forbids it. It's just because identifiers usually have to start with a letter.

Finally, I'm more than a little surprised that "foo", ".foo" and "foo." are all valid but not ".foo.". Same for "foo.456", ".foo.456", and "foo.4ar", which are all valid but not ".foo.4ar".

Philippe


On Wed, Feb 18, 2026 at 11:46 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
On Wed, Feb 18, 2026 at 1:29 PM Philippe Altherr
<philippe.altherr@xxxxxxxxx> wrote:
>
> Just to be clear, here is an example of what I mean: a variable named ".123" can't be created with an assignment or with a call to typeset but it works with a named reference initialized with ".123". Is that really expected?

OK, thanks for clarity; no, that is not the difference I was thinking of.


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