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 10220 invoked from network); 7 Feb 2023 00:57:07 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 7 Feb 2023 00:57:07 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1675731427; b=R3+39TlLj4J/t+XeThNOqwpmnm6w91R93FUIqORFwKPo1wG7Mi+NyGzpvFCzMTuKxodm6PILeI /x1IcBMYef/ZKKQJAACG/AXUpTWe6d+4jbLpHsjgxx0Ize1pVf/yRoai3Lxs3D0WNAG3KFk0rU NlKY5mjCnGmgmPFXw/TwcKFBohnCWp3vtPXNbI7qHFJMTrJB0WQj81/HflRN9Psafws2aOCOjK enMx1xiUYuaNqNtueavz8048/sNw8pFti1vShu9FvFOwptR2vDoPll2nrOyyD7d6VHWjxVtcW0 b1/ev6ZWmUT9lV+xMkbjOAHNnjTfA2gudCKu2Wt4PmWnFA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (wout1-smtp.messagingengine.com) smtp.remote-ip=64.147.123.24; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm3 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1675731427; bh=KAaQ6mqBtFodVD/dY/+QsgB8X+ikZQ63Cj/OUciaCeI=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:To:From:Date:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=c7sYUTE1jcgUApaxMsHt2xTPR0DxcgXCGvFsRkvHsxCC6v2WTK6Y2Ead8k/u7WoHHg62eK2qUa 5DTj3QTtP/+UTZohspReoyyjl3RgaZvK2oC0UHB8NXrbqgdtJaru/OZebIY58+BuRyPzEfO3wX /aH3UnEO2vpmblbKmCEbCAaNSmuMXTcZeDTeWWB1x3X7oiucBCRDMSV3lz3lFN3mB7D3mUKvph DQnsaLLXz22Hv/0GBnwL/9ZZ5q0Cc1QTnw7we1b3sdntN/dRMdZEXrTBdV+E/cbRVZ6GFopKXK 0yqEEhgW5Guvso3+vXnJynpYCyCzKjLz6rgPf+Aqyt1YNw==; 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:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=G43HgkoBNQQsCUh1qqReaQJVKarY1vkCP15ydEMeVJE=; b=I3AawkpcKkjQao0ruaTl7T/6Hv 4LE5bRWtPdPR4HHL8uBpiXlsOn+dOnzeYlmUaiTvN5huBDsfIV9f75jA2UMdmniAlYiABmpcgZajb 25cHxQHsQcpmh5cEsobN7Babrddrp2o94/sjgaETetOoXUTPp+G9XgulbIkrep20UIs51c+4Gnzsh RpTJKHTLcjNIMgfV36jAE1wdh5/0wMtgy+fgpyjmPhTQ4Tj0U178tngJVBRb9JBA6WekuPObFr0IA hgGbo2tRqUCFeOLRlKBOOZbfH+ikqF5fM1bJ+TBpi7awX/wlS67eShrJ9bt543GemV6vKjcAsCm5/ Nf6nejpQ==; Received: by zero.zsh.org with local id 1pPCIE-000POq-Mx; Tue, 07 Feb 2023 00:57:06 +0000 Authentication-Results: zsh.org; iprev=pass (wout1-smtp.messagingengine.com) smtp.remote-ip=64.147.123.24; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm3 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:43709) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1pPCI1-000P4w-Rx; Tue, 07 Feb 2023 00:56:55 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id B17DE3200985; Mon, 6 Feb 2023 19:56:51 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 06 Feb 2023 19:56:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to; s=fm2; t=1675731411; x=1675817811; bh=G43HgkoBNQQsCUh1qqReaQJVK arY1vkCP15ydEMeVJE=; b=IijAkuGK+62CBQ9uEczt4UvFcuaBLml4ncYVLx6Lp BLGfZ9R5nGisG5+zJENuB/TxbKRJI9PVgLtgdAQX+vlr/jlmNvCqzOm1v1dYhD+N MELpDurvtfvjFSLUQJuxvwVPo9z3leNkeN8jQo4RLGF0DsTRzBVTbwcWQv0lUZEG dK1PA6+N4ZC9Vog2Xxo8i91gw5O4RTaNNnlqGs/htx9mo5+ir1fMnBEZ8MVl6jIw +D0V40kJX0fwm1wqUmrMp4axOPHBtNT7t8ujOHCw6xijCaKo1qp/HApzrwq4uNa/ icOzLmMoLkZyoIlg1brHjrxgcbvxKT0RNHFhwyvfFO5Qw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1675731411; x=1675817811; bh=G 43HgkoBNQQsCUh1qqReaQJVKarY1vkCP15ydEMeVJE=; b=a7WELSK2vZeELqskk Pce8OkDu374GbdLxs8um14SHsDxKl2OmMAuion4LTkGQASzPDX86wB6Psce3/1aY P8l0f2CbcNin6ZyyjNGKOnPlHaEKr1GOqIq3kft9MFs+BjHZQEC9TIRbeCX58vL5 IIEYOwC9BBXfhGscVuVRBTslLBYKcBNLo1EBPIUzgNEAbLkeEOpzkRFBM2xxkd7Y lF4LqfCV07D6Y+m0IdwK+ZAVbWMwsrxS+VuCK1l+9+ed0wvI7kJVUec4MCz+Vxs6 +LqLaUsH5Ds1SOfMxgPQl+LrCNNhHEjya2WUMNPUzXMrHGkGCXowpZwBN4pcS3is 9ehaA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudegjedgvdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggugfgjfgesth ektddttderjeenucfhrhhomhepffgrnhhivghlucfuhhgrhhgrfhcuoegurdhssegurghn ihgvlhdrshhhrghhrghfrdhnrghmvgeqnecuggftrfgrthhtvghrnhepgfekgfefjefgvd dvgfdutdelleekvdefteeitdduhfevveevudfhvdevfeefvdeunecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepugdrshesuggrnhhivghlrdhshh grhhgrfhdrnhgrmhgv X-ME-Proxy: Feedback-ID: i425e4195:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Mon, 6 Feb 2023 19:56:50 -0500 (EST) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1000) id 4P9l800ZkMzn5; Tue, 7 Feb 2023 00:56:47 +0000 (UTC) Date: Tue, 7 Feb 2023 00:56:47 +0000 From: Daniel Shahaf To: Zsh hackers list Subject: Re: [PATCH 3/3] Documentation for named references Message-ID: <20230207005647.GA5789@tarpaulin.shahaf.local2> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 51368 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 on Sun, Feb 05, 2023 at 18:26:50 -0800: > +++ b/Doc/Zsh/builtins.yo > @@ -2037,6 +2037,20 @@ To initialize a parameter var(param) to a command output and mark it readonly, > +cindex(named reference) > +cindex(reference, named) > +The flag tt(-n) creates a em(named reference) to another parameter. > +The second parameter need not exist at the time the reference is > +created. No other attribute flags may be used in conjunction with > +tt(-n). The var(name) assigned-to may not be an array element nor use s/assigned-to/assigned to/ > +a subscript, but the var(value) assigned may be any valid parameter > +name syntax, even a subscripted array element (incuding an associative "incuding" > +++ b/Doc/Zsh/expn.yo > @@ -1523,6 +1526,77 @@ Include the unmatched portion in the result (the em(R)est). > +subsect(Named References) > +cindex(named references) > +cindex(namerefs) > +cindex(reference variables) > +cindex(parameters, nameref) ⋮ > +Expansions of the form `tt(${LPAR()t)tt(RPAR())var(pname)tt(})' expand > +the type information of var(rname), unless var(rname) is empty, in which > +case `tt(nameref)' is expanded, or when no variable var(rname) exists, "in which case the expansion is `tt(nameref)'"? > @@ -1545,12 +1619,16 @@ substitutions; the nested substitution will return either a scalar or an ⋮ > +When both a named reference and the `tt((P))' flag appear, the named > +reference is resolved before `tt((P))' is applied. Add a test for this last sentence? > +++ b/Doc/Zsh/params.yo > @@ -626,6 +627,49 @@ find the programs in tt(/new/directory) inside a function. > +cindex(named references) > +cindex(references, named) > +texinode(Named References)(Parameters Set By The Shell)(Local Parameters)(Parameters) > +sect(Named References) > +Zsh supports two different mechanisms for indirect parameter referencing: > +ifzman() > +example(tt(typeset )var(name)tt(=)var(rname) > +tt(print -r -- ${LPAR()P)tt(RPAR())var(name)tt(})) > +ifzman() > +example(tt(typeset -n )var(pname)tt(=)var(rname) > +tt(print -r -- ${)var(pname)tt(})) > + > +The `tt((P))' flag method is older and should be used when a script > +needs to be backwards-compatible. This is described fully in > +ifzman(zmanref(zshexpn))ifnzman(noderef(Parameter Expansion)). > + WDYT of documenting somewhere in the manual namerefs are new in 5.10? > +When `tt(typeset -n )var(pname)tt(=)var(rname)' appears in a given > +(global or function) scope, `tt(${)var(pname)tt(})' refers to > +var(rname) in the scope of the tt(typeset) command. This differs > +from ksh93 where the scope used is that of var(rname) even if the > +current var(rname) would be found in a surrounding scope. > +em(This is a misfeature.) Does "This is a misfeature" mean "This may change in the future to be compatible with ksh93"? > +acts as a placeholder. The first non-empty assignment to var(pname) > +initializes the reference, and subsequently any expansions of, or > +assignments to, var(pname) act on the referenced parameter. > + > texinode(Parameters Set By The Shell)(Parameters Used By The Shell)(Local Parameters)(Parameters) > sect(Parameters Set By The Shell) s/Local Parameters/Named References/ Cheers, Daniel (public service announcement: we have *.yo syntax highlighting for Vim in our tree)