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, HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20344 invoked from network); 10 Jan 2024 00:55:49 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 10 Jan 2024 00:55:49 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1704848149; b=ADVnE7LORLlKYfgcr7NM/AQDxM3D1JmE0L2QekbFK5dAyf+YwP2boDjhIPK+v7s2hxwSkGbdFB btV2oo7YPZnNBytR6Cio2BjIq/ThntFFLogfp3/789i+lRTunImthpAjTlahhH/nBRPmUIB3LR 34anRRpFQmwZYKOq+M+GxwZiKjX5WQ29EOPi8RkXTU5zWCfBCF7pFibe4eLqW486YyFxwy9um3 OR1VRvvZA7D+O0JycODlo8Xx4G+rTy4BQwHrJqo3RxuNZwJc4VoIs7j6/2rfRXe4QYLL4f2y9S QBfud12nA99ba67CcOgFcAVQkyDglxH12oGQFDzIAwCFTw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta02.eastlink.ca) smtp.remote-ip=24.224.136.13; dmarc=none header.from=eastlink.ca; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1704848149; bh=/00h5sWSb8QIGmFZ7ofWGttFI4S015N3FvTT5L6cvxA=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Content-Type:DKIM-Signature; b=WKEFRP/4im7kvhLhfiFgE7GCKYtJjDdx1tEJJdOjRLpsJ1P/ZstAdJjFlQDpz10crBVFIGFs55 r/uf6KiSVHeAVIBUEbe9skJsl2bLAHJ7c5qEB7ZHCxZwKq3vgdZAMXh+Cdwvgh1OJ4EMW54tvm XKn9dZ2S6MhKeA2xBmuiBPJCUVyZteBhYwiJyr0RpnNFO4sXLk6RrVPobjmjSxplfY/ycc7jSa RCqkQ43fg26G4FuELARymcmuY58zA3gfb2LDN5vwdM03hwE4mB+NG08xkwqFWgWk3a40roPrpN SlAp+FWqdlyFwf7O+bqPjckwd53cMnIWrAypJEpSjLh38w==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-reply-to:From:References:To: Subject:MIME-version:Date:Message-id:Content-type:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=WNGJkqxO3epy9vfGv6hQlTd1abtLM28MrD2CM02TksU=; b=sabCvw8LpTLneaTjuVWXhceIdW Y4/vaHhklpajCplVPIuF/BMtFtM5X598lPgRgN4Px+FfOZXCRW+2Dat25l3BKwm9MHcJOvo2EsIzX cxZRxC/lKo+X6pmNBAkBl1vGHMiRlCIb4TKb1XL4e7H4GASwh3K56ay0B6PpzPuYtNV/+2XVFFqld b6g9AFrTwSv2krPvHvDV3VwoSNrtwBhloxf3mu17ZIP6ZmIGnrhXV0fqEMMCkG0pXNbk/0YPXWJ4+ wA0Jr3EHYC+7a2sCNJxqiiuy4y55Dx8g7xZh71ky5uhUYz6kdaFZx+WJjqjHBsYE8r5eiNpTScQ2P 5Ue9KIyg==; Received: by zero.zsh.org with local id 1rNMsn-0002Yy-3e; Wed, 10 Jan 2024 00:55:49 +0000 Authentication-Results: zsh.org; iprev=pass (mta02.eastlink.ca) smtp.remote-ip=24.224.136.13; dmarc=none header.from=eastlink.ca; arc=none Received: from mta02.eastlink.ca ([24.224.136.13]:46055) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rNMrp-0001qu-R4; Wed, 10 Jan 2024 00:54:50 +0000 Received: from csp01.eastlink.ca ([71.7.199.166]) by mta02.eastlink.ca ([24.224.136.13]) with ESMTPS id <0S701QFYHT5VT510@mta02.eastlink.ca> for zsh-users@zsh.org; Tue, 09 Jan 2024 20:54:48 -0400 (AST) Received: from [192.168.0.11] (host-24-207-19-13.public.eastlink.ca [24.207.19.13]) by csp01.eastlink.ca ([71.7.199.166]) with ESMTPSA id NMrnrixtvAItUNMrorBp9D (version=TLSv1_2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256); Tue, 09 Jan 2024 20:54:48 -0400 X-Authority-Analysis: v=2.4 cv=NJYTuW2g c=1 sm=1 tr=0 ts=659dead8 a=e7T7DzMKK1R988ZCg0wLyw==:117 a=e7T7DzMKK1R988ZCg0wLyw==:17 a=r77TgQKjGQsHNAKrUKIA:9 a=gir0-LH0AAAA:8 a=wju7VXLmeKXh7detDUAA:9 a=QEXdDO2ut3YA:10 a=pGLkceISAAAA:8 a=HZGzHrJYU8Grx4HT9cQA:9 a=RZ7DYfeVyE7jKncX:21 a=_W_S_7VecoQA:10 a=lqcHg5cX4UMA:10 a=aLewGyoHDmJ4ULJHWpSz:22 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdeitddgvdekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecugfetuffvnffkpffmpdfqfgfvnecuuegrihhlohhuthemuceftddtnecunecujfgurheptgfkffggfgfuvfhfhfgjsegrtderredtvdejnecuhfhrohhmpeftrgihucetnhgurhgvfihsuceorhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrqeenucggtffrrghtthgvrhhnpefhteethfevgeeuvdelgefgvdevudefueduffdvgfelvddvgfdtieegueeuleeifeenucfkphepvdegrddvtdejrdduledrudefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdegrddvtdejrdduledrudefpdhhvghloheplgduledvrdduieekrddtrdduudgnpdhmrghilhhfrhhomheprhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrpdhnsggprhgtphhtthhopedvpdhrtghpthhtohepreerpdhrtghpthhtohepiihshhdquhhsvghrshesiihshhdrohhrghdpghgvthdqkghiphfrrghsshifugepthhruhgv X-Vade-Score: 0 X-Vade-State: 0 X-EL-AUTH: rayandrews@eastlink.ca Content-type: multipart/alternative; boundary="------------PvPubkcsHoZjVFSahVGd7Bgu" Message-id: <2546420c-deb1-4dd7-a0e8-7b9db463503c@eastlink.ca> Date: Tue, 9 Jan 2024 16:54:47 -0800 MIME-version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: proxy name for array Content-language: en-US To: zsh-users@zsh.org References: <41f9b4d6-8f4a-4220-a86a-b7ccf690bd89@eastlink.ca> From: Ray Andrews In-reply-to: X-Seq: 29438 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: This is a multi-part message in MIME format. --------------PvPubkcsHoZjVFSahVGd7Bgu Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024-01-09 16:21, Bart Schaefer wrote: > On Tue, Jan 9, 2024 at 11:00 AM Ray Andrews wrote: >> typeset -A body=() >> LIST=( one two three four five ) >> body[array]=LIST >> proxy=$body[array] # But name of array could change. > This whole business with body[array] seems irrelevant to the question, > because by the end $proxy is just the name of the array and $body no > longer enters into it. If that's not true you're going to have to > explain yourself better. I have a lot of functions that might have to work with any of several different arrays, each with it's own name.  The guts of the function naturally needs one name to work with so that name must be a proxy for whatever the 'real' name of the function is. My tests work ok so I can do what I want ... with eval. #2 - assignments don't indirect on the identifier to the left Yes, I sorta know that. I'm not the least bit surprised all those efforts failed. > proxy_assign="${proxy}[2]" > : ${(P)proxy_assign::=TWO} I had saved a snippet that looked much like that, but for the life of me I can't remember what '::=' does, and I didn't make a note of it at the time which is a mea culpa, and naturally it's impossible to search for '::=' in the manual or even online. Google for: " zsh  '::=' " and get zero hits.  Man I hate that. I'm not lazy, I try to do my own homework but there's no way of knowing where to look. Anyway I'll try that on faith. > The problem with that particular construct is that you're eval-ing TWO > as well as eval-ing ${proxy}[2], which though harmless in this example > could bite you later. Necessary quoting to account for that might not > be any simpler than using the extra parameter. Yeah, well I already know I'm not going to use eval if I don't have to. > > The perpetually-delayed next release will include "named references" > which change above issue #2 ... > > typeset -n proxy=LIST > proxy[2]=TWO > # Now $LIST[2] is TWO > Cool!  Pointers! That would make my issue trivial. --------------PvPubkcsHoZjVFSahVGd7Bgu Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


