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 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 31600 invoked from network); 28 Feb 2023 17:56:07 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 28 Feb 2023 17:56:07 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1677606967; b=NEPQpXUuHeE6vc04FfDLJmPiPn3+bKDCmo9keQpPGXYOvUHm5olJMv5e6Vwa93N/U3wKQLHl33 EyjHIwuc4o5Oq5G1LojwZwywmimwQItPiOnDLj5kT+MrMIquoVV9RxLTOOUBgvdDGlbkLQSslN 5zie1TSVwcIthOCVqvSuPCV8mmKWOr5sT55kPJpk108F79QDLaE40Rm2Mp2ef52v4EE+PWkQz/ lg3VSc0+XJM0oOyFLbqpm/U7k/K/Srt9DihoxFYKpjNvWhBiKed9h/ccJvJBEmzhfcEegPKrUW fsgzNg44PDTW2WaI377STTaKULrzhIfPqd8NaYsItcWW5g==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ed1-f47.google.com) smtp.remote-ip=209.85.208.47; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1677606967; bh=tK69Jk3Pz+p/eO2gllj8tc1d7FIc0KUBFjWHxNi1eQg=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=obsurMJ+ucgdCA/E+TduzpVEhUAAMnIzY7THjUf7K7BNT3nWgyIbFxfOXOzhibsTHwbWhyDdBW 4IVdbHLezjgOiggpR3Xgz3hgKTgi+HnU6QRUnouddCXzaMcAGD6oAckhlESiGEYxLh2+0ra2XF yTplDgDMDQSSfTOHZOUIzVLk88W6gAw29imAgNgCN8zp9xcea7ojjei89sO+r5wh4FO/Bo0+Gx R6dpe76Iiz3A943EKyikeJvAR6DrjlNJYdzc6wkvwYRs2iffnWmUGu8V9rxeoUmTNhslkvPxFs 4XSlMKpmcaoG2KtbjkpTz3dsZR61GJ9U22wG/SgZRnCUIw==; 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:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=/oCjE+BIGtjbXF5yg/lnXib1E4cUJbHtN6UXa7q9KMg=; b=Zh6qjeM8Rjl+PZgxne9PZ8pKyK L60mHGkqMv1F44QKlxPscGkTDwyhwTM8zdyZXnR0Kn8dbAbPSZd+K9Rgxm9C1KXyHiRg/sc1Vp2er ma/yMcUvxElrNBiVMjXMjm4go0H8mFAoXlZl6Y40iP3n8GRYFvl+nrtxPaiqK8IkcLAX87qDCCsyi yrp+g8f2bFXg5TeXw/cOoM1mg5bAa6HoZpblbspByDYAeuyhgHKOAG/wGVdGa1BZMw2eOq7WS3i4E tUf7ikMM981ANDVSBBvX5vEsQmocnrZsewljM70deEFK4djK8jIfKho2g3IMwXhDpy220bgQdH4oX dumG4F4g==; Received: by zero.zsh.org with local id 1pX4Cs-000Jxr-Iu; Tue, 28 Feb 2023 17:56:06 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ed1-f47.google.com) smtp.remote-ip=209.85.208.47; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ed1-f47.google.com ([209.85.208.47]:35505) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1pX4CJ-000Jen-52; Tue, 28 Feb 2023 17:55:31 +0000 Received: by mail-ed1-f47.google.com with SMTP id ee7so43591499edb.2 for ; Tue, 28 Feb 2023 09:55:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=/oCjE+BIGtjbXF5yg/lnXib1E4cUJbHtN6UXa7q9KMg=; b=CVNcKuk8RYBRi0gVbW7ZM3zcOLJrBPLBEJTE+uPwD8VEZlhUrAFGniDNzVX755063Y 15ugHcq9N29oAweiFYzZnp3NioEf8HVwOoxktUi2Uv2X81aNMtNQ4uIMRDcEzp6ng8DX 9PSJydinax8i1sjvRsFfpjCL4wxDyFTcIiZf34XISJA9kPC0na1M1vfktCH3anFJ/buJ G884HVnN2VZO3eKU9PimJfrirYcC2ag+28hMJj/WgRvMmd60MGjdZqH4aiGCiILM9oNl Npxg7XzVMbnRFEmmGy+d4sw5O0u2aZ8gOEIoQAnNb9aK7aXra5DP20hxEO12xIwxU220 wZ0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/oCjE+BIGtjbXF5yg/lnXib1E4cUJbHtN6UXa7q9KMg=; b=wPWCwgW6wG7xYxFAgNWEfwE6uDr4468lzxSokm33DgPEBdROVCwUflDbRWggssvPGR nP/m6BB3v7d5ZthdfbWE7Pob8CxSAi8oZr8wKI0thhhor62B4dbtgNKHt5K2PgQORMCM WZOQt7REZy9urD52MYdIam4b8vkWKSewscTPfWIEnQnlQYL+73alZPSvnU9PY06PFzPL wzjIUCQuxsNoFE0fsCFTyyWbxNZmfPnJgbqhIKOH1G7FLZFPXV2tp8aWlPJnWshvYD8w yXLUwAJtq9HileZDnBwS0iiFUtVn+yp6m9rkouSdFnp/2xLF2rc2/Gc7/CnrVXTIHFDX ZJiA== X-Gm-Message-State: AO0yUKXeQWdGH8QU38yOkiN2dpdS2P7E32ypUZWUKXyhTMqYAp5Pr4Pa kwWTqOnc2Ulhs2ohHdOToeinNX8jXkJASX3To3uELw== X-Google-Smtp-Source: AK7set+WRCrWdP6YXnYNMYyxkoTbcLdjRO7Y8botldVERpVOXDL4jMjCzZWJ4qFOCawm04d9JiUAvuu4WaodVMgDL0s= X-Received: by 2002:a17:906:b4a:b0:8b1:30eb:9dba with SMTP id v10-20020a1709060b4a00b008b130eb9dbamr1690416ejg.6.1677606929609; Tue, 28 Feb 2023 09:55:29 -0800 (PST) MIME-Version: 1.0 References: <60026-1677574037.450652@BS_8.Gg9A.ql-t> In-Reply-To: <60026-1677574037.450652@BS_8.Gg9A.ql-t> From: Bart Schaefer Date: Tue, 28 Feb 2023 09:55:18 -0800 Message-ID: Subject: Re: expanding nameref target? To: Oliver Kiddle Cc: Mikael Magnusson , zsh workers Content-Type: text/plain; charset="UTF-8" X-Seq: 51495 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: On Tue, Feb 28, 2023 at 12:47 AM Oliver Kiddle wrote: > > 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[@]}. There are some significant differences between bash and ksh regarding ${!...}, I have a patch for subst.c that documents this in comments. The simplest one is that ${!scalar} in bash works like ${(P)scalar} in zsh, whereas in ksh it just substitutes the parameter's own name. We already supported ksh ${!foo[@]} for associative arrays, I bolted nameref handling into that code path (in addition to the zsh flags path). However, that's explicitly (and commented-ly) enabled only in ksh emulation. We don't support fetching the array of (normal) array indexes anywhere, I haven't tried to add that. > > 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. It does seem unlikely to be something wanted during an interactive session. How about if I leave it with just ${(!)foo} instead of consuming (?) as well? > 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 I presumed Mikael had a use-case or he wouldn't have asked about it. It seems odd to have it available but only usable in ksh mode (e.g., ${!...} is historically a synonym for ${(k)...}, but that doesn't make sense for namerefs). > > 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? You get the module until the feature is loaded, and then you get the target of the nameref.