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,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 14983 invoked from network); 4 Jan 2021 21:58:25 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 4 Jan 2021 21:58:25 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1609797505; b=ZRMQwm1W8/a9iNiJH+u5+8s5AJBXUW4Qs9sL0XzHT0hZ/qeFpftqCoiOsZ+nFZw+qP81tCsmG0 160CZSeal7UZ+OeY4IQf1Jj2aKJ/9BY3+4M5ZE/3m4ofUr2NE883UYztWtBL7uqkGg2oGyCyry 0Sw6xx0tHColZ/uPwcBJ6pFKvKcLMHT4Tmd7Jdu49bgOtax/EfurVHZllNMEVlz3/Mob9Nbdkq x/R28Hq/ny2rrZD6auwpUmXbo42N6/6uXtf30uLvNbfNGlUxte4exqxDvimGPgacZ/O122YQnP 2N/7ZP5kYLkRsHxTQ8SOwUapMRsGPq25TM3laVqRzkjpcw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oi1-f177.google.com) smtp.remote-ip=209.85.167.177; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 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-20200801; t=1609797505; bh=yI/z4vieYDZkQU9c62+Fd321v+vOgrI9r+dnwd+UDF4=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=IPvFmMUZ30Hw405QilUNeRb47L9T5LrKuIKDSdWrRWaDa5ySW5ysK6PqQ1+ueXnkPOMSeYw3j0 ja4PWFcyPzBFB7voJjxPMajJAmkefq7lzAN+XLA3wUntvDdVcyqkShh5L+1UVCtjPHHfP8UDg5 HI4sBRIDWCuOW9mqlAKUNN83I2fyblnsYTkuQOSTb7ZJlBRjMMZQBYRfVxKPzbnY/tgo0RIVik bcNyEutPE5fizhJCiRyXsVaAniXy1eWYJXzm/Y6KTmShdFMs0mktWy2Gu4etQffpBAYnM7XJdP VS3FTo4JQJ7ideNfRyat37koY+CCCRLMftycp0EaNoXBHQ==; 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-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=xRtrHeqWasMnq9LHakXDlx9FKYUA7JrN6QJtLQTbOD8=; b=nUabyZ73zyLEX2LSSfQdLYDuD2 Y1W2SmIh988ry192BH40maRA0R/xrOsJdh5EkymVh+FjVFZmTkASkhQvRhb6lT6QYJCzsGFonJoMh zA1XhFZ7s5ZJSMmRgv/Yf9wmEp6QEcbCvdwf+CJ5urKpsrNgHOfyWEQc98IL0ZiQyJmRsW3XKsuF1 mBA/wdXBt++XzHBOwGFEvx/1lvJME0Ju5ZUWPwYA8hNY1lWNvOO4/x5PdM+lwOs7JZAZ4MQQlEbyR PvT7+a6UbDR24Q5wvVyypCFCPMqPsqi/oIwWBLPfkVOXO8tU/DUIEZsnKREi86yZSF6E6QmOt5DjD AiaNbwZg==; Received: from authenticated user by zero.zsh.org with local id 1kwXrr-0008Vj-Ug; Mon, 04 Jan 2021 21:58:23 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oi1-f177.google.com) smtp.remote-ip=209.85.167.177; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-oi1-f177.google.com ([209.85.167.177]:43294) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kwXrZ-0008NR-9E; Mon, 04 Jan 2021 21:58:06 +0000 Received: by mail-oi1-f177.google.com with SMTP id q25so33818888oij.10 for ; Mon, 04 Jan 2021 13:58:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=xRtrHeqWasMnq9LHakXDlx9FKYUA7JrN6QJtLQTbOD8=; b=YuXOhJAtzieRRZFeuK1MCchXoWUkAgPLtfAsZKndhptAza4MwJs/F3ZyBEXmhgEZmq LR5gGxIMOMbNr14w8n8leWI3hZQiz0VCRaSq+7Mq7icEoARrKnydEF93eQbdIRyAv+s/ Xn42/RVZ3CgybEtmPlneRbJPANe/6zL2sE8jiAYpgZRnMqH8y9rFFzMvtp6Yy2JcM9Yh FbfJzYmXOgZGjhdnyEv4AJf64UBwk0TQJWZEaXRMvWmzBcqPhhE/8KPSToUpcJdQGie7 H6YxwS1SfSlierdgYzw76C9JaAyPp8oT3AlltTskJFjQFIPPyrSEsHL5UHz79sATUshU szRA== 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:content-transfer-encoding; bh=xRtrHeqWasMnq9LHakXDlx9FKYUA7JrN6QJtLQTbOD8=; b=i3wDXGe1+eZjHHAXKVilc2gjoRupzMVL2Zfi+rNVUnr/UmnHAT+8HYH2my33fBPRQi 5UUveHaiCoC+c0HxRNuVTSz0y4YgAONo376NawdQ83iruCS6xSed7duNlywiFsCeGh90 kyc+MYL3O40p0luBoNzDCkZeVimSi8iOWZX9rrpu90Y8QYkQBlC+YCi6OTGsNODcGkzy uQubQXSuXdvYg+hEs5dwG/m3cJwVD4tC1v3eoUwyS9XIrMksbzQxQkr375y4qUIwy2h2 zpRJzf5RJDhZqslo4tb4IBOr21APLMUpxZo/Gz8tvDSdlXFKm0g/wHhzGW1zhpcGAu1R A9Pg== X-Gm-Message-State: AOAM532qEEwFiNEX6lBDZMX+5Ib7jD3iH/Al5/8A9v5q6JITAh7orB0j 39GDgvNCSAcXMcycRav1bdbg2Kk1mP13G9o7R9oFnA== X-Google-Smtp-Source: ABdhPJxJ4jxd+KPt8l40ZX2iTHkjbn5pj5YFs1zEtDWEIgXizygQCoq0xqz7YkyFJDNGAXU/++FE03wjn7P5U5ft64Y= X-Received: by 2002:aca:6089:: with SMTP id u131mr704558oib.84.1609797483774; Mon, 04 Jan 2021 13:58:03 -0800 (PST) MIME-Version: 1.0 References: <20201228221342.136199-1-felipe.contreras@gmail.com> <20210104061718.GB14783@tarpaulin.shahaf.local2> In-Reply-To: <20210104061718.GB14783@tarpaulin.shahaf.local2> From: Bart Schaefer Date: Mon, 4 Jan 2021 13:57:52 -0800 Message-ID: Subject: Re: [PATCH] declarednull: rename DECLARED to NULL To: Daniel Shahaf Cc: "zsh-workers@zsh.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 47797 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 Sun, Jan 3, 2021 at 10:17 PM Daniel Shahaf wrot= e: > > Could you summarize the bits that need to be named and the corresponding = shell > language incantations/semantics? There has been a series of threads about this, but to try to summarize: In current zsh, typeset -i var typeset -p var print ${var-foo} produces the output typeset -i var=3D0 0 Note that integer declaration (-i) is for example purposes only (because then $var is visibly zero rather than empty string); the flags to typeset don't matter, only the fact that there is no assignment in the command is significant. This disagrees with e.g. bash/ksh, so the proposal is that with POSIXBUILTINS set, the same three commands would output typeset -i var foo That is, even though a parameter named "var" has been declared, and that declaration can be regurgitated, "dereferencing" $var produces a result equivalent to examining a variable that is unset. Felipe has argued that this is functionally equivalent to having assigned a NULL value to the name "var". Internally, zsh does not have a representation for a NULL value (although with a number of changes, it could do so for non-numeric types where the parameter union contains a pointer, and we spent a while discussing whether those were the only cases that require implementation). My approach has been to create an additional flag (originally called PM_DECLARED) which represents the state immediately following typeset -i var and then to bitwise-OR that with PM_UNSET to minimize differences in code that tests for unset-ness. So the "bits that need to be named" are: 1) the bit representing "remember that this was declared but no value was assigned" 2) the combination of that with PM_UNSET that represents "functionally behaves like NULL" We could of course simply never name #2 and always write out the bitwise-OR, but that seems cumbersome. As I understand it, the objection to PM_DECLARED for #1 is that the name implies that only "unset var" should ever turn that bit off again, but the implementation requires that assignment also turns it off. Similar objections of English language semantics conflicting with the implementation have been raised to other names I've suggested. > Is this anything like using =C2=ABstruct foo **p=C2=BB in C to denote a s= ingle parameter > that has three possible states Sort of, except that (!p && *p) is actually "valid". The problem is that ${var-foo} resolves as if (!p) but ${var} resolves as if *p=3D""