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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 2437 invoked from network); 3 Jan 2021 02:38:37 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 3 Jan 2021 02:38:37 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1609641517; b=vksMVMZu51klFNYB1+HLwja4kK8gmJIhbzNieGfmy+VOK8/Jswi4Dda/g/QiWO349X9kujpHcU rAKxLhXDp9Xyhxk+bi/b/kgsSX+CFWnGSmSQOzAOaWuYgCbRdELtL8xLDYb5I88Oe0cq+s2sZp t91TXwUe53MhmYGt04zeBPrvZee5I1/9gWQj9Q66lgp8AIYeSbgqoTyh2mU0Zorn79kCxk5Bzk cGQBEB3J/poh58HEtTht/pfe/kLo2K6zh9KIG2kXkK2b2b/qPpb9iDiYtNxJX37Hz8Bow2y1EC +zf5+m21r3gCRT2GC1am9SChKSif23uBU2LXQ+5pBPvuRg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-wr1-f51.google.com) smtp.remote-ip=209.85.221.51; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1609641517; bh=pvst8J1YATlhEmG0Aq3gIz6GZ6S+3rPC3DuOQy9/g2M=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=wV6fJdTQZ9zRU61W+yjZ3PcH8FoMgmcsN/5DZqJneZfhS9UhJLplIjhRVnUFFpmJWOgR863wGT GlxMDrgIT6Z48ArU5G5wzVto5Tl70atvl6dtgs+gQAhNdeuZtuzb4LzhX2jSgXS23VvGJc+AlR BRLVhvekUmreMedn+8XY88rtfPwziBQv+2e1S+ZlXnq/cj1i7Yqqy4G451gGmBoRxcpaNXxsdQ ta6f2l9Biso1sVEwxdZxT6P6f+ueYF9w0cyb19bJseqY4vip5KFpYnKTaDs/fTlDBiLu7n+1n8 6znlAWCp2jkVHrReiinuPwd8Ug0iG15+n+5CR+q7UNTAEA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=eEd9Wvvg3iY8sru7SBsDN1h816ntPsSA54Yy6JGCQiQ=; b=g4wwAZDsJZ9QHB649qFHigZku5 APk8CFZB1DIklOg/YcJ/WK/52QtxUk+z+q7D/ClIjYwxuRXtSKFyixGEwOoeqvhuu074ZEucaKmLx qddWUgOUxKvhBJyE4Akkrob3GSdqXqFIOLrHkkf0xYj67Z/HmU1LbpnJS9Yc5ulR+qjzeaUC5C/+E 0BkunZTQtktqvmKD9pAx51pKgniskUHQ/cNqtouVsdk+wr/K2ANRFQojf4WAMbaRP+2XuZj+igJza VVQ9ZYVPmryAJkceFkRKlqljLiFhMeyS+J2edusYyssyl1/mRb8UI2WX3JcFvgPbmwzdUUkuuyrxL nPw5kF3A==; Received: from authenticated user by zero.zsh.org with local id 1kvtHw-0008yV-FW; Sun, 03 Jan 2021 02:38:36 +0000 Authentication-Results: zsh.org; iprev=pass (mail-wr1-f51.google.com) smtp.remote-ip=209.85.221.51; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-wr1-f51.google.com ([209.85.221.51]:39305) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kvtHd-0008op-4a; Sun, 03 Jan 2021 02:38:17 +0000 Received: by mail-wr1-f51.google.com with SMTP id c5so27435949wrp.6 for ; Sat, 02 Jan 2021 18:38:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eEd9Wvvg3iY8sru7SBsDN1h816ntPsSA54Yy6JGCQiQ=; b=MOozdxztvanVEnObqxWDt6LTBMWvUbozAZ+eIKJZkvozNfRVgNMyUzPWQrfj9pza1u lchVUHrjAxZdX2AwLxZx0yMZTGmroO6ZlVh1Hi/1gk4NdFRjS1rpauLPm6kXzdrbvYwr Nz9HuGiyBjBwhxeHCDmXnmMGgstr5Mc7XeYjF+/r8iBMAyicJrJdg7rc2TyCSCUjQujc rZgR7jOW05/RBJ9V54j6NJjpXK0ZBLJIiWWsqIfwCJDqXDteerZJOZeT0xdTOLH8Rz1X Xq0nYMeEYG29qdrNytCdDpFB0mlqWsUb9/Ei0I6iUMzbthiTdKzygxgrWgPQaEuZLd4e OwEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eEd9Wvvg3iY8sru7SBsDN1h816ntPsSA54Yy6JGCQiQ=; b=X4ZW/NbxbzE8hO5PVFWSfxsDhFg3LSz/hl+EgFX8CmeL6oVi2NyVGKkQlYxAwltekj zdxq499bikI982Fzl876YCPIN+Y49pYkx9vJ+EJkMJnq9S0nZ+P6Z0rSaw8YnSWRj9D8 HsuQuO3YpCRhQBZmZDifEO9vHBDGFVpR3qXXo+ioyITpLj6ckWHQOMR9c96LFCxwhavO uOmxhxgsfPidSgKGduo0Lwku5GRBdjZxUbCysl5rzXALI0yWvYSX7xZfQd5fldq0BZAx tnlNhRYhPXMeS+m/kBEInCcGkPVK7jVKCz0w1hVsGyUsDC0SFi5F6Rw4NRLWKbCbp1rY XXcg== X-Gm-Message-State: AOAM532wnDOUxxR6ZCAjfe3v+M8rmwxNHploZT8PjOi0VxZP/0lmDSjo /EfeHWQIucpWq/6C7tOCd6iDOA/xAuoZQgDqSNUChg+Q4q/I/g== X-Google-Smtp-Source: ABdhPJyx8shzkPi3l6PSnOy8hjjZQjbuuJywV8mRiNI7JSRiGZ/glapyoSx2xNXanigQxjUqbbbc6GL6tsdTL5c3rT4= X-Received: by 2002:a5d:4f0e:: with SMTP id c14mr74052777wru.84.1609641496791; Sat, 02 Jan 2021 18:38:16 -0800 (PST) MIME-Version: 1.0 References: <20201228221342.136199-1-felipe.contreras@gmail.com> In-Reply-To: From: Felipe Contreras Date: Sat, 2 Jan 2021 20:38:05 -0600 Message-ID: Subject: Re: [PATCH] declarednull: rename DECLARED to NULL To: Bart Schaefer Cc: "zsh-workers@zsh.org" Content-Type: text/plain; charset="UTF-8" X-Seq: 47791 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: Archived-At: On Sat, Jan 2, 2021 at 7:18 PM Bart Schaefer wrote: > > On Mon, Dec 28, 2020 at 2:13 PM Felipe Contreras > wrote: > > > > This way the logic makes more sense: > > > > typeset var <- NULL(on) > > unset var <- NULL(off) > > var='' <- NULL(off) > > > > NULL means: declared, no value, but still valid even with PM_UNSET. > > > > No functional changes. > > This is now getting a little bit weedy since only the names are under > discussion, but ... Yes. In this particular patch that's the only consideration, but I'm using that only as the starting point. I'm still unsure about the rest of the logic, but I haven't checked all the cases of PM_UNSET yet. So, yes... For now. > if we go all the way back to the original > discussion about this, the point was that > > typeset var > print ${var-unset} > > should output "unset". Correct? Yes, but that's only *one* of the considerations. It's still not perfectly clear what "typeset -p var" should output. Using "${var-unset}" is using loaded language. If we use "${var-foo}", then yes; 100% under agreement. > Consequently my thought was that PM_UNSET should be assigned for that > case. Using your terminology above, NULL(on) implies UNSET(on). To > me, that means that if there is a bit pattern named PM_NULL, it should > include the bit pattern for PM_UNSET. In retrospect I could just have > used PM_NULL instead of PM_DECLAREDNULL but I was seeking to make it > obvious that there were two bits in the pattern when it was used as a > mask. I mean NULL(on) imples "${var-foo}" returns "foo", yes. > As one last stab at this, since neither PM_DECLARED nor PM_IMPLIED is > satisfactory, what about PM_DEFAULT ? And scrap PM_DECLAREDNULL for > just PM_NULL. > > #define PM_NULL (PM_DEFAULT|PM_UNSET) > > This yields > > typeset var <- NULL(on) <- DEFAULT(on), UNSET(on) Makes sense. I think it's debatable whether or not this is really "unset" (what "typeset -p" var shows), but OK. > unset var <- DEFAULT(off), UNSET(on) <- NULL(off) Nope. The value hasn't changed, it still has the "default" value. Now it's 100% sure it's really "unset" though. > var='' <- DEFAULT(off), UNSET(off) <- NULL(off) Yes. I agree with all these. I think this is playing ring-around-the-rosy; you are trying to find a word that signifies that no value has been assigned, even if the variable is "set", but that's not "default", since the default can be "". What we want is to change the default value from an empty string (""), to a non-value, which in computer science usually is NIL. It's not "default", it's not "designed"; it's "no value". Doing "unset var" should not change the value in my opinion, but that's probably another patch. I think we should start by separating meaning from behavior, so how about this script: ---- [[ -n ${ZSH_VERSION-} ]] && setopt posixbuiltins function check { echo -n "$1: " test -n "${var+on}" && echo -n 'A(on)' || echo -n 'A(off)' echo -n ', ' test -n "$(typeset -p var)" && echo -n 'B(on)' || echo -n 'B(off)' echo } function f { local var check 'local var' unset var check 'unset var' } f ---- With that script we get: current zsh: local var: A(on), B(on) unset var: A(off), B(off) bash: local var: A(off), B(on) unset var: A(off), B(on) ksh: local var: A(off), B(off) unset var: A(off), B(off) patched zsh (Bart): local var: A(off), B(on) unset var: A(off), B(off) patched zsh (Felipe): local var: A(off), B(on) unset var: A(off), B(off) So It seems your code and my code agree with the behavior of both A and B. The only unknown is what A and B mean. Agreed? Cheers. -- Felipe Contreras