Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: BUG: Initializations of named references with an empty string should trigger an error
I wasn't going to send this until I'd completed some other patches,
but Philippe is obviously forging ahead without waiting for me, so
sending it now.
On Wed, May 28, 2025 at 3:58 PM Philippe Altherr
<philippe.altherr@xxxxxxxxx> wrote:
>
> Currently, "typeset -n ref=$varname" may or may not initialize the reference even though it's extremely unlikely that anyone would write such code with the intent that an empty "varname" should indeed not initialize "ref".
It's always possible to write ref=${varname?uninitialized reference}
... my philosophy has been that except for impossible cases (like the
"hides nonexistent" patch), nameref parameters should be treated in
the ways that ordinary parameters are treated.
> Another consequence of the current treatment of empty variable names is that when TYPESET_TO_UNSET is enabled, there are two types of reference placeholders
Yes, but there are also two types of scalars. Drop the "-n" and your
example looks exactly the same.
> This stinks of bad design in my opinion.
Perhaps so, but it's a design we inherited. If the defaults of years
ago had been to behave as if TYPESET_TO_UNSET and TYPESET_SILENT were
in effect, I might feel differently, but as things stand "typeset -n
ref=" is a necessity.
> It's even more sad given the fact that otherwise everything is so nice and tidy with TYPESET_TO_UNSET enabled.
I'm curious now what "everything" you find otherwise tidier about
TYPESET_TO_UNSET.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author