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 1kiyWl-0000Kw-FO; Sat, 28 Nov 2020 11:36:31 +0000 Authentication-Results: zsh.org; iprev=pass (mail-wm1-f50.google.com) smtp.remote-ip=209.85.128.50; 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-f50.google.com ([209.85.128.50]:38267) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kiyWN-00006B-Fw; Sat, 28 Nov 2020 11:36:07 +0000 Received: by mail-wm1-f50.google.com with SMTP id g185so640449wmf.3 for ; Sat, 28 Nov 2020 03:36:07 -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=4anUhEOpN9iy5F3lGORkU9dlCz6QfUqjJXvaq8j9RJg=; b=t+VurdMALCT1nxRMXZRWtRXSal5zyCcO9YsszoZe2pQIw5/ZYKsF1gMp8OV7zLKI74 B5o7w1U97X9LF/fo67toVYdBbpTc//DfWSEyM87kPdGZLvTEj+eHb2EY2LcYaFcxjbU8 KpaunMrRw2YKmjKqHDXWsbx64bTGWahRe/IWMaJi7QmtkEi0gY1u/tfjoaUIxxb4M8tB FW4oxuXZEKYyUnOx9MSwTwjKHuNiw8/EmwF7LQmQ7FvSSLBPO1Fi32l2vZR3hQHbQ7w9 9FULWPkp8RSiOyelYzk38ds4bkL76C1vsKJlAOCxN8t0+M5ORs+3kLkojk9Hxm8P7DBG pDYg== 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=4anUhEOpN9iy5F3lGORkU9dlCz6QfUqjJXvaq8j9RJg=; b=YBXQ6jOOYvSL302F59JSYQY2mGK5grvWFyvwiiArc+ANLOc6hqg/moDyqucr9ZER44 4pMHzrCRPtmkBAauk1Olrx4JOkyhJBWZt13FJ2DTa56K6cRb3ggddHnHTqQHQmYku2By 6n4v6JK2JWh//66vRxBRxPwL6DEFaOBS0nXGjSCXftO3erpb0SxKHIeZVgkwazwgsJdv X9ZUeaFxAO56QwcelOIlrFqTzNK1dmxyikQxX4Sv/GcF3zLAFjoVFKCVDx6KdOiJvkAe kuJRRm9UTNthpDZnRgBuJYMBLzvS1i07qwsZJHaBq7Dds5UOujqXavMz04kVNco+6B16 fjlg== X-Gm-Message-State: AOAM533m9TDUB9flg93FQ/WyVhVwUjnvn7lwwNnlgulVHO8RFa0rmJjE TPEreLHRsGC05YXFAgz5daS//aKdlv7Ow3B3p0at5DHVkHn4rg== X-Google-Smtp-Source: ABdhPJyFHhLn7nKghInnMDtMVqQCzgU5TgSF95zHInxloICKUKe1UPTh9ILObqp/+9IMlPsj9Bx+y2HXRBW/48U06GY= X-Received: by 2002:a1c:f619:: with SMTP id w25mr14236816wmc.55.1606563366687; Sat, 28 Nov 2020 03:36:06 -0800 (PST) MIME-Version: 1.0 References: <20201125131921.vay7h3xk5qn4odgg@chazelas.org> In-Reply-To: From: Felipe Contreras Date: Sat, 28 Nov 2020 05:35:55 -0600 Message-ID: Subject: Re: The emulation rabbit-hole RE typeset/unset To: Bart Schaefer Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 47694 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 Fri, Nov 27, 2020 at 6:37 PM Bart Schaefer wrote: > > On Fri, Nov 27, 2020 at 4:00 PM Felipe Contreras > wrote: > > > > This is a bit tautological, because if the variable is unset, it can't > > be anything else but a string: param_is_unset(p) -> > > param_type_is_string(p). > > This is manifestly not true in ksh and bash, because: > > [[ ${foo-nil} = nil ]] implies foo is unset > { typeset -i foo } declares foo is an integer, not a string > function ff { typeset -i foo; echo ${foo-nil}; } outputs nil All right, that is true. But then, if we have this: typeset -i foo At this point "foo" is unset (in bash and ksh). It does not have a value, and ${foo-nil} is nil. So for all intents and purposes it is nil. Then, we decide to add 1 to it: ((foo += 1)) The result is 1 (in bash and ksh). This is interesting. Irrespective of the fact that foo is unset, you can still add 1 to it, so in bash and ksh it doesn't matter that foo initially is *not* 0; you can still add to it. So this: f() { ((foo +=1 )); echo ${foo-nil}; } Returns the same in all shells: 1. You don't need to define "foo" first. So the statement 'the only useful "declared but not set" variable is a simple scalar' does not seem to be true. An integer is not a "simple scalar", and seems to be useful unset. Or am I missing something? Cheers. -- Felipe Contreras