Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Reverse engineering named references
On Fri, May 9, 2025 at 4:55 AM Philippe Altherr
<philippe.altherr@xxxxxxxxx> wrote:
>
> https://docs.google.com/document/d/1C-HBI-sziv4_t5BMed0EjEKByVZQuoYuvthfNnv17d0/edit?usp=sharing
I've been through this document and left a bunch of comments. The
discussion falls into these categories:
1) Suggested changes to the specification, all of which I'd already
incorporated into the documentation update that I mentioned in
workers/53557 as forthcoming
2) Misunderstandings that could be cleared up by use of "typeset -p
ref" instead of "echo $ref" in the test cases; it is unclear whether
this implies a need for any further discussion
3) Inferred behavior of scope transitions, more on this below
4) One actual bug involving a mix of scope transitions with $ref1 ->
$ref2 -> $var -> value chains; I already have a fix for that.
Regarding scope transitions, this was discussed in workers/53549,
excerpted below, emphasis on "variable goes out of scope ... does not
change the assigned value in the calling function":
> Regarding clarification, in the recent PATCH thread, I wrote:
> >
> > When the reference is finally assigned, it refers to the same variable
> > until that variable goes out of scope. However, that does not change
> > the assigned value in the calling function, so when the reference is
> > accessed again in the calling scope it finds the corresponding name
> > there.
> >
> > This behavior is required by K01 test "Global variable is a reference,
> > warning" and it's not clear that it's wrong -- if this were an
> > ordinary parameter, it would remain set in the calling function unless
> > explicitly unset. However, an alternate behavior, such as making
> > lines h:3: and g:3: behave the same as g:2: and h:2:, is possible.
>
> I'm becoming convinced that the current behavior is correct and the
> latter behavior would be wrong, because the latter behavior would
> preclude creating a function whose purpose is to set the target of a
> named reference declared in the calling function.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author