zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: Re: workers/40626 (commit 6c476c22) causes multiple test failures
Date: Tue, 28 Feb 2017 21:51:10 +0000	[thread overview]
Message-ID: <20170228215110.GA15436@fujitsu.shahaf.local2> (raw)
In-Reply-To: <170228110424.ZM7827@torch.brasslantern.com>

Bart Schaefer wrote on Tue, Feb 28, 2017 at 11:04:24 -0800:
> On Feb 28,  5:03pm, Daniel Shahaf wrote:
> }
> } > So here's my question ... why would you ever attempt to append to the
> } > options parameter, empty append or otherwise?
> } 
> } To set multiple options at once:
> } 
> }     local -a options_to_set=( printexitvalue on warncreateglobal off )
> }     options+=( $options_to_set )
> 
> My point is you don't need append for that.
> 
>     options=( $options_to_set )
> 
> will do exactly the same thing, because it's not possible to delete any
> of the hash keys even if you don't appear to be assigning them.

I noticed that they're equivalent, but I think it's more readable to use
+= when setting values of some options and = when setting values of all
options.  That's because using = without specifying all options violates
the following invariant of hashes:

    local -a a=(...)
    local -A hash=( $a )
    (( $#a == $#hash ))

I suppose that's an argument in favour of turning "using = without
specifying all options on the RHS" into a runtime error. :-)

Jokes aside, backwards compatibility argues that we should make neither
case an error.

Cheers,

Daniel


  reply	other threads:[~2017-02-28 21:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-26  0:04 Bart Schaefer
2017-02-26  6:16 ` Daniel Shahaf
2017-02-26 19:42   ` Bart Schaefer
2017-02-27  9:31     ` Sebastian Gniazdowski
2017-02-28  7:45     ` Daniel Shahaf
2017-02-28 16:38       ` Bart Schaefer
2017-02-28 17:03         ` Daniel Shahaf
2017-02-28 19:04           ` Bart Schaefer
2017-02-28 21:51             ` Daniel Shahaf [this message]
2017-03-01 15:55               ` Bart Schaefer
2017-02-27  9:41 Sebastian Gniazdowski
2017-02-27 16:42 ` Bart Schaefer
2017-02-27 18:48   ` Sebastian Gniazdowski
2017-02-27 20:08     ` Daniel Shahaf
2017-02-27 20:38       ` Frank Terbeck

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=20170228215110.GA15436@fujitsu.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --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).