From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7757 invoked from network); 19 Dec 2020 09:13:43 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 19 Dec 2020 09:13:43 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1608369223; b=TL3D8DEQ/zqYMma0foT9mGkyzBL9R+Zeismc1lTgxyiQbxIWxn7WkW8Cqo1vvvvhUdObBc+e5b Gd4aMrzhloWS0/jTTzKQ2RZkhnr9ZcmkhH9N8hL7KOMVIAUH73/atdtvif4Q9feHZQcxD+r09I UddyyDjlxYRnU/L4JI4SI5wO/83BjPQUDSXPYddHfnzKi6YvOUhXuhz9ySxLZ7fn13OSt2/IGV 4uMyc/pslSuOVegXZYmcwaQ//VkYX1qL+zNThO5C773l0BhusqaR2cOB2Q4U1AQGqCCWKt117d pTrTTfqwwRN80Ybs/7vdThUCmcP689FSU7k3ogLJRbbV+Q==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay8-d.mail.gandi.net) smtp.remote-ip=217.70.183.201; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1608369223; bh=mnLuMrRA1mW39+oJqvOBP+4esxR9xzu/610WEh3yiUg=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:DKIM-Signature; b=eaNYviXs+/mRKN6HZWdNRE1ZuOC6ailDWkW/Lz/xhGP4ZtP1iwf6Fw4QrNwJgWrV/siPqcpKro Nq1xUZrqckouTkBljNOhB2T/n2hgsLwKlCJtVjBbviONhdcjO/otbonoII5zcNNllxq8RWaUMB +Nwp9/q+Mvm9KZY+SmJexZkg+Aa8TSNubq1lkayS0QNjXjmSY8jd+CYsWbHTA/DfTwcDqqwRor DuVS/tcpEYX7A/JKq+pVvbbg9kDCdFD4uMe21KAJyCXOahxclsLcu6tOcX5hVy8hGTL2oWfsoX SLGRt2GXeGoBwo03exhpgmTu9fcgU+bXgexgGhb1eCYsVw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=8Ue8QwKt2hJqaokFqE2+N4GZ8EoFRQzkue+GqwuU4zg=; b=f1SZb26gY7zgLvLfg70pBydiT4 pGyU+ShCWlpLWWtBLKIOPIqxEwtVGgkhhR/NQ13FIcQioyGLUBlYT0ZswnrU58TZpyaS4odf8jjyN flzeb/vcZNEmBCDkUVNpc8DdOgoKbtMp3jtpdxWwb+suPkKc5jn2PZwPYG2/nyJ0KTZkkcr8mlYZ7 IMrfznjf6uH9Kv5H8wyqoq6zhqd/xA9nRVaiyaZ7h5G5zoHGQnTKeH5PviL13PfPvcKEi7pM0gogv lNls8dHGKxNaqw7M5v//cUQ0EpnhpIllp67C0c0XXc5MKHGgztb7sI7TUY7fBhgHfOlFnkGXAHMFl cvH3E5hw==; Received: from authenticated user by zero.zsh.org with local id 1kqYIx-0009xb-Mw; Sat, 19 Dec 2020 09:13:35 +0000 Authentication-Results: zsh.org; iprev=pass (relay8-d.mail.gandi.net) smtp.remote-ip=217.70.183.201; dmarc=none header.from=chazelas.org; arc=none Received: from relay8-d.mail.gandi.net ([217.70.183.201]:54443) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1kqYIf-0009ox-8S; Sat, 19 Dec 2020 09:13:18 +0000 X-Originating-IP: 94.10.124.211 Received: from chazelas.org (unknown [94.10.124.211]) (Authenticated sender: stephane@chazelas.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 17E711BF204; Sat, 19 Dec 2020 09:13:14 +0000 (UTC) Date: Sat, 19 Dec 2020 09:13:14 +0000 From: Stephane Chazelas To: Mikael Magnusson Cc: zsh-workers@zsh.org Subject: Re: RFC PATCH: Sketch at :@ subscripting Message-ID: <20201219091314.dxslsscyiqffa3il@chazelas.org> Mail-Followup-To: Mikael Magnusson , zsh-workers@zsh.org References: <20201218131815.25999-1-mikachu@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201218131815.25999-1-mikachu@gmail.com> X-Seq: 47748 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: 2020-12-18 14:18:15 +0100, Mikael Magnusson: [...] > The idea is that you can do this: > % typeset -a somearray=( 'data here' 'some words' etc etc 1 2 3 4 ) idx=(1 3 5) > % echo ${somearray:@idx} > data here etc 1 [...] Hi Mikael, I can't help but think that allowing to specify the indexes directly as perl does for instance in: print @list[1, 4, 2, 7..10, @idx, -1]; And in assignments as well: @list[@idx] = qw(new values here); would be more useful. It's unfortunate that "," is used for ranges in $a[1,3] in zsh especially considering that "," is also an arithmetic operator (btw: $ a=({a..z}) $ echo ${a[1,3]} a b c $ i=1,3 $ echo ${a[i]} c $ echo ${a[$i]} a ??) and that {1,3,{5..7}} otherwise follows the perl semantics (and extends it as it allows backward ranges). ${list[2 6 8]} in zsh wouldn't work as ${list[2 -1]} already means something different, but maybe ${list[2;6,9;${(j[;])idx},-1]} would? That would mean no backward range as $a[3,1] ATM is the empty list but backward sets would still be possible with $a[3;2;1]. Maybe another option could be $a[{1,4,{8..2},$^idx}] so as to reuse an already known syntax? Except that: $ i=(a b) $ echo {1,2,$^i}. 1. 2. a. 1. 2. b. $ echo {1,2,{a,b}}. 1. 2. a. b. Syntax would also have to be restricted to a[{...}], no a[{1,2}0] for instance. a[{${(f)^"$(shuf -n 5 -i 1-100)"}]=({a..e}) soon becomes awkward as well. There's also the question of a[1;5]=(a b c) a[1;5]=(a) ... Having a syntax that could also apply to associative arrays would be best. -- Stephane