From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15634 invoked by alias); 1 Oct 2017 16:48:52 -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: 41800 Received: (qmail 9888 invoked by uid 1010); 1 Oct 2017 16:48:52 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-10.server.virginmedia.net 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(80.0.253.74):SA:0(-4.7/5.0):. Processed in 6.906516 secs); 01 Oct 2017 16:48:52 -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.7 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_PASS,T_DKIM_INVALID,T_SPF_HELO_TEMPERROR autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Originating-IP: [86.21.219.59] X-Authenticated-User: p.w.stephenson@ntlworld.com X-Spam: 0 X-Authority: v=2.1 cv=SeoKDalu c=1 sm=1 tr=0 a=utowdAHh8RITBM/6U1BPxA==:117 a=utowdAHh8RITBM/6U1BPxA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=x7bEGLp0ZPQA:10 a=q2GGsy2AAAAA:8 a=L98bBqk7m0JiFEsWGy8A:9 a=CjuIK1q_8ugA:10 a=z9dJwno5l634igLiVhy-:22 Date: Sun, 1 Oct 2017 17:48:37 +0100 From: Peter Stephenson To: Zsh hackers list Subject: Re: PATCH: typeset -P Message-ID: <20171001174837.748e2c8d@ntlworld.com> In-Reply-To: <170930171154.ZM21088@torch.brasslantern.com> References: <20170929205059.5fa7eb4d@ntlworld.com> <170929155533.ZM15802@torch.brasslantern.com> <20170930134851.503623ed@ntlworld.com> <20170930204613.3cb2be70@ntlworld.com> <170930171154.ZM21088@torch.brasslantern.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ntlworld.com; s=meg.feb2017; t=1506876518; bh=wmb/qWUQv7O4YnHmt92RxFFE71fizLwbNgxmS2iA6Qk=; h=Date:From:To:Subject:In-Reply-To:References; b=YDUhfSJS1fu72E4BVK5GAyk8801+o88tB25gqU8ewwDSFzXhTQDBxqYPSAH8Hy93B q1BUhN3iOesJouJxHJQjo+fVHtcOTacgXouVcIUhtGyYoH76BZc0W/guEetl4TwBf1 hULzpjoIXSGExUf7CRCEI7LNOomtFZnwP04b5VDAeuFWtjD8NWu/T28JnwWThlnrE7 +brXMTs4MY606+TBusI+5ffc6D9hoexJGa5wwurStbzzEW3FMmte1OV52fjwXNlKpZ mH8gZK5znWXKB0v0Y3NFceXtwmUq0z16pmY5KdreAS1Xp3Pay8EmL5EgbLAZV4i/ys PmXdAs2wx6zyQ== On Sat, 30 Sep 2017 17:11:54 -0700 Bart Schaefer wrote: > Hrm, this makes me notice that there's a useful case for typeset -p to > output the [k]=v syntax even for traditional arrays. Consider: > > % typeset -a onek=([1024]=something) > % typeset -p 1 onek > > We could skip the initial 1023 lines of '' if we used the new syntax. > On the other hand, we'd waste a bunch of bytes on [N]=... if the array > was *not* mostly empty, so most of the time the old syntax is likely > more compact. Unfortunately, unlike bash, arrays aren't sparse. So the intervening elements that haven't been set are identical to any that have been set explicitly to any empty string. Of course, that could be adopted as a convention --- on re-input the effect is the same, which is ultimately the key point. > } One other minor compatibility note: the existing typeset -p > } prints a space between the parentheses of an empty array. [...] > } I've removed this space for typeset -p1. > > Interesting: > > torch% typeset -p x > typeset -a x=( ) > torch% typeset -p 1 x > typeset -a x=() > > (I don't really care either, but somebody is probably going to notice > and file a bug report.) I only changed it because I was asked. Cosmetic differences between -p and -p1 are quite explicitly not a bug. I'll commit it as it stands (with a correction from Daniel). Hmm, maybe I'll make typeset -p0 the same as -p for consistency. pws