Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Up-scope named references, vs. ksh
- X-seq: zsh-workers 52676
- From: Oliver Kiddle <opk@xxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Up-scope named references, vs. ksh
- Date: Tue, 05 Mar 2024 02:05:03 +0100
- Archived-at: <https://zsh.org/workers/52676>
- In-reply-to: <CAH+w=7ZZrCh23Q3kzJ3K-TtS1ULnWyR-Cpj_ymSvEgejpvtDgw@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAH+w=7ateaqX5azdifTaFpJT6sX-fVhnEazgeYYXSWtJY8EQTw@mail.gmail.com> <CAH+w=7akb334QvsofyMLtc7_091bmP=omjAGOZSc8eH8FWuTqQ@mail.gmail.com> <20240220210553.g6imt3op6zahz4pa@chazelas.org> <CAH+w=7bucofSovKLc0kJeMT3RcKUc8ydhFSaGQqMALvJ_0S21Q@mail.gmail.com> <20240221201215.anpjcfav6na55gg6@chazelas.org> <CAH+w=7aGtWkXFYXQRnL808CscE0=CsAvA3zpoUK6LcSzk5JEww@mail.gmail.com> <20240301182238.tpyajwblbam5bxw7@chazelas.org> <CAH+w=7bVzYFBsqpZy40GEJ6qGpM+BQz9AbY=3eTtW_2B4wB3dA@mail.gmail.com> <20240303134413.74c7trikf73g5kjy@chazelas.org> <CAH+w=7ZZjS3QZeK8R8Zy_ACHeJsFj_YoKk22R3EG0NhXaQHjFA@mail.gmail.com> <20240303202756.7axmzy6gkohza2ra@chazelas.org> <CAH+w=7ZZrCh23Q3kzJ3K-TtS1ULnWyR-Cpj_ymSvEgejpvtDgw@mail.gmail.com>
Bart Schaefer wrote:
> The word "scalar" is just as important in that sentence as the word
> "global" -- "read" and "zstat" can specify whether the variable is
> scalar or array, you can't do that with a nameref. Furthermore, if
Isn't defaulting to a scalar type fairly normal. For the read use case,
it works for some basic tests when you start the function with:
[[ -v $1 ]] || typeset -g $1
typeset -un ref=$1
A different problem I'm finding is with not being able to hide the
reference type of a variable in a called function:
inner() {
local var=hello
typeset -p var
}
outer() {
typeset -n var=value
inner
}
outer
This outputs
typeset -g -n var=value
The value "hello" is lost but a subsequent assignment within inner()
applies to the reference.
I would expect the `local var` in inner to hide any variable including
references with the same name from an outer scope.
(I'm currently testing with the typeset -nu and Fix crash on
unset-through-nameref patches applied).
Oliver
- References:
- Re: [PATCH 1/3]: Add named references
- Up-scope named references, vs. ksh
- Re: Up-scope named references, vs. ksh
- Re: Up-scope named references, vs. ksh
- Re: Up-scope named references, vs. ksh
- Re: Up-scope named references, vs. ksh
- Re: Up-scope named references, vs. ksh
- Re: Up-scope named references, vs. ksh
- Re: Up-scope named references, vs. ksh
- Re: Up-scope named references, vs. ksh
- Re: Up-scope named references, vs. ksh
- Re: Up-scope named references, vs. ksh
Messages sorted by:
Reverse Date,
Date,
Thread,
Author