zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <Peter.Stephenson@csr.com>
To: <zsh-workers@zsh.org>
Subject: Re: PATCH Re: let unset array element remove compatible with bash
Date: Mon, 2 Jul 2012 10:11:08 +0100	[thread overview]
Message-ID: <20120702101108.7c07b233@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <120701152310.ZM28640@torch.brasslantern.com>

On Sun, 1 Jul 2012 15:23:10 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Jul 1,  7:15pm, Peter Stephenson wrote:
> } Subject: Re: PATCH Re: let unset array element remove compatible with bash
> }
> } On Sun, 01 Jul 2012 09:53:54 -0700
> } Bart Schaefer <schaefer@brasslantern.com> wrote:
> } > So the patch below makes
> } > 
> } >     noglob unset foo[x]
> } > 
> } > work properly.  If x is an existing index (or valid slice), it is cut
> } > from the array as if by foo[x]=().
> } 
> } Do you mean that?  That's not how bash works, it doesn't cut the
> } element, just remove the value at that index
> 
> I do mean that; this is the closest zsh can get to the bash behavior, I
> think.  Bash represents arrays as linked lists of position-value pairs,
> so it's possible for it to have an array with a hole, but zsh uses real
> arrays.
> 
> It'd be easy enough to tweak the patch to put an empty string into the
> element instead of splicing the array, but then it'd be inconsistent with
> bash's expansions of ${foo[@]}, ${#foo[@]}, etc.

Hmm... I'd have said putting in an empty element in was the least
surprising thing to do, at least in the short term.  I don't think
shifting an array so that the numbering is different mimics the ability
to have only certain elements set to any great degree, there are too
many other cases.  If we ever did add the ability, the effect would be
to remove elements that currently appear as empty strings --- so having
the array index shifted would then look wrong.

It's a bit hard to give a definitive answer because, with the
current underlying behaviour, neither meaning of unsetting an array
element actually adds the ability to do something you can't already do.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK



Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


  reply	other threads:[~2012-07-02  9:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAPg-njyehwyETKY4KGdFV8u_ZwkMku-G9xVi7d7PpU9rZhdPDA@mail.gmail.com>
2012-02-22  5:01 ` Bart Schaefer
2012-02-22  9:52   ` Peter Stephenson
2012-02-22 17:28     ` Bart Schaefer
2012-02-22 20:19       ` Peter Stephenson
2012-07-01 16:53         ` PATCH " Bart Schaefer
2012-07-01 18:15           ` Peter Stephenson
2012-07-01 22:23             ` Bart Schaefer
2012-07-02  9:11               ` Peter Stephenson [this message]
2012-07-07 17:02                 ` Bart Schaefer
2012-07-08 17:50                   ` Peter Stephenson
2012-07-01 22:29             ` Bart Schaefer
2012-07-02  7:36           ` Bart Schaefer
2012-02-23 10:58       ` Peter Stephenson
2012-02-23 16:23         ` 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=20120702101108.7c07b233@pwslap01u.europe.root.pri \
    --to=peter.stephenson@csr.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).