From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 564202137A for ; Sun, 11 Feb 2024 17:15:15 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1707668115; b=A6apXSQ2d7ajX66+tErC0o/til64GY0haK2WqGR4UPYFftN80yxfsMlu0jJFVu677RO2tIPyp2 DJNfUopyxw9TyBPSyX9C45qOuJ8gstG35bGGpCSt0GeSOKPDpb32VETgtwg6dpdw2RV0Ecael3 BEIfogDDCuNQDMfjwjo7LBDjUS6pk+8qYx7Mqzoxj3QA9XFVkECEYGKosd69XIeCra3EkYKlBr jQ1q6tHFm4ny8xp6bIXERj0A6WOH5WU/TQCWjQchhFljci40ZCr3Xp+whqGYCI0mDlVb3sqY0K 5qiO00abcgKOhKTXy0Bt3iAvvpvKSCAeNO3eFWhU79EbOQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f49.google.com) smtp.remote-ip=209.85.218.49; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 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=1707668115; bh=E7Mxd6BmjzYpT6dPyHacsXo93xtFqZ60M8TphgxbpMI=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature:DKIM-Signature; b=oF4BQnUqBNrxlTwnCIIQ63bDnNemEvClwMpCtk8UempUVQ1cOd8+Ag2Dsfpi5MMw5IP8gboCeq bM6J2I4rmF0nFey1ZHEXmRORZS9Mna5zrWgqVs2zvFZzWLufmiyaHTisLV2CNDup9X4oOUcF5c GC+qeWh1g0ah8aLq4R9eEhiRODotV8q8kFbLV2YLPtmlfQpWQsDm7VT3ab/CdKCp77jS1mxUpl ZoFDwgomowUyO5ov8aIuAU6Y6D5J1y/qfQE2gAcwXpJMbmofcLR0AcLiJ/TfxSxgb98yeoPlFw 57v0KPNYTm7qfNNKRKLv71q1lK6mXr+yXKuwZ6gn5QG5DA==; 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-Transfer-Encoding: Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=yZNkL/eeDA0zOYj+VqpJenjvQJbeBIgYG3quBINwdyY=; b=j7bGHJ3IdMlRF5eDgXCrpsGu3/ y2jBed+uPUjEjxTXi9uagPstltzkdk6xtGI11gomVHp85J1cprJha8wSnBAU8seezJozZ8eBxCMFk qNiKMe7hOVvdMkmeogNnP40jp4X5XnkJlBiyTt44TW1Ty/G84Eh0XrjreVcEWoXX00f19E/ecTaxf Yi2nNhgR8QgJuV82QtDdiOuNMfHbkNs+VNXyclbAlLttywpJhdJaXXoBgJEwqujtgig54Q06DcLZ4 ViZoJRuQ/xExZuD+B2LmHBD6W1geGWhjV/zAt36JOHqbwbexiNnlWZsr+aCvU7YjDufKDy/znl19D qXAwkjfw==; Received: by zero.zsh.org with local id 1rZCU6-0003yB-GA; Sun, 11 Feb 2024 16:15:14 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f49.google.com) smtp.remote-ip=209.85.218.49; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f49.google.com ([209.85.218.49]:45523) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rZCTl-0003fR-S7; Sun, 11 Feb 2024 16:14:54 +0000 Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a3c7cad994eso28935766b.3 for ; Sun, 11 Feb 2024 08:14:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1707668093; x=1708272893; darn=zsh.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=yZNkL/eeDA0zOYj+VqpJenjvQJbeBIgYG3quBINwdyY=; b=ZjzPmAarXVOT3eDViFKF8+xA2RvYi2j7ZfB/jN2I+fGPiw+AIV5Ec9QniN6WkzPsdu gfiVb9ZjbGwxWu2vfNfGOgVUEvtil4/hAqVsb2HjAUchgyC9tIwPl83g/6AzeBuZeG2g psdYumXMJV0kvKYGIqBKEnlpZ8FxnyYkPpfHnpZcpoRaLyhGdUG3BaFV/2G+CnMooyX7 4oWf1csndwp8FJAVFK5Q4Z+g534GefpEJyoepUyKG6j6j8mtwCymUFQYspLP+p/MA5A0 BJZWpJeEkA4r4U/mEHHqe88iDx9o4kt9GBPE8Fn4/SXgN/Nmzo+pvVUNuWhZYZBp89c3 Yvsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707668093; x=1708272893; h=content-transfer-encoding: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=yZNkL/eeDA0zOYj+VqpJenjvQJbeBIgYG3quBINwdyY=; b=veBa1nyHu/UmwezLU8DL+UMbLyBxUVOwAFyP4QwyGWuGrc5qG0PEjHDN+j6h+B4a9s PZrvfhsocDsqh9A0CIuwaRT71r2GnUwlV1joUhpVKseFjZvxgzfuqVqRwGOOPPY9yF+K LpmJ9bv3sVhgnCYc/SrVy89IKRMqysyC63VrJR2C2zAsTpldu1Mm/17uZQAAAWZN9qrg JGsEunOnNnRVEl/QL8F5jL6e+wrI/2Tz2X0BxPuMIA4zEw64UgsEOcW7rZzrjoCP2MjH XQg0VjMZAeXKbE7X8TKVmfmG+w5EEVjZTfAI2C5MKe1F8Cn6tERRMbsx0ym+MMmh8Fej f8QQ== X-Gm-Message-State: AOJu0Yy0I5pVzRDclVS9v+cD5fw3By1KpnkkcBJcj5iGXcP1B/B8vfSL GuchMVzpDceevvTGj6b9QCVq48ZFZYY0dc9XuSmmEcobGNe9yaC50kzpPi7PJKZgD2L9h6IHovH AfYNm9Dr4FPF6dqzCg2w9FBnyz3zyaVDZx17Iq5uVDe2foiY= X-Google-Smtp-Source: AGHT+IHfzqIFGLE8NxovU8jdjdWpOhzl8wmFNQLA3R4Hxgsin/lAnrvGdeqFk4WJPna7vrHr1ky38I3yuhCz5+HnjcI= X-Received: by 2002:a17:906:234b:b0:a37:478c:6021 with SMTP id m11-20020a170906234b00b00a37478c6021mr3838113eja.76.1707668092787; Sun, 11 Feb 2024 08:14:52 -0800 (PST) MIME-Version: 1.0 References: <67689-1675827940.088548@BxvG.D9_b.7RzI> <12608-1675903622.800470@Xj82.e3y1.svhG> <66045-1675975796.128039@FBF_.0yMO.Y8fk> <40726-1676098925.110777@U2kb.d0Pd.I9ml> <20240211070042.4j37hkgjjn3dfjqd@chazelas.org> In-Reply-To: <20240211070042.4j37hkgjjn3dfjqd@chazelas.org> From: Bart Schaefer Date: Sun, 11 Feb 2024 10:14:40 -0600 Message-ID: Subject: Re: [PATCH 1/3]: Add named references To: Bart Schaefer , Oliver Kiddle , Zsh hackers list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 52531 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 Sun, Feb 11, 2024 at 1:00=E2=80=AFAM Stephane Chazelas wrote: > > One difference with ksh93: if the target variable was not set at > the time of the "typeset -n ref=3Dtarget", then when ref is > assigned it may end up refering to a local target Hm. I think I can prevent that from happening (it wasn't intentional) but I don't know if it's feasible to actually create a new variable at the original scope, because of the implemention as a linked list of scopes for each parameter -- it's not clear how to insert a variable into the middle of the list. > It can be worked around with a typeset -g $1 before the typeset -n var=3D= $1 Is that really sufficient? Might the -g not select the wrong scope if the string $1 was passed down a couple of layers? Seems to me you have to avoid re-using a variable regardless, especially if you do typeset -n var=3D (create what I've been calling a "placeholder") and then assign to var in some nested scope. This may particularly be true of the "for var in ..." special case for namerefs. Something I forgot to mention before regarding "_zslurp_var" -- if you're going to a assume "typeset -n" then you can also assume namespace syntax e.g. ".zslurp.var" But the zslurp I put in the distribution was also meant to be somewhat backward compatible so I didn't use namrefs or namespaces.