From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22172 invoked from network); 14 Dec 1998 15:51:26 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 14 Dec 1998 15:51:26 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id KAA06999; Mon, 14 Dec 1998 10:49:10 -0500 (EST) Resent-Date: Mon, 14 Dec 1998 10:49:10 -0500 (EST) From: "Bart Schaefer" Message-Id: <981214074747.ZM21619@candle.brasslantern.com> Date: Mon, 14 Dec 1998 07:47:47 -0800 In-Reply-To: <199812141055.LAA07255@beta.informatik.hu-berlin.de> Comments: In reply to Sven Wischnowsky "Problem with associative arrays" (Dec 14, 11:55am) References: <199812141055.LAA07255@beta.informatik.hu-berlin.de> X-Mailer: Z-Mail (4.0b.820 20aug96) To: Sven Wischnowsky , zsh-workers@math.gatech.edu Subject: Re: Problem with associative arrays MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"nVtZ-.0.Ij1.rDJTs"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4773 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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