zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: zparseopts default associative array
Date: Thu, 13 Feb 2014 08:56:18 -0800	[thread overview]
Message-ID: <140213085618.ZM26934@torch.brasslantern.com> (raw)
In-Reply-To: <CABABwVH+Yu-oFiE8OYkmNHxRGSwfYT8331oA0=0s9quom3CTGA@mail.gmail.com>

On Feb 13,  8:17am, Sebastian Stark wrote:
}
} Maybe I misunderstood something, but isn't my example the intended use
} of -K? Or is the condition "when none of the specs for them is used"
} really meant like "if one option is given, all other default values
} are emptied"? How would this make sense?

Yes, it really does mean that the defaults are kept only if NONE of
the possible options for the array are parsed.  Although it applies to
the default arrays, the intended usage is really with the =array form
as in this snippet of Completion/Base/Core/_description:

    gropt=(-J)
    xopt=(-X)
    nopt=()
    zparseopts -K -D -a nopt 1 2 V=gropt J=gropt x=xopt

In this example -V and -J are mutually exclusive.  (There seem to be a
number of unnecessary uses of -K in the Completion tree.)  Before the
introduction of -K, gropt and xopt would have been unconditionally
erased by having merely been mentioned in the zparsopts arguments.

Yes, it would probably make sense for associative arrays if -K retained
individual elements for associative arrays, but the implementation does
the equivalent of the whole-array assignment o=(-a foo) for both plain
and associative arrays because there is no useful way to do individual
element assignment in the non-associative case.  Unfortunately -K was
an afterthought added with the minimal possible code changes.


  reply	other threads:[~2014-02-13 16:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-13  7:17 Sebastian Stark
2014-02-13 16:56 ` Bart Schaefer [this message]
2014-02-14  7:55   ` Sebastian Stark
2014-02-15  8:37     ` 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=140213085618.ZM26934@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@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).