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 F0C1229CCE for ; Tue, 5 Mar 2024 03:54:10 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1709607250; b=fCkzIUfDVI59ZxiaZiyafmkYd/dCOiUNKI/rf1iYdgZQlI0Pm8DmzeZf4bLUuOGwb5Vk5UG1eT mYtgDs7SzSDFnaKyWtbvkLhsVtKpf3bZN/mE66cpm+qRGKJaSN+c4zf7gTexCsslb8UWpebf1v 7CuHuOwBGs7wPQnSoSPQkPqJkYV9jvgHOMr4nH8T2oqEC/iiHo/Kz9SjHuq9W7nZZBRt+ERmox HXST23yJ//gR5pHPh2/FrZcOvSvnMLUdsPFkZt6Ym7kLDqLeJBx7T/zHhsgCuosliIbU6RcViD BmE/PcjXweCNd1PrJ2opB+G/H06f83VdNt3T7xK5Sy3idw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ed1-f44.google.com) smtp.remote-ip=209.85.208.44; 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=1709607250; bh=n37GEuQfEs2NsXR+dAU9QQ21bUAWCW8s8lpwgjaKaXM=; 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=gQFwJf7NGbgMcixp3P0qZlaOmHANMre8zY50O4BU3Dj1XpgM1ccC3O0kjBoN7t1sT5K0vhUmXp y3HiEKw6etkkjeWH/RIQ5cRtmdPEeSNWwroWu9lb90GGexSPk/LcNNABEoc80i07zVlV075t+1 aBgd/AK9afbdpx6PDkPxU70ql7K0JxBCcDLCLo6lzGHvYFn8kvky9I2ltP381m7RtBhQjzJJJR 5iUdRyBqtgrRuQOxWmfIETgATupE1/ecAqDVTxQ2gtiQR6ZAjOl/2ubFda7iBLrulblqNyWXdc svPsFmSNud6V4uMH/arTsYfPObMReZ5b+T8aHAMyiJMynA==; 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=XvzArXFXb3pI0H0zPlE+nb+cF28MC9GRRmr5UdaKGeQ=; b=nmbKbtlii7mfYtowtXvZLG5XSQ nlw61kHPmiFbgRNJyCQqfF7DQZt133ZP2R5ThN6/0hF93ATbLImWTradEMxB2jYfXaXboLh4qdjqX o7OPmYlEh+wm++zxOVVgT40i6WB6BeEqDBTpoeuJaeMfpS5Lih5v5NF2vQ4yY3NmFGeJW+aWmb0Ct 1AufbqRadgqL80SxmFyilwymjz8HdSkHZi+xpOXerrdxwg1newwKaM+FY4k39mmFg8RXRclJ/ITcH R7unly30upsRdn/KRnDCpHcQKBYaSpS5dbRF21VoYrvP0QAJ9HwjcVT9inrngZsBjBYDh/5nSwTWJ kbtWbKnw==; Received: by zero.zsh.org with local id 1rhKwS-0007TT-Ro; Tue, 05 Mar 2024 02:54:08 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ed1-f44.google.com) smtp.remote-ip=209.85.208.44; 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-ed1-f44.google.com ([209.85.208.44]:61727) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rhKvq-00078C-1p; Tue, 05 Mar 2024 02:53:31 +0000 Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-564fd9eea75so170304a12.3 for ; Mon, 04 Mar 2024 18:53:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1709607209; x=1710212009; 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=XvzArXFXb3pI0H0zPlE+nb+cF28MC9GRRmr5UdaKGeQ=; b=usZwzL72MELVaa+HbZg9MtOIx7Q1C7JhX9lRueeQ0CtVw5+1cXQp8L2o2AyieW15sm y55P5w5dTmrnPH2DOVZTJfqmzalOPL8/8lnea+WdQAaFF3nLKlZUa4ad5Z//PsF6BCdU raLsOk/rx2eMlsw3DB7OeJNcmuE/4LB7qo/IecsND054CLlYoekoc2NCGuzsb+nGu/KN imBI8UpVfImRtzwkhguSqtoDV/ly8PM4P6ETl0szKwzmUDfiNYowvQgdV9Igo59QE7NC MLFiR0pjx2LGzXH+huQBTWcoZvA6KQCidISsnAL/imNv2z5FXkJc517Tz0QJmTUFptpy zDGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709607209; x=1710212009; 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=XvzArXFXb3pI0H0zPlE+nb+cF28MC9GRRmr5UdaKGeQ=; b=Hg4GfpNVVh6U/bZzyCiVj/+yI7xGl7+z7U4hJFvKUTsbCFQJIbSgGqzrh0sb7LSTxj zvTFmtJXSmnART6d8cE3Z/d2E2jiQ3dHkL5YXE49mrRObHud/5iUGbPrrQWrBlopJLrL pOY/ksl54Omu6GxsSGy6CNDABMG2BZ5y5mNmKNqfITi+41huT+ASg4+Ck+UtQwMOJ8I3 FK9wnGyJC6doZASVoO2LlOgPyTC0IAD9kwS9zFMqN7PBqIw8OJye/jZBCoHgSppWkVZ6 0F5HrGa+xELG8fZzjN9gSxJhlNXM2d9e/Oqaq/6Pzqa42C27GOryVrRc/gZKLToeaVf4 NUHQ== X-Gm-Message-State: AOJu0YxgPIiwRtFdkEx47r66o3GH/WZZDI62H+IgmSGU7M2rEc59i68D iS4Lru3GQxzp3O6IMfR+umRLWcDBC/TTqvQ2hWxa9MeAKWzxcdIS7DC1HWrO3l/fKyAb4IluSRb U1ZJm0qPLynrz5iwntKE/BEG2slPT7byMHZhGNYRhkUXRwYiBDQ== X-Google-Smtp-Source: AGHT+IHq+P1esNLZAyhjoaSpoqb7uLxt3Y7VeIXclbsMC38omstq6SDs/WUHrQaZyP531u3+ub8Wrkti7LGxEShoa2I= X-Received: by 2002:a17:907:b9d4:b0:a45:a762:137d with SMTP id xa20-20020a170907b9d400b00a45a762137dmr343216ejc.60.1709607208963; Mon, 04 Mar 2024 18:53:28 -0800 (PST) MIME-Version: 1.0 References: <20240220210553.g6imt3op6zahz4pa@chazelas.org> <20240221201215.anpjcfav6na55gg6@chazelas.org> <20240301182238.tpyajwblbam5bxw7@chazelas.org> <20240303134413.74c7trikf73g5kjy@chazelas.org> <20240303202756.7axmzy6gkohza2ra@chazelas.org> <90920-1709600703.280388@Hl_Q.k_r5.OUBX> In-Reply-To: <90920-1709600703.280388@Hl_Q.k_r5.OUBX> From: Bart Schaefer Date: Mon, 4 Mar 2024 18:53:17 -0800 Message-ID: Subject: Re: Up-scope named references, vs. ksh To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 52677 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 Mon, Mar 4, 2024 at 5:05=E2=80=AFPM Oliver Kiddle wrote: > > Isn't defaulting to a scalar type fairly normal. Sure, but Stephane wants a global that's a blank slate for anything to be assigned to. I don't think we have a way to do that -- the way the implementation works in the absence of namerefs is to actually remove/free the parameter and create a new one. If there are locals pointing to the global via pm->old, and the global gets removed, all the locals are also destroyed. > A different problem I'm finding is with not being able to hide the > reference type of a variable in a called function: That's actually "correct" -- from the doc: When a _named reference_ is created with 'typeset -n', all uses of PNAME in assignments and expansions instead assign to or expand RNAME. This also applies to 'unset PNAME' and to most subsequent uses of 'typeset' with the exception of 'typeset -n' and 'typeset +n' I admit this is a little weird when the named reference is inherited from another scope. The most recent FAQ entry that I patched actually suggests using "private -n var" to prevent downward scope leakage of namerefs.