From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [PATCH 3/3] Documentation for named references
Date: Tue, 7 Feb 2023 10:51:05 +0000 [thread overview]
Message-ID: <20230207105105.GB14216@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <CAH+w=7YAvAVOiUzj_tyc=Amgs1N0S50FrrBHsuVWiO10Q3cY+A@mail.gmail.com>
Bart Schaefer wrote on Mon, Feb 06, 2023 at 19:25:03 -0800:
> On Mon, Feb 6, 2023 at 4:57 PM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> >
> > Bart Schaefer wrote on Sun, Feb 05, 2023 at 18:26:50 -0800:
>
> > > +tt(-n). The var(name) assigned-to may not be an array element nor use
> >
> > s/assigned-to/assigned to/
>
> I did that on purpose to remove any ambiguity about what object "to" acts upon.
I see.
> I've used s/assigned-to/so created/
+1
> > > +When both a named reference and the `tt((P))' flag appear, the named
> > > +reference is resolved before `tt((P))' is applied.
> >
> > Add a test for this last sentence?
>
> I can't think of a way to do so. Given ${(P)ptr}, there are two possibilities:
> 1) ptr is a scalar, in which case we're not testing the right thing
> 2) ptr is a reference, so any other order of expansion is meaningless
>
I'm not sure I follow what would be "meaningless" here. I guess you
mean that ${(P)foo} requires foo to be a scalar's name and expands to
a list of words, so trying to expand ${(P)} first to a list of words and
then treating that as a nameref wouldn't be implementable. Is that
what you mean?
Anyway, would it be worthwhile to add a few simple tests of the
combination of (P) and namerefs? I have these:
pointee=value
typeset -n nr=pointee
myscalar=nr
echo ${(P)myscalar}
0:named references with (P), as ${(P)name_of_nameref}
*>value
pointee=value
myscalar=pointee
typeset -n nr=myscalar
echo ${(P)nr}
0:named references with (P), as ${(P)nameref}
*>value
(the asterisks are so MUAs don't treat the ">" as a quote)
> If ptr is a reference, a working test of ${ptr} implies that ${(P)ptr}
> also works. [...]
That doesn't seem to be the case in the following:
% ary=( 'bry[1]' 'bry[2]' )
% bry=( lorem ipsum )
% typeset -n nr='ary[2]'
% echo $nr
bry[2]
% echo ${(P)nr}
zsh: bad substitution
I expected this to expand to "ipsum".
I also expected $nr and ${nr} to behave identically to each other, but:
% ary=( foo bar )
% typeset -n nr='ary[2]'
% echo ${nr}
zsh: bad substitution
% echo $nr
bar
%
>
> > WDYT of documenting somewhere in the manual namerefs are new in 5.10?
>
> I was going to add something to NEWS and README eventually ... also, I
> wasn't sure we'd landed on a version number yet. I suppose (once we
> do) a mention wouldn't hurt since the docs are likely to end up on
> line.
That's one argument, yes. Furthermore, I think stating version numbers
would be useful even in the locally-installed versions of the manual,
since someone might run a bleeding edge distro and write code that
targets LTS distros.
> > > texinode(Parameters Set By The Shell)(Parameters Used By The Shell)(Local Parameters)(Parameters)
> > > sect(Parameters Set By The Shell)
> >
> > s/Local Parameters/Named References/
>
> Thanks, thought I'd caught all of those ... it was nice when the older
> version of yodl complained about those incorrect references.
The yodl macro is a thin wrapper around the texinfo macro. Perhaps
texinfo warns about this somewhere in its output?
next prev parent reply other threads:[~2023-02-07 10:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-06 2:26 Bart Schaefer
2023-02-07 0:56 ` Daniel Shahaf
2023-02-07 3:25 ` Bart Schaefer
2023-02-07 10:51 ` Daniel Shahaf [this message]
2023-02-07 16:53 ` Bart Schaefer
2023-02-08 21:28 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230207105105.GB14216@tarpaulin.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).