Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: [key]=value syntax, work in progress
- X-seq: zsh-workers 41697
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- Subject: Re: PATCH: [key]=value syntax, work in progress
- Date: Wed, 13 Sep 2017 09:44:30 -0700
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=aa/LaZ+P7364gETNtfCgoY0h1HFofw0SqCPVeNpj5cA=; b=EvIug7eL16txluZ6T6exrGuUYwLBh5SQIx7RzRuCUZsybdOGsj0gP2VgzYXpPcSRF8 gEeHKt55NsUn7bpGNIDoFLCDsOHmkEDIcOsIzpmuJ+LA2h1T6VQgs8T/0dR6tppDMAOE K9es6nNGP2Q8+s3OD3iT26VOa+BRNhu6Xx5Qe4ZURb+me4gLQqBD+DUnMry71pmXz2E5 /r31LVwoMgZtSFuOyobF8dAtHzlIKTDTzXbaPbf80mVlokqyzW7L/kvPjIhuBds2N4Ao heA3L3UqLYOUAiuVB9SkmY2huSivXCmkrVhsO7fbH+lSzZsawmCPSGipddH6LJqOMhSm BkaQ==
- In-reply-to: <20170913095338.25a469f8@pwslap01u.europe.root.pri>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20170911215115.6aa27dec@ntlworld.com> <20170912212519.3d873212@ntlworld.com> <CGME20170913071430epcas4p419e001f03aaccf99cfc9d5490524bac3@epcas4p4.samsung.com> <CAH+w=7bTW6Gjiq0mhnQUe9FAXaPjLD=NZqqRmZkiLS2CcxnLYQ@mail.gmail.com> <20170913095338.25a469f8@pwslap01u.europe.root.pri>
On Wed, Sep 13, 2017 at 1:53 AM, Peter Stephenson
<p.stephenson@xxxxxxxxxxx> wrote:
> On Wed, 13 Sep 2017 00:13:35 -0700
> Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>>
>> typeset -A x=([y]=2 [z]=1)
>>
>> and that's the only way to assign an associative array; if you assign without
>> the [k]=v syntax the parameter converts into an ordinary array. Is this going
>> to get enforced when KSH_ARRAYS and/or KSH_TYPESET are in effect?
>
> That's probably a good idea.
I would anticipate a number of problems with the function libraries
for cases where "emulate zsh" is not declared.
> By the way, the mixed syntax is going to be a nightmare:
>
> $ array=(* [100]=foo)
>
> is entirely valid, which means much more work
There's an easy way out of this: If the first element in the parens
does not use the [key]= syntax then none of them do. That's the only
way to make the mixed syntax relatively backward-compatible with
globbing in any case. (How DO you assign "all file names containing
an equal sign following a leading digit" to an array in bash/ksh,
anyway?)
> typeset -A hash
> hash=(key1 [key2]=value)
Either "[key2]=value" is a value, or this converts hash from an
associative array to a plain one. The more interesting case is
typeset -A hash=(key1 [key2]=value)
where the choices are that either "[key2]=value" is a value, or the
whole thing is a syntax error (see KSH_TYPESET remarks above).
In both variations if "is a value" is chosen then it has to be
globbed, which will probably result in a file not found.
Then we have all the worms in Oliver's can.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author