Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: A solution to fix hidden references in reference chains
- X-seq: zsh-workers 54240
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Philippe Altherr <philippe.altherr@xxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: A solution to fix hidden references in reference chains
- Date: Sun, 22 Mar 2026 20:21:46 -0700
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=DiRB6Td85jLew7qSSXECDsKrVL/Stn3N7c1kq0NpVZg=; fh=RngAOd9wlRc8Glv1v2GOfDUnq2FsyrczungEY8JNfXY=; b=NgVrNuXjyk0tSRHUumWvn7eRAnxOeJFAQggYmUJy2QS6btK5K/XPMpi2V0f+7ZILuC akX5RxhfS6hpQfRgFufECPhX8veAg/SI8smqCVAiyfxPBS/G1OVOpzmhVl3bkTKq3MJ6 Pmph8NUdA3xI+6eFo9B7m8jB8YAaoXTu6nooybhc05/DQGE858dmpIHAQyIKyQaUHSxF oG5hyrTEIl4X1k/OGZ3KIffnvQHSuIQmdejZL/f95HtYz+nv7JYnfIFDxO/KnSMNrhUS 32rDghZEYPlKdGr13pY1jfnFKFdIg2z20FI9EiBDSqRHrFB4RYxIcgjxBq1hQMaAiwjS XHNQ==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1774236117; cv=none; d=google.com; s=arc-20240605; b=CV4v5BU2UhdYKDhrWQHHQj9Al0DPJnA5apka7jkraiuOWssFXRiIC15VVVrcn2U+w1 1CUgjneOh2Hocxbc4xQV7gUYag+h06h11TR8VSWRu86sWx/FF5Zp5a83OyLIORd3ltl/ EeL4q01/2cJt8gMSPXwnsRLR4aje3iEbKhASJ0hle13uMwwflFqWLqIHCqdBdFKUp3hj LbF8wmhRQ7k/cawHTYr4r74kl37qkNZ5I16/AsRGd7wC2ehYBP8v3AG7oKNO6AfDiS40 ZKk/Ai4NmSs+fJWdkCl6lxtO4s9+WDykQhs/95PPAlFARUhNAkYD9y1ZmrKSv/4ulxoD iJlg==
- Archived-at: <https://zsh.org/workers/54240>
- In-reply-to: <CAGdYchsioZqVwsr47KqR--2zPBXM_hvg6QrPdkDYw52-R=qbgw@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAGdYchu3rxH9MBanWDLTuWcaUNh+g1suQD1bRmC+Pbcj+QJY1A@mail.gmail.com> <CAGdYchvU3=Zzk8q-V36EEf9WDHd6Y9Mjgg=mkKFVRn0BbGuAcA@mail.gmail.com> <CAGdYchuNP=3pfWYRX7iq3wqTf1tzwuUA+txdpPiKrLAcATMLdg@mail.gmail.com> <CAGdYchsVb+dSmS6uHVqORNkFdcmY3f9qKz_J9CrLJYuMN6sf0A@mail.gmail.com> <CAH+w=7Y7WcHh6VYUakX42cUc2ybHNPp=q5ex91UUL1HGc1YjMw@mail.gmail.com> <CAH+w=7aWyqQ3WFD_QgPThZ1TgsccZj1DfJ9Pf7FS5Pqkc3wD9g@mail.gmail.com> <CAGdYchv8AsaH4UQHcqvetAOmiYrS3_0uNKf+yn2kXRP3YLbWzw@mail.gmail.com> <CAH+w=7Y9YO4n5QXOsDnkjVzz5KEr1Hh7AhinzO+kxjvdKwL+HA@mail.gmail.com> <CAGdYchsioZqVwsr47KqR--2zPBXM_hvg6QrPdkDYw52-R=qbgw@mail.gmail.com>
On Sun, Mar 22, 2026 at 6:15 PM Philippe Altherr
<philippe.altherr@xxxxxxxxx> wrote:
>>
>> But you can't change a named reference into something else that way.
>> Even "unset -n" doesn't remove the nameref-ness of the surrounding
>> scope parameter.
>
> Yep but I was working on a fix for this issue. I have now sent the patch, see workers/54236.
This is exactly the thing I meant was a conflict. I'm not convinced
workers/54236 is correct in this regard.
>> > - Ref added to a scope list is now an integer with base=N
>>
>> Per above, I think this is actually impossible, at least at present?
>
> Once workers/54236 is committed all of that should become possible.
Again, should it? (Asking others, not Philippe.) Related:
> - In workers/54236, I had to add many checks for PM_UNSET and PM_DECLARED. Most of these would not be needed if whenever a local variable is unset all its flags were cleared and replaced with PM_UNSET. This would guarantee that if a parameter has a type flag (one of PM_ARRAY, PM_INTEGER, PM_NAMEREF, ...) then it's for sure a still alive parameter of that type. Currently, you should always check for the presence of the type flag and the absence of PM_UNSET or the presence of PM_DECLARED, which is rather verbose and very error prone. Do you see any reason why flags should NOT be cleared when a parameter is unset? Afaik, there exists no mechanism that allows undeleting an unset parameter. So I don't see any reason why flags would need to be kept after a parameter is unset.
I don't recall all the details (again, other readers?) but my
recollection is that there's a POSIXy issue here. E.g., an exported
parameter remains exported even if unset (so re-assigning it updates
the environment), and I believe numeric types are supposed to retain
their properties across unset. This is why I wonder whether
references ought also to retain reference-ness across unset.
> - I wonder whether we would be better served if PM_DECLARED was replaced with a PM_NULL
We had that argument at some length before PM_DECLARED was introduced,
and decided against PM_NULL, and I'm not excited about rehashing the
topic.
> - Bart, you once suggested that dereferencing not-yet-initialized references ought to trigger an error. Currently such references need to be handled in several places and, when they are part of assignments, they trigger various kinds of errors/warnings that may not necessarily make much sense to end users. My impression is that things could be simpler and more uniform if dereferencing a not-yet-initialized reference would always trigger an error. I will try to write a patch that does that,
There, we need to consider what happens with ksh.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author