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 18246 invoked from network); 11 Feb 2023 03:05:36 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 11 Feb 2023 03:05:36 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1676084737; b=IzLjwmopgCRJ7rGdE0RztXTq0QEQVVgBhzLFYRsw0B7eCpsq0kpsyzKgPe0RA58PrORWt+Pxm/ Q6E56lV4BG3Imf05F84a+Vkvhl7ENlOyhqubON1TFf3LLcinOjecue7QeB65LjzXCzPwcrxlKm nlLQp7gHS5LvpWKw61qG2gU2U/V8pctv10rbZLRoGuW2eiDVht3buaNJIivTFAFWAIQVxvb9dX EizbnSExvaOoqwJ7Z96Nt63kiZRpB9BVx2afMLbh12YkDu3M6G3ELE6UbY5AOZqaM1GZSLl6js BWibeyQ4OJ1Ws4FeN+YX6iSgj86LouFESZDEwXb8m7mTWw==; 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.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=1676084737; bh=W5rNYxJxtlDqKOJmC+0jKemloTdVHGj2mpVQuu6DwSQ=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=lVb2Sf1sbpSh6D3sgMQuDq7oKbagc/HnkkaP+Xq3uCmR5pF7/CjShFyzThrBJxpOXSrwewl/Qh M9kQIg1QQd2XLitNtuGoqWTKs1r21JUjujS1ji7z1xorCcKY9kWkcZ8t3w3exUQlAO04oga33F n2jURe8yla8lWitsWH+K07asipMnxTRJ/NX7aWqe8SZYrdSgCtRtqG07lrbYAQEhtkHioReoAZ ymg0dv+J7hHtdmL4UlfPks98h5lq+XrqYW4kXoiH/ly6G2CAokHcPQgASwkR0omH97n2ui3spL +NfzWVbFQDsmy5XxCWc85qLlR1u8zJU/dYXcoL+jG62euw==; 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:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=wVyO0Y2e3JQss2pJ8WAcfQhYrip/diCGaGe9wVh9kg8=; b=pR9vJ4iV1ysv8zTzUE4C+vZaZc SLcNWCy++NI4QHa/ZgMB80DdNlAqQK6BT3b7p6fQCuhNPvhQ8hKyi6qL1f3SjyHA/idy8yfh1Gs4X VqlQ5ahBCFo4PR/Pv20w6qE2upQTofYnQOMQRNpq/gyzIp78y97EIs2PJtp1bfogPxb74GAifTjpS YJrgnt5jLvP8E0I29YYGa+Dc9kU6rJffXda4vHjUVxGz7uP1msLNMPdcBYa7h90dAcD9o7kTha39t phNiVu+6DBDdYSZtt1ZYWwHexFu25p7pwwFuPeIHa0qWoFlGLn8/d7P5MnE3ox2ALUEimvRN+Xexm rlQfJWyQ==; Received: by zero.zsh.org with local id 1pQgCk-0006yw-Jt; Sat, 11 Feb 2023 03:05:34 +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.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ed1-f44.google.com ([209.85.208.44]:33729) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1pQgCK-0006i4-05; Sat, 11 Feb 2023 03:05:09 +0000 Received: by mail-ed1-f44.google.com with SMTP id l12so6617652edb.0 for ; Fri, 10 Feb 2023 19:05:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=wVyO0Y2e3JQss2pJ8WAcfQhYrip/diCGaGe9wVh9kg8=; b=EFV5wRzEV3TA29DEnsbo5IDQUnlhwlUvcMfajlDcUPJcNLdplMvD0LZFAo/fgAbOgQ imNQ8MZd5gs5L3E+UCQAPvjbpu6QM6EV2noIYDKqdoJAzT6XmKsjBh3ASQD+AfIBXdom Tnc19MMpJavCSrMz9qATBhNbBv1jYX2+8fT97LiL8zfkuX4GPjG9uoqLcuBmifTRBOGQ bmntxsoWKZDGV7LmISGLBbdU+7npkgLskqKHhGxufOg0n7wv909UNXKFrE8xdP9ek8fD lVeaE1tyWhXPco/m47wEJTuH5c4oxKCg0RX5L8R7UlTkIpMj9hOdnJn9MSi2B+tQowUo z/WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=wVyO0Y2e3JQss2pJ8WAcfQhYrip/diCGaGe9wVh9kg8=; b=VrXWwsjSJBmdmLAJNONiG7ivNzmEES7RZ6Z+37LjU7KBS0iAHw506UfBC5jxovnv0u LYvnrUpcGA7wvLTtGsT0PbGq3e74sQAoVZnXLydXbB7ne25b2XpXh1HsMGwHxKDoLxGc au5e6pHsd641R+VosCusZrywLTuYz1dkodmANMu5su8cOEFj0SaX9LARVm4+8Yt+TTMc /aNyoACR/BD/KcJkitxL912vC9UlxAYiC2YdafWXIUYUKF12V23dpBTyg8MbAh9iSuWE PCdgv83YQSbGrI502d3J5oqOCiQ3PkYZ+XWfwfIM/GeBGZ62lme2t5o7wVwhOH2t62lQ r+5A== X-Gm-Message-State: AO0yUKWLTvGTp2YNflxZ3cDmykMiFuMoo0ziWG0LTdQY9+GWfUYWNrZJ Badmb+V8lAZ9jsFPBCR8ipAQ5ymG4+5wp0CjQnNUOpKh3VoxRrgn X-Google-Smtp-Source: AK7set9ZCzxMojL0EAbSFIfiIYVfINJ1vDzxgaz3CgL8hyhP7IULPJMlNnxuqZyAvLA2cW3n9atGPphCVbkF19Q3XT0= X-Received: by 2002:a50:c308:0:b0:4ab:4dc7:574b with SMTP id a8-20020a50c308000000b004ab4dc7574bmr852631edb.3.1676084707359; Fri, 10 Feb 2023 19:05:07 -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> In-Reply-To: From: Bart Schaefer Date: Fri, 10 Feb 2023 19:04:56 -0800 Message-ID: Subject: Re: [PATCH 1/3]: Add named references To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 51394 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: Closing in on this, I think ... remaining decisions on which input would be appreciated: On Thu, Feb 9, 2023 at 3:07 PM Bart Schaefer wrote: > > > Ksh prints "global reference cannot refer to local variable". > > At what point does that happen? Upon the assignment ref=var ? At the moment, just toying with this, I have it erroring when EMULATE_KSH, printing a warning when WARN_NESTED_VAR, and otherwise silently creating the down-scope reference. Thoughts? Perhaps WARN_CREATE_GLOBAL would actually be better here, or maybe check for either one. > Relatedly, what should happen on any failed assignment? E.g. > > typeset -n xy yx > xy=yx # OK so far > yx=xy # Oops, invalid loop > > Should yx become unset, or should it remain a nameref with no referent? This probably doesn't matter except at the command line as the referent loop is otherwise fatal. > > When relying only on dynamic scoping, it would be good practice to > > define all the namerefs to passed parameters as early as possible in a > > function to reduce the risk of a name clash. > > If you were going to put that in the doc, where would it go? Options are: - under Named References in Parameters - at the description of -n under typeset - with the scoping example in Expansion - in a new section under Functions > > > validate_refname() is calling parse_subscript() ... would further > > > examination of the accepted string be sufficient, or something more > > > needed? > [...] I meant, would examining the subscript string in the C code be sufficient. > > > It might deprive us of many clever tricks but parse_subscript() could > > gain a flag to disable anything questionable like command substitution > > and math evaluation side-effects. parse_subscript() is already a bit of a hack, it sets up its own context and invokes the lexer. A flag such as that would, I think, require plugging in an alternate lexer, hence my question about doing a simpler examination of the string.