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

Re: Warning about failed assignments to references to not yet defined variables



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