zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Peter Stephenson <p.stephenson@samsung.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: PATCH: [key]=value syntax, work in progress
Date: Wed, 13 Sep 2017 09:44:30 -0700	[thread overview]
Message-ID: <CAH+w=7a59aWuvx=wC4eDzx1LCvb7GmUciB_GmOp41q-E+x=pqg@mail.gmail.com> (raw)
In-Reply-To: <20170913095338.25a469f8@pwslap01u.europe.root.pri>

On Wed, Sep 13, 2017 at 1:53 AM, Peter Stephenson
<p.stephenson@samsung.com> wrote:
> On Wed, 13 Sep 2017 00:13:35 -0700
> Bart Schaefer <schaefer@brasslantern.com> 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.


  reply	other threads:[~2017-09-13 16:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-11 20:51 Peter Stephenson
2017-09-11 20:56 ` Peter Stephenson
2017-09-12 20:25 ` Peter Stephenson
2017-09-12 20:28   ` Peter Stephenson
2017-09-13  7:13   ` Bart Schaefer
2017-09-13  8:53     ` Peter Stephenson
2017-09-13 16:44       ` Bart Schaefer [this message]
2017-09-14 20:48         ` Peter Stephenson
2017-09-19  1:13           ` Bart Schaefer
2017-09-13  9:14   ` Oliver Kiddle
2017-09-13 19:41     ` Peter Stephenson
2017-09-14  7:03       ` Daniel Shahaf
2017-09-14 20:38       ` Peter Stephenson
2017-09-16 10:30         ` Daniel Shahaf
2017-09-14  6:54     ` 'typeset -p' of assocs (was: Re: PATCH: [key]=value syntax, work in progress) Daniel Shahaf

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='CAH+w=7a59aWuvx=wC4eDzx1LCvb7GmUciB_GmOp41q-E+x=pqg@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=p.stephenson@samsung.com \
    --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).