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,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 5009 invoked from network); 13 Jul 2023 04:06:39 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 13 Jul 2023 04:06:39 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1689221199; b=b2S7OLeLfDMAI3fSXZHWm+1vIB7GmPR3B0e7H5VUIOCC0W92E9hRX0D2HsSRVDuF1R1M30YB5Z SCAUb1C0aaohepyqE9HG7sLrjs1xF1KOU47V19TwzhrLaXFcxhVfT8p7e7ZqQgTEcLHYdx0H+O RFun52QbwwRFAt1Jfrw+xqK4mI4xlo6HE8D6gYusawn/d8DjN9dKFe6b+bCiFDB1hDev5YsUrB Rlo7DUVqZ31PEh++uXQNy2es6YRkaN11H3u48/88D9YPsEUbNC8w85Vp15S6CHz9ZzLOMiAMUl NnuzDke+cJ62p1G5XE58xrx32og/Vrnn9tezZgAQ/oRwHg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (snd01001-bg.im.kddi.ne.jp) smtp.remote-ip=27.86.113.17; dmarc=none header.from=kba.biglobe.ne.jp; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1689221199; bh=JzPPwC/eSIVNS5HVJPn1o/L5J8MWcxlubFwgQ/GPtYA=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:To:Date:Message-ID:Subject:MIME-Version: Content-Transfer-Encoding:Content-Type:From:DKIM-Signature; b=iNmTEEQOr2AbNixqWeVhWC77xfNuo55p4FWZ6RwgB9UoGPXAYDFFw7ua4PmiWQZoK0lvTLX6vv ApSUJl0L3zEe42j1G2qhggi5xTvM1SX9mKJACLwQbRl2eMxD4VsYRRRw02y3dlPolATYV+OVra qclsdaVkZNaMjjNaZ9RbqmP55E7N6sOJzbmIZ9mKA8++J5LiXd6jtLMEguEXfbottjrdvsEAPm MJbIQF8CLdl2JuSuW37426gIO4NxwMH+YdnPAPQIBNbuGklKXwDDCAc5WEpS/VoWZWkqpiQnaM 59jxAkv6upOoZwKKUtkMMhFJ/gDc1CQWWnClagx/uVdCkQ==; 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:To:Date:Message-Id:Subject: Mime-Version:Content-Transfer-Encoding:Content-Type:From:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=LRzUFui9PVLyFYXn9di5qESKMdMm0ij7nZ1kV+fdYGI=; b=OF+zxkzHJQ2UmR10CbpURcDBn9 ZZFtJ/LWtVjC6OL+9JSaWXZSYq7yxpmbMDZsYTvDq3jHRhAyAQNP/tedSSBwMMLxpXjFfGEW8Ep8t 7K2toZYunMX/yMysErg+v33bjCgaDKHUS6RvhxK/uTz1qEJ/sqc7YlKXuh7qxBSL5ewlVJyBNQmKP D5s7nVc2glHiFgezFsPn9rE2lJ/LmO59YhiGXGM3TiuKMQWsxpyGxffSZuTPaOeCR6t4gsGGw2gGZ 4YIXj4ari2Oe9/T4+i/QcWN0+LLbEKB9GNu6uQ7mryLNpi2G5K/MD7m3iIlddzk41yIR/UDQcQcFc e3EWRbdA==; Received: by zero.zsh.org with local id 1qJnbC-000GYZ-L5; Thu, 13 Jul 2023 04:06:38 +0000 Authentication-Results: zsh.org; iprev=pass (snd01001-bg.im.kddi.ne.jp) smtp.remote-ip=27.86.113.17; dmarc=none header.from=kba.biglobe.ne.jp; arc=none Received: from snd01001-bg.im.kddi.ne.jp ([27.86.113.17]:56033 helo=dfmta1009.biglobe.ne.jp) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1qJnaZ-000GE8-ER; Thu, 13 Jul 2023 04:06:03 +0000 Received: from mail.biglobe.ne.jp by omta1009.biglobe.ne.jp with ESMTP id <20230713040553504.YUCD.13671.mail.biglobe.ne.jp@biglobe.ne.jp> for ; Thu, 13 Jul 2023 13:05:53 +0900 From: Jun T Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: a few question about named reference Message-Id: <083477A3-A5D3-49B1-BF6F-D148C6BCAA54@kba.biglobe.ne.jp> Date: Thu, 13 Jul 2023 13:05:50 +0900 To: zsh-workers@zsh.org X-Mailer: Apple Mail (2.3445.104.21) X-Biglobe-Sender: takimoto-j@kba.biglobe.ne.jp X-Seq: 51928 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: [1] what does 'typeset -n ref' do when a variable 'ref' already exists? (1a) removing a named reference In the section NAMED REFERENCE in zshparam(1),=20 ... so to remove a named reference, use either `unset -n pname' or one of: typeset -n pname typeset +n pname followed by unset pname But: % i=3D10 % typeset -n pname=3Di % typeset -p pname typeset -n pname=3Di # now try to remove pname % typeset -n pname # this does nothing % typeset -p pname typeset -n pname=3Di # still points to i % unset pname % typeset -p i pname typeset: no such variable: i typeset -n pname=3Di The following works: % typeset -n pname=3D # reset to empty % unset pname % typeset -p pname typeset: no such variable: pname Just fix the document? (1b) converting a scalar into named reference In the first post by Bart about the named reference (worker/51360=E2=81=A9= ): > One difference from ksh93 is that you can't convert scalars into > namerefs But it seems we can convert a scalar into nameref: % i=3D10 % ref=3Di % typeset -n ref % echo $ref 10 I have no idea whether the conversion needs be prohibited or not. [2] readonly named reference % typeset -nr ref=3Di % typeset -n +r ref typeset: no other attributes allowed with -n % typeset +n ref typeset: ref: read-only reference % unset -n ref zsh: read-only variable: ref So we can't remove the readonly attribute (and will not be able to remove/unset it). Is this intentional? [3] can named reference be in 'unset' state? If typeset_to_unset is on, creating namerefs with and without =3D'' have some difference: % setopt typesettounset % typeset -n r1 r2=3D % typeset -p r1 r2 typeset -n r1 typeset -n r2=3D'' % echo ${(\!)r1-unset} unset So it seems r1 is 'unset'. But: % echo ${+r1} # or just "echo $r1" 1 % typeset -p r1 typeset -n r1=3D'' # now it is set to '' It seems resolve_nameref() in params.c resets the PM_UNSET bit. I feel it would be simpler to ignore typesettounset when creating a nameref.