zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Zsh Hackers' List <zsh-workers@zsh.org>
Subject: Re: Typeset with array
Date: Fri, 19 Jun 2015 19:36:26 +0200	[thread overview]
Message-ID: <7337.1434735386@thecus.kiddle.eu> (raw)
In-Reply-To: <20150619123930.2688d9e3@pwslap01u.europe.root.pri>

Peter wrote:
> Here's where the Cunning Plan comes in: the spcial assignment behaviour

Firstly, this looks fantastic. Much of my initial basic testing seems to
already be working.

I'll mention some of the things I tried. Just in case there's something
you hadn't thought of. Some combinations aren't especially sane but
might want an error message.

  local -a foo=one
So scope needs to be handled first and array conversion later.
Similarly: typeset -i foo=(23)

I did something like the following in _git recently. It works
  arr=( one two three )
  local $arr
There is also
  local $^arr=foo
and 
  local $^^arr=foo
The nearest in bash would be:
  declare {a,b,c}=foo
which works, but not:
  declare {a,b,c}=(one two)

Bash apparently lets you use += with declare but it seems to be
meaningless because it is not using the value from the outer scope:
  $ foo=hello
  $ function foo {
  > local foo+=bye
  > echo $foo
  > }
  $ foo
  bye
  $ echo $foo
  hello
Ksh doesn't allow it. Printing an error in this case seems best which is
what you have: typeset: not valid in this context: var+

Bash allows array element assignments:
  typeset var[4]=hello
Zsh now prints "can't create local array elements"
Including when not in a function.

That could also be extended to something like var[2,7]=(1 2)

This is perhaps jumping ahead a bit but for completion, it seems we now
get -command- context after typeset. As long as -var- context is applied
inside the actual contexts, having -command- context otherwise for
typeset would probably work fine.

It seems that it is already possible to have assignments after nocorrect
so there may already be handling for this situation by copying whatever
is done for nocorrect.

Is there a reason why noglob can't precede assignments. That could be
useful.

Oliver


  parent reply	other threads:[~2015-06-19 17:41 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5578996E.3080700@thequod.de>
     [not found] ` <150610191427.ZM30841@torch.brasslantern.com>
     [not found]   ` <5579C247.1060800@thequod.de>
     [not found]     ` <150611183639.ZM32247@torch.brasslantern.com>
     [not found]       ` <20150612094237.338f79d5@pwslap01u.europe.root.pri>
2015-06-19 11:39         ` Peter Stephenson
2015-06-19 14:06           ` Peter Stephenson
2015-06-19 18:54             ` Bart Schaefer
2015-06-19 20:16               ` Peter Stephenson
2015-06-19 21:11               ` Eric Cook
2015-06-19 16:09           ` Bart Schaefer
2015-06-19 20:32             ` Peter Stephenson
2015-06-20  3:50               ` Bart Schaefer
2015-06-20 17:05                 ` Peter Stephenson
2015-06-19 17:36           ` Oliver Kiddle [this message]
2015-06-19 18:40             ` Bart Schaefer
2015-06-25  9:29             ` Peter Stephenson
2015-06-25 15:16               ` Bart Schaefer
2015-06-25 15:39                 ` Peter Stephenson
2015-06-25 16:08                   ` Bart Schaefer
2015-06-25 16:34                     ` Peter Stephenson
2015-06-26 13:51               ` PATCH: array slice Peter Stephenson
2015-06-26 23:07                 ` Bart Schaefer
2015-06-27 19:42                   ` Peter Stephenson
2015-06-27 20:09                     ` Bart Schaefer
2015-06-26 16:46               ` PATCH: typeset completion Peter Stephenson
2015-06-26 19:14               ` Typeset with array Oliver Kiddle
2015-06-27 16:33                 ` Peter Stephenson
2015-06-21 20:05           ` Peter Stephenson
2015-06-21 20:38             ` Peter Stephenson
2015-06-23 16:47               ` Peter Stephenson
2015-06-23 17:52                 ` Mikael Magnusson
2015-06-23 20:17                   ` Bart Schaefer
2015-06-23 20:21                     ` Peter Stephenson
2015-06-23 20:24                     ` Mikael Magnusson
2015-06-24  1:35                       ` typeset -p with assoc array (was Re: Typeset with array) Bart Schaefer
2015-06-24  6:03                         ` Bart Schaefer
2015-06-23 20:25                 ` Typeset with array Bart Schaefer
2015-06-24  9:14                   ` Peter Stephenson
2015-06-24  9:29                     ` Peter Stephenson
2015-06-24 10:35                       ` Roman Neuhauser
2015-06-24 13:00                       ` Mikael Magnusson
2015-06-24 13:20                         ` Peter Stephenson
2015-06-24 15:03                     ` 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=7337.1434735386@thecus.kiddle.eu \
    --to=okiddle@yahoo.co.uk \
    --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).