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 17995 invoked from network); 7 Dec 2020 23:13:53 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 7 Dec 2020 23:13:53 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1607382833; b=0+uwZxLAW/noFQqu/YUDlqm2OUstyvDpoTqrVIkEwHz9EbkN9WMdennM/J8jcC9Zd5I4SNzanc 2PzPaHUxhL6pa8KeUmTZPuvx2wouO9W/lO7si2Ryo3JQ4jdeEiQ/dZ/I9XItZTuAu9Ta0WoVST LTWxOIqsESfGzez9xlipn2VXQleK4dblxwr83RrH9vOQ//EwlVnPPvOvzCpkf2D2e9hJRUUwx+ 7nwL3yPD4g9EOz+MJNs9mJUnuU9/8q2duHLcm/PrKb1kd+2pJJHL2+UjeawP4yGXgUjVGod2zI Kk9i/B5zPKsG0FXUvhoAb7rmILTSH/eJaM8r/mFMtalFxA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ot1-f43.google.com) smtp.remote-ip=209.85.210.43; 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=1607382833; bh=5GTkdGZhaNxRuFceZAwOIMGd1IRvYOfSnusr+QUatig=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:MIME-Version: DKIM-Signature:DKIM-Signature; b=Xd+CcuF7n9f8Rq2LMJzrZBYhdkN/O/VGmb3e9G7KQd0D9jsVLhrfogkVqCFsSXDDfSzJNDdPRd nE9KX4ekbSu9XYjXvQjlNef+Rkxp9KJECM30uwTowhKxPmg2JE1GeH6lrVNVn5ZNFX/l2e9SWZ dD5j8iEnG9HL4twXstpBtIXpzsSz8o23l/NEYF+YguPFX0gHNe3d7LGmeyRfHlkjv0d1HuFUH7 WW7s69sKVTfv9MPt3jioqgqNHXbNncMgb8QnJDOiHz7qVLhZnuzGF6jPJmz0VX6lIHV6DPPhkw jar/V4SVQ66yGpVtuP/r1z/TMClarobc8K9V9II78jf5SA==; 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: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:In-Reply-To:References; bh=ToVR8FglKjQKviXoin46fLrJgna/ykBjQiZdDTzpevI=; b=fEs3ctPWxq6QMG1xyw6fuaKJZq J76XaZ8ViwMWPCivPRLHf7ynNLvSsM5UCBr/tW0qwfp65rgycKqYUszvGZ2uhpkTpzfJJM1CwvoVv /Lqg6zRuH6oadEXqRPWO6BCuP/aS0qtc996MVD4Nou096HwN8Vx0Bbhw8Gr2pfbDBduEz9BSZhtfh ZxK57bizC4wlgkOkOGrrrRKutaZ0ENiLT5l2wo72c4zNzFypn8/gsJh6WHgKSyBLxFWfGX1AfGot5 l/owMhjMKf7efoTvYc3lgc8xu02lGysiDRx4ug8bn69SiyUR9tm49wRQvpoO52kjGKSgon0subZ3Z SmDiy5fg==; Received: from authenticated user by zero.zsh.org with local id 1kmPhZ-000DJF-0I; Mon, 07 Dec 2020 23:13:53 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ot1-f43.google.com) smtp.remote-ip=209.85.210.43; 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-f43.google.com ([209.85.210.43]:45427) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kmPhJ-000D9N-Jt; Mon, 07 Dec 2020 23:13:38 +0000 Received: by mail-ot1-f43.google.com with SMTP id h18so10224926otq.12 for ; Mon, 07 Dec 2020 15:13:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=ToVR8FglKjQKviXoin46fLrJgna/ykBjQiZdDTzpevI=; b=s+Mn3FMqDZi1M+X61VeLdvI2FWb8djA6pUN5cNkn2yAoGnAsF3jBi5mdAombxcEtY+ wDtwN54kxX2fJ9PFVCCU1zLl5gsNdbyVHxmUbFoXBQf05bzhRaPUXl2vxnhxdne4lF9I O3v1VQwto3QxnayzkKEdeu8PmiwmrN9XHTwxB7w8Cyhrtlldh3VPqxyvBIIAwBx3FY2a 11u3eEWAYVm4UCtmOdnHZT46O0taFPdEEEP+CmCOBHXHe8gzuuzNj91Vac+k7oHzmyTx jKJn6cbFSjjcOfqhpPfzlnLHDWrMBl2OiUFXYaq81Am4koSwWV6NbSlJBcEK2zg2nUDy ibcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=ToVR8FglKjQKviXoin46fLrJgna/ykBjQiZdDTzpevI=; b=mvEQZ2+kfn0ntdtBwkHCxpkGkNCbe01wq/m5RRWvFOg5PuugqS1R5mYfdcS5Iq6amW phsMeIj4Yyy4FCGnpreSF32lzHbs7Ot2BF9tBgbKoHcqsD/4Bn1Pk1GaDK+v5FW3+bdW x84o/JJlT0m2OQ+uSfcqwSdNVJJTcaZ/n2gZOGyLaBMF1vPgAFjCHU1BFWIuj138WOSu fOCMOnBvsbedYJOvIDVQ0kiOb7pmn8A9yg4MfjEuLBQO21T/EN6ZLaaACKQnpBuA7mJZ 9Y0fyo1qsnlgLfOGcO8tlcUhDUrYmU/ztRjcVFkD3YpOLTlLp0eDlwDecu7TpZro6M9b 6Z9w== X-Gm-Message-State: AOAM532qD+KHUlrKPmti/irv8+MesZLEtBgP6iPVl/SJ2H3qZQc9Je4N pfi5rqHLUd/7bsSQ+vF9Od0H0+j5JLNGzkQTtNXB8oLJUVXffw== X-Google-Smtp-Source: ABdhPJw4xJqLhTLx+rXMJLaHehj/nMVvGAY0rSOXnzMm8hNFIvP7QbkaCy/plZpdjckYazX79iN4xQzmNHFiuGc4lmI= X-Received: by 2002:a9d:470c:: with SMTP id a12mr14427623otf.161.1607382815973; Mon, 07 Dec 2020 15:13:35 -0800 (PST) MIME-Version: 1.0 From: Bart Schaefer Date: Mon, 7 Dec 2020 15:13:24 -0800 Message-ID: Subject: Unset and $empty[(i)] and $empty[(I)] -- worth the effort? To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 47729 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: Current behavior (git master branch): 5.8.0.2-dev % print $notset[(i)] $notset[(I)] 5.8.0.2-dev % typeset emptystr 5.8.0.2-dev % print $emptystr[(i)] $emptystr[(I)] 0 0 5.8.0.2-dev % typeset -a emptyarr 5.8.0.2-dev % print $emptyarr[(i)] $emptyarr[(I)] 1 0 5.8.0.2-dev % unset emptyarr 5.8.0.2-dev % print $emptyarr[(i)] $emptyarr[(I)] 5.8.0.2-dev % I want to rationalize $emptystr[(i)] by saying that it's searching for an empty substring and it did find one, so it can't return (($#emptystr + 1)), but there's not really a $emptystr[0] either. In the reverse direction, if an empty stubstring is allowed to match there's no unambiguous answer for $emptystr[(I)]. Behavior on the declarednull branch: delclarednull % print $notset[(i)] $notset[(I)] delclarednull % typeset emptystr delclarednull % print $emptystr[(i)] $emptystr[(I)] delclarednull % emptystr="" delclarednull % print $emptystr[(i)] $emptystr[(I)] 0 0 delclarednull % typeset -a emptyarr delclarednull % print $emptyarr[(i)] $emptyarr[(I)] delclarednull % emptyarr=() delclarednull % print $emptyarr[(i)] $emptyarr[(I)] 1 0 delclarednull % unset emptyarr delclarednull % print $emptyarr[(i)] $emptyarr[(I)] delclarednull % Given that the behavior on $emptystr is already poorly defined, I'm not sure it makes much sense to put any effort into making the uninitialized $emptyarr case differ from the $notset case. Further opinions?