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 26974 invoked from network); 28 Feb 2023 08:47:54 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 28 Feb 2023 08:47:54 -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:To:References:From:In-reply-to:cc:Reply-To: Content-Transfer-Encoding:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=o5TLaaSXkKiMLaAtbk8+SL67pHAUevSRRYRC8Q/O/tQ=; b=UenU0s2jbbZci9HAOZZn9P2Yz7 rjBTLhDS7IDZS1uXp7DO7XlXZqsSLRaLYGfClaCfiDI4QWS7uDzhRgsZFKk2GaGirfa3CCCEyyvBs sKoHQ0tnQ8w08SCHnf9SeLWox/vGA0TNm/w6RR/fHncOthZ0EpZ018nlIlbbe1uRkbuvqAXPcRZvw YydUD4ShNPAovv0c737HLcmdI6QdSZ+AdBjAMdqFhM9VqZTfXI9ArmFgS3AjX4iYMF10ZrGtNTJJi DgFDgthOltjAFte+QDEACpXVxmnaXHmjsPb3y/iil0D8HNcE54zvHAr8ux2yCMXgQtNsjvfme82Lf 3X2LYPXQ==; Received: by zero.zsh.org with local id 1pWveK-0003cF-IX; Tue, 28 Feb 2023 08:47:52 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1pWvdm-0003IO-F8; Tue, 28 Feb 2023 08:47:18 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.95) (envelope-from ) id 1pWvdl-000FcB-Ee; Tue, 28 Feb 2023 09:47:17 +0100 cc: Mikael Magnusson , zsh workers In-reply-to: From: Oliver Kiddle References: To: Bart Schaefer Subject: Re: expanding nameref target? MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <60025.1677574037.1@hydra> Date: Tue, 28 Feb 2023 09:47:17 +0100 Message-ID: <60026-1677574037.450652@BS_8.Gg9A.ql-t> X-Seq: 51488 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: Bart Schaefer wrote: > In ksh emulation (and history disabled), I have this working: > > % typeset -n foo=bar > % echo ${!foo} > bar Supporting ${!foo} is useful for ksh (and bash) compatibility so that sounds good. There are also other forms such as ${!name[@]}. > However, that's pretty clumsy because of history expansion, so I'm > proposing the following for zsh native mode: > > % typeset -n foo=bar > % echo ${(?)foo} I would question whether it's really sufficiently useful to warrant that. I'm inclined to suspect that anyone who thinks they need ${!foo} has probably missed the point of namerefs. Unless they are writing something that is meta in nature to begin with like the describe-params function that recently circulated on the -users list. ${!foo} may give you the name of a variable that is hidden by a local variable so you don't want to rely on it if you want your code to be robust. So my view is that I wouldn't bother expending one of the few remaining flag characters on it. > As an extension (more by accident than by design but possibly useful): > > % echo ${(?)options} > zsh/parameter Doesn't that lead to a conflict for a nameref defined in a module - do you get the module name or the target of the nameref? Oliver