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 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 17807 invoked from network); 9 Feb 2023 02:04:48 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 9 Feb 2023 02:04:48 -0000 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:Message-ID:Date:Content-ID: Content-Type:MIME-Version:Subject:cc:To:References:From:In-reply-to:Reply-To: Content-Transfer-Encoding:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=2BkypeIG6xIPbfW9/HRiUD/pYrJJdNf7xhjiggEpO6A=; b=HudLg1eFH8TorcNSkYY4/4xMFt oYtlPv+EVw8j5hCikhU2E3739o75l+XVrSvMQ9zM55iuFnfKrs4lhSZwNXmTRKcbHz+fpbnYybbqA jI9YqWyEyFP30hZYIlfD1atQkEsRBC6gGLlI81tkC/3tTYXqAv1H7wG6uKtD3ouQ+JhpWLjk4Dngu gX5l+u7iFIXgBFvLF9qvRh9dvH5Vxz8N8MWWRc7ZkmIktdpQFOVaeuNu/ysTuZaEL+72wVQlV/mIf 37WbbZ6ATtV946iJjTwHKT58NxGiIPeoQzCtdvwazfV2qt50ep0z1bACY74BUWawg2+sHZPEU8odJ /rl75+CA==; Received: by zero.zsh.org with local id 1pPwIp-0007qv-Nf; Thu, 09 Feb 2023 02:04:47 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1pPwFB-0007TT-2D; Thu, 09 Feb 2023 02:01:01 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.95) (envelope-from ) id 1pPwFA-0006jP-AN; Thu, 09 Feb 2023 03:01:00 +0100 In-reply-to: <12608-1675903622.800470@Xj82.e3y1.svhG> From: Oliver Kiddle References: <67689-1675827940.088548@BxvG.D9_b.7RzI> <12608-1675903622.800470@Xj82.e3y1.svhG> To: Bart Schaefer cc: Zsh workers Subject: Re: [PATCH 1/3]: Add named references MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <25877.1675908060.1@hydra> Date: Thu, 09 Feb 2023 03:01:00 +0100 Message-ID: <25878-1675908060.317862@x_tj.49MY.g4Qe> X-Seq: 51386 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: This isn't a self-reference because the local levels would be different. And "self reference" in the error message should be hyphenated. typeset -n ref=var foo() { typeset -n var=ref } foo foo:typeset:1: var: invalid self reference With -g it would be, however. I wrote: > On the subject references to array elements, it does seem both powerful and > dangerous that subscripts are evaluated on reference. The subscript This is fairly sane: typeset -n ref1=arr[ref2] typeset -n ref2=ref1 echo $ref1 zsh: math recursion limit exceeded: ref2 This seems useful: arr=() typeset -n ref=arr[1,0] ref=4 ref=5 Similar: idx=1 typeset -n ref=arr[idx++] echo $ref $ref This is where I worry about security: arr=( 1 2 3 4) typeset -n ref='arr[$(echo 4)]' echo $ref typeset -p ref # it was only evaluated late thanks to quotes Maybe the code should have a safer mode for subscript evaluation. This could be useful but it is asking for trouble. Also can see this being useful: str='one two three' typeset -n ref=str[(w)2] ref=zwei We already talked about this error message. But now it is a substring. export ref export: ref: can't change type of a named reference Oliver