zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>,
	zsh-workers@math.gatech.edu
Subject: Re: Problem with associative arrays
Date: Mon, 14 Dec 1998 07:47:47 -0800	[thread overview]
Message-ID: <981214074747.ZM21619@candle.brasslantern.com> (raw)
In-Reply-To: <199812141055.LAA07255@beta.informatik.hu-berlin.de>

On Dec 14, 11:55am, Sven Wischnowsky wrote:
} Subject: Problem with associative arrays
}
} Subscripts for associative arrays are matheval()ed

No, they are not.  The code in params.c looks like

	if (PM_TYPE(v->pm->flags) == PM_HASHED) {
	    ...
	} else
	if (!(r = mathevalarg(s, &s)) || (isset(KSHARRAYS) && r >= 0))
	    ...

} which makes some problems:
} 
} % set -A a

You have to use `typeset -A a` to get an associative array.  `set -A a`
creates an ordinary array.  I realize this is confusing, which is why I
originally used a different option letter for typeset, but compatibility
with ksh requires -A.

} % a[foo]=bar
} % echo $a[baz]
} bar
} 
} There is no variable baz, so evaluating it yields zero and since
} numeric subscripts on associative arrays work, this yields the `first' 
} value.

This is all accurate, for ordinary arrays.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


  reply	other threads:[~1998-12-14 15:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-12-14 10:55 Sven Wischnowsky
1998-12-14 15:47 ` Bart Schaefer [this message]
1998-12-15  8:12 Sven Wischnowsky
1998-12-16 14:31 Sven Wischnowsky

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=981214074747.ZM21619@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@math.gatech.edu \
    /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).