Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH 1/3] Extended ksh compatibility: namespace parameter syntax
- X-seq: zsh-workers 51767
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [PATCH 1/3] Extended ksh compatibility: namespace parameter syntax
- Date: Sat, 20 May 2023 13:32:23 -0400
- Archived-at: <https://zsh.org/workers/51767>
- In-reply-to: <CAH+w=7bjStThTiTpEgem636Hr3Uev9CjLMUBhR1OWGNOvsfq4Q@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: zsh-workers@xxxxxxx
- Openpgp: url=https://www.security.spodhuis.org/PGP/keys/keys-2013rsa-2020cv25519.asc
- References: <CAH+w=7aV2s_+79eCPuavRTiR5wRTwDtTjYxP_VN8HNtL2R5iXw@mail.gmail.com> <26170-1678007435.186071@mDq6.Euc0.bAwZ> <CAH+w=7aqU8B8NAJYD3iAiMRDpGMY=G4oAv6+B+rbdVd_yt6Kyg@mail.gmail.com> <52850-1678055097.553101@HAUa.4aGe.fmcC> <CAH+w=7ZrEFRuswLd6jpAx5YE7X62vrQeuCn9v9EQAgbUVRGVgg@mail.gmail.com> <ZGgq/syXoXQF/pLl@fullerene.field.pennock-tech.net> <CAH+w=7bjStThTiTpEgem636Hr3Uev9CjLMUBhR1OWGNOvsfq4Q@mail.gmail.com>
On 2023-05-19 at 23:54 -0700, Bart Schaefer wrote:
> On Fri, May 19, 2023 at 7:06 PM Phil Pennock
> <zsh-workers+phil.pennock@xxxxxxxxxxxx> wrote:
> > AFAICT, in zsh, .a.b=c is assigning to var b in namespace a, while a.b=c
> > is setting the b attribute of the compound variable a.
>
> As presently implemented, there's no difference. The latter is
> supported by the parser but should be considered a reserved syntax;
> some sort of compound variable feature is a possible future
> application.
Sorry, I thought I'd fixed that typo before sending.
In _ksh_.
I played with ksh to evaluate the behavior, which didn't match what was
said upthread, which is why I spoke up to clarify the distinction.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~8< ksh >8~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% ksh
$ echo ${.sh.version}
Version AJM 93u+ 2012-08-01
$ PS1='ksh$ '
ksh$ foo=( alpha=first beta=second ) # compound var
ksh$ namespace bar { alpha=one beta=two ; }
ksh$ echo ${foo}
( alpha=first beta=second )
ksh$ echo ${.foo}
ksh$ echo ${bar}
ksh$ echo ${.bar}
alpha beta
ksh$ foo.gamma=third
ksh$ echo $foo
( alpha=first beta=second gamma=third )
ksh$ .bar.gamma=three
ksh$ echo ${.bar}
alpha beta
ksh$ namespace bar { echo $gamma; }
three
ksh$ echo ${.bar.gamma}
three
ksh$ echo ${@foo}
typeset -C
ksh$ echo ${@bar}
ksh$ echo ${@.bar}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~8< ksh >8~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I don't know what's going on with `echo ${.bar}`, it's undocumented in
my man-page and the inability to use ${@vname} to get details about it
suggests perhaps it shouldn't expand?
( ksh ${@vname} ~~ zsh ${(t)vname} )
So, to match the intent of ksh as I understand it:
* .identifier.x is always treating identifier as a namespace
* identifier.x is always treating identifier as a compound var
* this is consistent across assignment LHS and expansion
-Phil
Messages sorted by:
Reverse Date,
Date,
Thread,
Author