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 28572 invoked from network); 2 Jun 2021 14:52:54 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 2 Jun 2021 14:52:54 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1622645574; b=Ye4mzEiRMyU8o86mbNRf4zL+1rkbtXesRUbpZcEMH7Uio6I1jzIWGPXrSqaXEflIq7r8VHrwYE /ihAq6xsnsxlbYy1+uVBdjKS5RBYAFJPz6PGkVNNmLzDYsJnTCRMkLseLgtJsPHKelEffZh9iQ mKu13nYDVXH/RRjLWpiU01LRb2wKcvFCzZNf7K+E34KdiUawkNrJVshPk7O6mw7h4bmual0BLE URzE+0w/7d/02FEpgASzjm121Tw8HNSHV+ASVJoVJaj/K3OjbBvOb8XMqIBx8qOxAOJ0Yqul5i RmFSMo1ZutVUmPzglPItWxs/h5t6464OW4/6X8V8AE1jNA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ot1-f50.google.com) smtp.remote-ip=209.85.210.50; 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=1622645574; bh=A/3i48NkKtvb9+pTTamGBPMeXXHmy2t3R3P4xFK+J3g=; 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=WEDATpZuAtnTi5bKImRbjTtY0L0ZAo2tbrMsxUmupZMkaPrGdGYNRCJBMlqCv6ZtMBvpml5h5M hMmMMmtGqpDIRdOK6iox7rM/4b+2IqBugkSxTX6ieYh+mjzN69T5sS+Tt5z0yj12xtcgy+b2Nm qkfAX4jtDYfgusF1qjA/UeIy19594ICIGDyHV5fCtXKI81LiLvydlsQCk4ANrD6u8vlJM4g3PX peBcoDL5y4NMAfiRxiqYjA9d7VCR2DTlS5XAF/ty1lubUQLXZ8P2cGHbg/8FyGnVzuu9Nvh6d/ Y2gD7Zr2sIWDmddq1t07rczxCegT1kNZ2AZlPS21o+uejw==; 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: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=PPlKyhG5B0z1ibvSYK30qy7WvTKxI0S9e2h0W9z/O2Y=; b=oLokgaRVxGPtMYLB4VJmWFQElu HrRnW9gajwObt04vkvK/nu2rtxkrKtv1dkbSnnFWTZQrromgAH8b8zev8BhYtT7e7mFd0sejUzrPL GL1A/V2PFyNLdF4EtmhPAtPVq2AlupFFBpPbFKfAVMA4fZRKWyMBGFcU94mnjonKldB4gPE6Uceql mj4R17YI/XOwbJ8T1YcXd97JSTNtLtQ9jqkgPAa6p4lHIKYuni7zbQQov6O9U5dS0muQsxY6tfa1B XCpN2yx3/WL4TGWJYnk5Rg6aJGLcAB8SfqhyeQoRVaxCzgmK9CteNIaY5f2G57aeV0UPw3T723WIw aS57dv7A==; Received: from authenticated user by zero.zsh.org with local id 1loSEo-000ISA-9D; Wed, 02 Jun 2021 14:52:54 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ot1-f50.google.com) smtp.remote-ip=209.85.210.50; 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-ot1-f50.google.com ([209.85.210.50]:41494) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1loSEX-000IA2-Mt; Wed, 02 Jun 2021 14:52:38 +0000 Received: by mail-ot1-f50.google.com with SMTP id 36-20020a9d0ba70000b02902e0a0a8fe36so2641580oth.8 for ; Wed, 02 Jun 2021 07:52:37 -0700 (PDT) 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; bh=PPlKyhG5B0z1ibvSYK30qy7WvTKxI0S9e2h0W9z/O2Y=; b=prt5cYIqUnb6jXuhDLLgjBo+YTX+OfVxOrZduF2gi8SG8+3NhC6M2NqcWRqlGJYwvY +HGr7BQdfMiMBc5s9fdWlfZFJkAIX9qRO1A606jrF46pl+7OGZY/NI3CLIUqCwZJvKBR 7U8gosWPhTEl4+lC1HuRxl4dkTd1jUV9r84RLzQ1XeenPUvX3hPGKz21WAvUULpv3PGk 9gYYTGr2uVU09LM8nKVCIRIOjXy6h8yrOT4Wm5NwRWBXLX9EDL1rFZIP2diAUyMcaFDW wSxOmsLlBWwMDyoA5Ztx1amlBVK7RU0P3g4ZOz1XB7PP2vSNi9f84gH5pgqzVDW1QAyJ cJqA== 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; bh=PPlKyhG5B0z1ibvSYK30qy7WvTKxI0S9e2h0W9z/O2Y=; b=X8y0IN+kFfg0fJDTHRrk6mPJ4uQxHeCCC6LsIwytbz9LLd7YnHV6FSppbmJfYbSM0Q ET2zJYZeiqal0gkCsGBZe9r/z9g2/O/HEe+jf3BavA568U8wzt7jck0G6TupAwe7OyiF 42f4dlFniifFBavv4alYQKbkGa3yEdqVo0sgDo+ha+9FsN9TxQSHr31CELGga/Ajl/fF Enx5NKhZgZVQyJC86+bxvXSe6kYNmPvZ1NYVQ5c0alhoIKrSv6w2+epRZWIc3p6I6Ekt wugRkKn6hR3QmtJrBO7/YoS+snaG2tH1gfIDQHMGLsj8z/ptcl7apuQhAAAg1qLfOtlD BVEQ== X-Gm-Message-State: AOAM531FDNo3YY8SEHD+oQInt01szzZETN2jnp/wahhTbQyPFMFwcU8a zll0dyyf/H6lDue+5mrBQaYBawX4fZHru01UYpBdFWYKEHY= X-Google-Smtp-Source: ABdhPJwhDLw4d85wUE9bFkDn+Ws3bKrUWKMQ8foGc9WgB8s9GUsmP90tqt8F8KPRVZ5nFGPLZH7zTj1O8/lblRgWKUY= X-Received: by 2002:a9d:6c46:: with SMTP id g6mr25875502otq.260.1622645556403; Wed, 02 Jun 2021 07:52:36 -0700 (PDT) MIME-Version: 1.0 References: <2ea6feb3-a686-4d83-ab27-6a582424487c@www.fastmail.com> <20200101140343.qwfx2xaojumuds3d@chaz.gmail.com> <20210430061117.buyhdhky5crqjrf2@chazelas.org> <20210505114521.bemoiekpophssbug@chazelas.org> <20210601053235.b4junj6muuwegl7b@chazelas.org> <20210602100651.qn3rrop5dup46ikc@chazelas.org> In-Reply-To: <20210602100651.qn3rrop5dup46ikc@chazelas.org> From: Bart Schaefer Date: Wed, 2 Jun 2021 07:52:25 -0700 Message-ID: Subject: Re: [PATCH] (take two?) typeset array[position=index]=value / unset hash[$stuff] To: Bart Schaefer , Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 48987 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 Wed, Jun 2, 2021 at 3:06 AM Stephane Chazelas wrote: > > 2021-06-01 19:51:32 -0700, Bart Schaefer: > [...] > > > The issue with the empty key seems merely to be that the subscript > > > validity test for associative arrays never changed from the one for > > > plain arrays. > > > > To maintain error-equivalent backward compatibility I didn't "fix" > > this, instead, hash[(e)] (or hash[(e)''] if you think that more > > readable) is required in order to unset the element with the empty > > key. > > I have to admit I don't see the problem here. I would have > thought allowing a[]=foo and unset 'a[]' would be no-brainers Mostly I was thinking about key=$(some derived value) unset "hash[$key]" In existing code that would fail on [[ -z $key ]], but you can't see that by examination. > as there's no concern about backward compatibility as those > currently return an error. That's not our usual criteria for backward compatibility. Usually we only change things if the new construct was previously a syntax error, something that would prevent an old script from even being properly parsed. > Even for plain arrays, IMO, it would make sense to allow empty > subscripts. In most contexts, an empty arithmetic expression is > interpreted as 0: But ... there's no such thing as array position 0 in native zsh. > unset "a[(e)$key]" > > That still chokes on ()[]`\ and that still can't be worked around This is why I asked for test cases ... combinations that I tried DID work with a[(e)$key]. So, that may be a deal-breaker regardless of the rest of this discussion. > It's also a bit confusing that subscript flags would be > seemingly parsed but later ignored (included in the value of the > key) except for (e). Well, they're parsed and ignored currently, and we already allow some subscripts but not others in various assignment contexts, so this doesn't seem all that weird in comparison. > The fact that (e) is recognised and (ee) is > not also makes for a not very consistent API. What would (ee) mean?