zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: <zsh-workers@zsh.org>
Cc: Daniel Lin <dlin.tw@gmail.com>
Subject: Re: PATCH Re: let unset array element remove compatible with bash
Date: Sun, 01 Jul 2012 15:23:10 -0700	[thread overview]
Message-ID: <120701152310.ZM28640@torch.brasslantern.com> (raw)
In-Reply-To: <20120701191526.50e2cf7d@pws-pc.ntlworld.com>

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.

I suppose we could invent a new metacharacter like Nularg that means the
embedded-in-a-string equivalent of PM_UNSET, but that seems a bit beyond
the scope of the discussion so far.

Or we could change zsh's internal representation of "ordinary" arrays to
use hash tables.  That might not even be too difficult as we already have
code to produce array representations of the keys or values of hashes,
we'd just have to impose an ordering.

I don't think that's necessary in order to fulfill the spirit of this
particular request, though.  Daniel Lin cc'd for comment in case he's not
subscribed to zsh-workers.


  reply	other threads:[~2012-07-01 22:23 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 [this message]
2012-07-02  9:11               ` Peter Stephenson
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=120701152310.ZM28640@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=dlin.tw@gmail.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).