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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 3650 invoked from network); 3 Apr 2021 19:48:44 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 3 Apr 2021 19:48:44 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1617479324; b=1cQMNWdukY19j2kJN3ipTsr6KtN1Dgc3RUl95qvIb7i55UlmGJ+pY83RuLmYuywA5QzIft/yGR Y6NwUIynqz3G5ZceRhvw/hYnLWGBjFXgSNMlrevnEq43g3Bga6LiouBp5FJsjvUhi6E628ZyV4 wDfP6uaMThpUKynDT4BwD9Abs6DgajBdLbF26UP6EzjLgABfEBPRuPd+ijaEaLQ53u5hX6WGn3 cwAt2qlxYJir2CngyLxfpagRc2+KJZJ+nYPocxAhFhRfvQRAlNgdrtc7dsBBUdgF10qTg8RjWw DTj6jmmHDeReMLL9lturUjgiv8CZYq7l4jH02xY8k1BL3w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (wout3-smtp.messagingengine.com) smtp.remote-ip=64.147.123.19; dkim=pass header.d=larryv.me header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=pass header.from=larryv.me; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1617479324; bh=U2ru7Pblw3J8lKS7PmbnmGirBqHXTbcyYd4U6z5ImVE=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Subject:To:From:Date:References:In-Reply-To: Message-ID:MIME-Version:DKIM-Signature:DKIM-Signature:DKIM-Signature; b=OaWv+3k1ZwrFIfFFdYTmYHFwrJmkDv4+iuFw3IsYE29fLoSriCBdZl2Pe19Cz44u4GFby+XZ8b tDgJwY/NfaxXlATCDdwFnacs/ip3OfRgNLowOI+QbkqAnYxZnyBKHDwrY07zoJR5/qseNt5dzR XtBCASqm/kyBKt83W7KKX8f+f3j2paqDneadtkLAKJyerWaKwnb1f/pCis/U6bBFDw09KfJRqh hECHjnzQxRlQIkENaw5SewJvNARVYYgPAalHvhaV/fY1q3hIHn0FDcjGTH49nLw0WuCiiQaaPQ 7IiPzPS58fkYjo5mXlg2tt3FXh0f6srRIge4PSBOK1QDuw==; 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:Content-Type:Subject:To:From:Date: References:In-Reply-To:Message-Id:Mime-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=uip/ae8q+rpSmWleTcHx8g2ypRBD76g4eDmjJ9YVXAQ=; b=WCi4dgTNVc1U76kidYosG0aj19 7GAZ3aT21ZrrZ5tQLMkirwB0JF1KW9gyjmMhMhKGI6OKmTsBWw6+9BdthWDa1WlMz54cSUGQofYHc 4bbiyxcO8h7pr3aBbjFyXReaCcppREAFHp6BwA4GJgaRPTs2ajpaF3N/k9SK5IWVtDjKKzK/Xa4ll 6kqwrq8N2LsmQhGBfN0eNJu12kQJuQr/ihweiLONEX/oT7rKhgScwfOdZ1BGCoAiMsRWQYQPsXaqI RmLg8opk/P+spvFaABiZ4h5WHk68qbSGgpQp/4IinJpIhPaLj9yWAHNrRg6vmVqDfTcX/0cSYsfl+ jkODMsGQ==; Received: from authenticated user by zero.zsh.org with local id 1lSmGB-0000KM-Lj; Sat, 03 Apr 2021 19:48:43 +0000 Authentication-Results: zsh.org; iprev=pass (wout3-smtp.messagingengine.com) smtp.remote-ip=64.147.123.19; dkim=pass header.d=larryv.me header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=pass header.from=larryv.me; arc=none Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:49979) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lSmFw-0000Ab-HW; Sat, 03 Apr 2021 19:48:29 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id D499DE09 for ; Sat, 3 Apr 2021 15:48:26 -0400 (EDT) Received: from imap2 ([10.202.2.52]) by compute6.internal (MEProxy); Sat, 03 Apr 2021 15:48:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=larryv.me; h= mime-version:message-id:in-reply-to:references:date:from:to :subject:content-type; s=fm3; bh=uip/ae8q+rpSmWleTcHx8g2ypRBD76g 4eDmjJ9YVXAQ=; b=vTSUuq88ef1PIRs5q8FZ9gyZNJdjMtENMU3p3DLYQL++cck b/UH95ANE0dbKLt7LcU4ytYS92RjDK8EpiqVaH3wvjgtvGSqfz+4v0/7jNiLiT0U iHNUMRqWZfIrGi8gnPrKqk/RgbYR8qar+BdugLOa7SkRyMRdkQFIDsZ3Gz0fLT2u JStIiQVlL2AwMPO235/jHuuOe246n2EbhE7djboJSsq2f4bb5fCFunpYtbUXDanR t2jbYusRZczg5DelN/ipzGoVG3g6QBA8tMa4hQG5gD7Ggd3a0HTrxSgX0ORlHd7O omh7X+wHlpzPdv0hgtYOJTSjv4Tb4HK7bVlcFVg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=uip/ae 8q+rpSmWleTcHx8g2ypRBD76g4eDmjJ9YVXAQ=; b=tNwiXKku2ECdpt/F4bicwN S9YiDsyR4aFlMfui6jW4hTnpCKP9zcxL+3To01JRX5t/9oeeW3LKb8Hte3+DK4Vi 39PrDX64/vC8yk47QEpq7zZyKfywsOG6xiGZq2iUcP5HZ6Iwm84oNhNxvVC3IFGf oycPbUsC+YhxMzWSnl1HWd9YnvnN3PrHRKSHaNoBD0929aQZZFW9d9mYd1WroL4f HdvorP7XpxN4G1mumeowBbShuUPFrw5D+JuyehSDl9zPBxyPclVsqZvz0AYD3YgY sixl+9oUt+ejZcyQDSxsixjMdd+77uc/nI5Hp4BrDxd/sHnKEbSE5TP5ITHnRC3g == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudeikedgudegjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgesth dtredtreerjeenucfhrhhomhepnfgrfihrvghntggvpgggvghljoiiqhhuvgiiuceovhhq sehlrghrrhihvhdrmhgvqeenucggtffrrghtthgvrhhnpeejfeehjefgfeeugeffgfefve dtgfekkeeujedvuefggeelvefgheekgfdvveeuieenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpehvqheslhgrrhhrhihvrdhmvg X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 24FE7A00073; Sat, 3 Apr 2021 15:48:26 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-273-g8500d2492d-fm-20210323.002-g8500d249 Mime-Version: 1.0 Message-Id: In-Reply-To: References: <20201218131815.25999-1-mikachu@gmail.com> <20201219091314.dxslsscyiqffa3il@chazelas.org> Date: Sat, 03 Apr 2021 15:48:03 -0400 From: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= To: zsh-workers@zsh.org Subject: Re: RFC PATCH: Sketch at :@ subscripting Content-Type: text/plain X-Seq: 48387 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: On Sat, Mar 27, 2021, at 4:27 PM, Bart Schaefer wrote: > On Sat, Dec 19, 2020 at 1:13 AM Stephane Chazelas wrote: > > > > 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]; > > The way to do this (syntactically speaking) would be with a subscript > flag. E.g.: > print $array[(^)1,3,7] > would change the interpretation of the commas to select a set of > elements instead of a range. I chose (^) because of symmetry with > $^array and to avoid confusion with for example $array[@]. > > I haven't looked into how difficult that might be to implement, > particularly in assignment context. > > Another possibility is to handle $array[{1,3,7}] specially since "{" > is already a syntax error in math context. > > Both of those options could apply to associative arrays, although keys > would need to respect quoting to avoid troubles with an embedded ",". > > > $ i=1,3 > > $ echo ${a[i]} > > c > > Here [i] is interpreted in math context so the comma becomes an > operator (the collision you already noted) so this becomes $a[3] > > > $ echo ${a[$i]} > > a > > This one is confusing and a bug ... it should be the same as > ${a[$[$i]]} but instead it's ${a[,3]}. I haven't tracked down exactly > what's skipping everything up to but not including the first comma (it > is not, for example, just dropping one character). bump vq