Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Warning about failed assignments to references to not yet defined variables
- X-seq: zsh-workers 53700
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Philippe Altherr <philippe.altherr@xxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Warning about failed assignments to references to not yet defined variables
- Date: Wed, 28 May 2025 21:14:01 -0700
- Archived-at: <https://zsh.org/workers/53700>
- In-reply-to: <CAGdYchsr8jCBkniN_ZRWzTFHNmMx=9tUkUOGaLZuCLmEdgSshQ@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAGdYchuuU5Cr8857UBvwZAREL8D4y7UNQjULWAVFC_XyfooOkA@mail.gmail.com> <CAH+w=7ZODHt82SMpnQg0dq-hezeEdZRKiXHDvR6qDPjNzXihWA@mail.gmail.com> <CAGdYchsr8jCBkniN_ZRWzTFHNmMx=9tUkUOGaLZuCLmEdgSshQ@mail.gmail.com>
On Wed, May 28, 2025 at 2:55 PM Philippe Altherr
<philippe.altherr@xxxxxxxxx> wrote:
>
> I'm fine if upper references to not-yet-defined variables aren't supported but I would very much prefer that this triggers an error rather than does something not defined. In my opinion undefined behaviors in programming languages are lazy and don't help anyone, neither the language users nor the language implementers.
You have a lot of bones to pick with the POSIX spec, then.
> Here, signaling an error when an upper reference is initialized with a not-yet-defined variable would be easy. Why not do it?
Again, more on the other thread when I have a chance to finish, but:
You agree this is OK at the top level?
typeset -n globalref=undefinedglobal
??
If you agree, then does this generate an error?
() {
typeset -un localref=globalref
...
}
Why would the following require an error?
() {
typeset -un localref=globalvar
typeset -g globalvar
localref=val
}
All that said, I am thinking to issue a warning when an assignment to
such a reference fails.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author