On 2024-01-09 16:21, Bart Schaefer wrote:
On Tue, Jan 9, 2024 at 11:00 AM Ray Andrews <rayandrews@eastlink.ca> wrote:
typeset -A body=()
LIST=( one two three four five )
body[array]=LIST
proxy=$body[array] # But name of array could change.
This whole business with body[array] seems irrelevant to the question,
because by the end $proxy is just the name of the array and $body no
longer enters into it.  If that's not true you're going to have to
explain yourself better.

I have a lot of functions that might have to work with any of several different arrays, each with it's own name.  The guts of the function naturally needs one name to work with so that name must be a proxy for whatever the 'real' name of the function is.  My tests work ok so I can do what I want ... with eval. 

#2 - assignments don't indirect on the identifier to the left

Yes, I sorta know that. I'm not the least bit surprised all those efforts failed.

proxy_assign="${proxy}[2]"
: ${(P)proxy_assign::=TWO}

I had saved a snippet that looked much like that, but for the life of me I can't remember what '::=' does, and I didn't make a note of it at the time which is a mea culpa, and naturally it's impossible to search for '::=' in the manual or even online.  Google for: " zsh  '::=' " and get zero hits.  Man I hate that.  I'm not lazy, I try to do my own homework but there's no way of knowing where to look.

Anyway I'll try that on faith.

The problem with that particular construct is that you're eval-ing TWO
as well as eval-ing ${proxy}[2], which though harmless in this example
could bite you later.  Necessary quoting to account for that might not
be any simpler than using the extra parameter.

Yeah, well I already know I'm not going to use eval if I don't have to.



The perpetually-delayed next release will include "named references"
which change above issue #2 ...

typeset -n proxy=LIST
proxy[2]=TWO
# Now $LIST[2] is TWO

Cool!  Pointers! That would make my issue trivial.



--------------PvPubkcsHoZjVFSahVGd7Bgu--