zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk
Subject: Re: set -A
Date: Tue, 11 Feb 2003 10:38:02 +0000	[thread overview]
Message-ID: <3745.1044959882@csr.com> (raw)
In-Reply-To: "Oliver Kiddle"'s message of "Tue, 11 Feb 2003 09:45:38 +0100." <8132.1044953138@finches.logica.co.uk>

Oliver Kiddle wrote:
> I'm inclined to agree that this is wrong. It would seem more logical to
> me for an unset variable to be interpreted as an empty array when
> retrieved in array context. 
>...
> I've been aware of this for some while and had intended to change it if
> I ever have time to finish work on the parameter code. Would changing
> it break much? It would improve bash/ksh compatibility.

I suspect it would improve matters in the particular case of `[@]' --- I
see no occasion when someone would deliberately use that in the
expectation it caused "$foo[@]" to turn into a zero-length string for an
empty $foo of any type.  However, note there is in general no such thing
as `array context' in zsh, so we need to be careful with other subscripts.

> A similar thing which I find annoying is
> that local defines parameters to be scalar by default instead of
> leaving their type undefined causing similar empty element problems.

There's no such thing as an undefined type for a declared parameter,
either, nor is it clear what that would mean.  You have to declare it with
a particular type.  You need to declare it as `local -a' if you want it
to behave as an array.  I think the problem is few people have yet got
into the habit of doing this (though increasing use of += makes it more
necessary).

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


      reply	other threads:[~2003-02-11 10:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20030207000138.GK5418@msi.ld>
2003-02-07 11:53 ` Peter Stephenson
2003-02-07 16:08   ` Bart Schaefer
2003-02-11  8:45 ` Oliver Kiddle
2003-02-11 10:38   ` Peter Stephenson [this message]

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=3745.1044959882@csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /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).