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=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RDNS_NONE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.4 Received: from authenticated user by zero.zsh.org with local id 1kiBal-000B34-2G; Thu, 26 Nov 2020 07:21:23 +0000 Authentication-Results: zsh.org; iprev=pass (mail-wm1-f48.google.com) smtp.remote-ip=209.85.128.48; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-wm1-f48.google.com ([209.85.128.48]:34866) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kiBaO-000Ao6-G4; Thu, 26 Nov 2020 07:21:01 +0000 Received: by mail-wm1-f48.google.com with SMTP id w24so1292044wmi.0 for ; Wed, 25 Nov 2020 23:21:00 -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; bh=AwlVwGat8bOVWSo+S7kY0YssX86bBaqjNmpOHj752nQ=; b=QGo3iqUakCje1sw8d5L0zwPhG5QaAn5PQwM4fmqDEqoJkjfBSQsvgBWqcZLSdigHea zhxmTlLeUzbkZzZyQELIzDksOTjRAHGIDkXmSqIyKNpTL4M1otVdZPSEoJfEJWNb69AQ yMscDj/YS088/VwLl+BXkBkPMb+h7vxSPEUx7auJDIFPOlyzKR4qvP10OQpuY3Y9i0xW x/n5o9hDdgdiYSDpwAKDFHVru/G9lx5g7Pv6DC0EtQTItU/nMb84AKl+WliCrBu9W8Tb 1pcDussNXCmBRRXLPZUvWYSqANohPd1/6PFkWrWKQrDVVIzqzwqnR5zJPIPM98aKX51G sbzQ== 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=AwlVwGat8bOVWSo+S7kY0YssX86bBaqjNmpOHj752nQ=; b=I2ujA4k6SI3rw9+aFgo1Zsa0PCTY+3S6hT6kuiNqyHO3eDnOi7OsOP2vAw7mo5/q9K g+Huj60s1BhsI07UJNbkTaylBNg1JztxPHkwMW2O2ipA/Jk0EXlBxXS9R1nuzvmbxiqt pPMamPs3Ir1DwaNawkWbufhMX3bdHEe0fbtoJ1HYo+vwpc2urrKdWMkyRclKJcEuH2Zd GCEtTKdwYe02mi67SreMIji28CMhqo0hNN/P6Um2kv3otam4mCgz/+nc0caIWEcqBasw pUt7ujYbymjPvFq7xR+oZj4EjcBqmWsSHLg96NOd3hm4rBOR7ikpbSm0ArBt4/OVUs2W S68w== X-Gm-Message-State: AOAM5303Cg0NmgVBt+lB/LS9iWpxyUETps7cbQgkCMoEgrC6iGQjkMuq y+lEXlnSy0xcFmiMuB7Fd2yykn6TO9ZFlT2tLVE= X-Google-Smtp-Source: ABdhPJzI74T8ZlSoK32SYZ4HJQYa8BdMSj61pAWUlMoWg2TcfWj/nORhP7PtFzOrrjMOgkA4EFSzxzIYyUsN8nThK30= X-Received: by 2002:a1c:a145:: with SMTP id k66mr1610503wme.173.1606375259739; Wed, 25 Nov 2020 23:20:59 -0800 (PST) MIME-Version: 1.0 References: <20201125131921.vay7h3xk5qn4odgg@chazelas.org> <20201126061029.in5tpnrg5bplam5k@chazelas.org> In-Reply-To: <20201126061029.in5tpnrg5bplam5k@chazelas.org> From: Felipe Contreras Date: Thu, 26 Nov 2020 01:20:48 -0600 Message-ID: Subject: Re: More rabbit-holes with unset variables To: Felipe Contreras , Bart Schaefer , Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 47633 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 Thu, Nov 26, 2020 at 12:10 AM Stephane Chazelas wrote: > As to unset vs initial value, both have merits. While I'd tend > to prefer "initially unset", it makes sense that "local -i i; > echo "$i"" outputs an integer. Or that "local -Z2 v; echo $#v" > outputs 2. Yes, when you are specifying a type, it's obvious what default value you would want, and at least to me it makes sense that "typeset -a arr" initializes $arr with an empty array. But that's not what was discussed here. The discussion is about what "typeset var" (with no type) should do. > In any case, I don't think zsh can change its default behaviour > as it would break backward compatibility. That's what major versions are for (maybe zsh 6.0?), and backwards compatibility has been broken before. Anyway, in the current state of the discussion, the idea is to add the unset behavior to "setopt ksh_typeset", so no backwards compatibility would be broken. > It could try and emulate ksh in ksh emulation, but which ksh? > ksh88, ksh93 and mksh behave radically differently in that > regard. Also few people use ksh these days, so I'm not sure it's > worth the effort. While the ksh emulation mode can help with > bash compatibility, bash's behaviour in this instent is also > very different. When no type is specified, both ksh and bash do the same thing: no initial value is assigned. I don't want to say "unset", since as you explained; that can entail a lot of different behaviors depending on the shell. But rather: nil value. Can we agree that it makes sense that "typeset var" (with no type) assigns $var the nil value (in other words: no value) (or at the very least no value in the case that no global $var has been previously set)? Cheers. -- Felipe Contreras