From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25145 invoked by alias); 13 Sep 2017 16:44:39 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41697 Received: (qmail 16028 invoked by uid 1010); 13 Sep 2017 16:44:39 -0000 X-Qmail-Scanner-Diagnostics: from mail-qk0-f172.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.220.172):SA:0(-4.2/5.0):. Processed in 3.085204 secs); 13 Sep 2017 16:44:39 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_SORBS_SPAM,SPF_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=aa/LaZ+P7364gETNtfCgoY0h1HFofw0SqCPVeNpj5cA=; b=EvIug7eL16txluZ6T6exrGuUYwLBh5SQIx7RzRuCUZsybdOGsj0gP2VgzYXpPcSRF8 gEeHKt55NsUn7bpGNIDoFLCDsOHmkEDIcOsIzpmuJ+LA2h1T6VQgs8T/0dR6tppDMAOE K9es6nNGP2Q8+s3OD3iT26VOa+BRNhu6Xx5Qe4ZURb+me4gLQqBD+DUnMry71pmXz2E5 /r31LVwoMgZtSFuOyobF8dAtHzlIKTDTzXbaPbf80mVlokqyzW7L/kvPjIhuBds2N4Ao heA3L3UqLYOUAiuVB9SkmY2huSivXCmkrVhsO7fbH+lSzZsawmCPSGipddH6LJqOMhSm BkaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=aa/LaZ+P7364gETNtfCgoY0h1HFofw0SqCPVeNpj5cA=; b=qcPrPM0B/NBrdIUjfpogCY29iZtb+chFXZQII4BJWN4WU34GieORm4WMEhHnUdasve HPfmF7xO5N3JnVfF1/YWdlQfF/C3AHCqaxzV3tjvsEy8cAut47FkgI5JWjKvri5lRE9N XXbjeQ9j4SqLWoWiY+FrPIrXNJSnKx6MayPBKoing+yqLPbQsdHhNKTBqa7VRAK1vlIt Y6C2YOhm3pvk/pg7/+UacVnA9KZry2lOsSkxQ4sQfVM/ZlXhY4vxIND0BcdcQqAUpSow iCnT8Og0mXW6RlIbww3st8K1NHn5HrYe9QicgXm9IyFzNEbEHVi3jZH2dVM3fdDd/hs9 oOwQ== X-Gm-Message-State: AHPjjUgiue2OqtfuufBlZ3bNZA3UWpAIgBo9H01yAKSNMUa51pxDGovQ 4wX8N/mdRqilB9naasxbLgaTakJKy3pAiNj9aUJiRQ== X-Google-Smtp-Source: AOwi7QCbGpA48ozNWOMeqo2HvzcoTWEPFYON7haVBLT+lyhXV5q5pJuJ1UIZxRuFgo9rfv65VhX6CaSdLKBfMr8uzsA= X-Received: by 10.55.35.69 with SMTP id j66mr26257798qkj.141.1505321071205; Wed, 13 Sep 2017 09:44:31 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20170913095338.25a469f8@pwslap01u.europe.root.pri> References: <20170911215115.6aa27dec@ntlworld.com> <20170912212519.3d873212@ntlworld.com> <20170913095338.25a469f8@pwslap01u.europe.root.pri> From: Bart Schaefer Date: Wed, 13 Sep 2017 09:44:30 -0700 Message-ID: Subject: Re: PATCH: [key]=value syntax, work in progress To: Peter Stephenson Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" On Wed, Sep 13, 2017 at 1:53 AM, Peter Stephenson wrote: > On Wed, 13 Sep 2017 00:13:35 -0700 > Bart Schaefer wrote: >> >> typeset -A x=([y]=2 [z]=1) >> >> and that's the only way to assign an associative array; if you assign without >> the [k]=v syntax the parameter converts into an ordinary array. Is this going >> to get enforced when KSH_ARRAYS and/or KSH_TYPESET are in effect? > > That's probably a good idea. I would anticipate a number of problems with the function libraries for cases where "emulate zsh" is not declared. > By the way, the mixed syntax is going to be a nightmare: > > $ array=(* [100]=foo) > > is entirely valid, which means much more work There's an easy way out of this: If the first element in the parens does not use the [key]= syntax then none of them do. That's the only way to make the mixed syntax relatively backward-compatible with globbing in any case. (How DO you assign "all file names containing an equal sign following a leading digit" to an array in bash/ksh, anyway?) > typeset -A hash > hash=(key1 [key2]=value) Either "[key2]=value" is a value, or this converts hash from an associative array to a plain one. The more interesting case is typeset -A hash=(key1 [key2]=value) where the choices are that either "[key2]=value" is a value, or the whole thing is a syntax error (see KSH_TYPESET remarks above). In both variations if "is a value" is chosen then it has to be globbed, which will probably result in a file not found. Then we have all the worms in Oliver's can.