From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15379 invoked from network); 9 Apr 2000 22:12:53 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 9 Apr 2000 22:12:53 -0000 Received: (qmail 27450 invoked by alias); 9 Apr 2000 22:12:41 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10600 Received: (qmail 27430 invoked from network); 9 Apr 2000 22:12:40 -0000 From: "Bart Schaefer" Message-Id: <1000409221231.ZM5523@candle.brasslantern.com> Date: Sun, 9 Apr 2000 22:12:31 +0000 In-Reply-To: <0FSL00K3NUBW5N@la-la.cambridgesiliconradio.com> Comments: In reply to Peter Stephenson "Associative array index." (Apr 6, 6:09pm) References: <0FSL00K3NUBW5N@la-la.cambridgesiliconradio.com> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Subject: Re: Associative array index. MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Apr 6, 6:09pm, Peter Stephenson wrote: } Subject: Associative array index. } } I'm sure we've had this discussion but the behaviour is still inconsistent. } The lexer and the parameter code disagree over the handling of associative } array indices. Yes. This is a known problem, because I didn't change the lexer at all when I added associative arrays. So the lexer still parses the stuff inside the [ ] mostly as if it were a math expression, and the substitution code just checks in the simplest way possible whether the brackets are balanced. If we're going to change the lexer for this, we might want to consider whether to handle ksh associative array assignment syntax: $ typeset -A foo $ foo=([a]=x [b]=y [c]=z) Which is equivalent to zsh-3.1.6+'s % typeset -A foo % foo=(a x b y c z) } I'd prefer to do it the way perl does } it, which is if you want quoting you add it yourself. The current way of } doing it is supposed to be like a double-quoted string, but it isn't, as } this example shows. The problem withthe "if you want quoting, you add it yourself" style is that it conflicts with long-standing array subscripting practice. Perl has syntactic differences to distinguish normal and associative arrays; zsh doesn't (and can't if it is to continue acting something like ksh). But the "as if double-quoted" style could be made to work better. } I should offer a prize for anyone able to extract } the value of } foo=("]" ouch) } by direct indexing. I don't suppose ${(v)foo[(i)[^ -\\\\^-~]]} counts. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com