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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, 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 1kiklt-000Ojm-B4; Fri, 27 Nov 2020 20:55:13 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oi1-f174.google.com) smtp.remote-ip=209.85.167.174; 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-f174.google.com ([209.85.167.174]:42477) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kikla-000OUg-10; Fri, 27 Nov 2020 20:54:55 +0000 Received: by mail-oi1-f174.google.com with SMTP id v202so7129749oia.9 for ; Fri, 27 Nov 2020 12:54:53 -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; bh=QQvnTftsrEnmSnlSTOrksdSPFl8tXs3FTcp8zHljvVM=; b=ttJ9USoSNlvargI8I3wUm/QxQJffOnRkAXWFh5bmmxb7+/jqtgaTcWWsyuAF0yvkTS 9TCQWJA//qqzDFhEVhyPq8RKQj8YLTj/Wk+5ZmPIRRBOUj3RVae3/G0ZH5ftNbTsQKv5 eODbW2s5U9+wCqumj29QSPepgymnHq4kksn4Y1QyyKBSj5VGgWzaTmgKcjtFVkCB/oS+ z7Ke1Ak1yfkhE4ccGmIuLa20EKXQiyDiIY0Tq0MfyUN4gApLHDsCI9I+D0p1qEfQf0Ur RJbW4c4AiZLRPIabyCNoIzU0IDK0CzlgGWtD7cHs4TmlQWxoMP4MNRzre3gbGZITOL6y Cuzg== 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=QQvnTftsrEnmSnlSTOrksdSPFl8tXs3FTcp8zHljvVM=; b=hsRQVr4JVyGnF9l0OJTRlqP+fffnGK17c5kd5SqQq8xAtVwptf41cO7Vrg9TgYwgYE rr0sr9B1h6UD3fKGSxsO6dK5tDC1Vd2wCZ7WoSKNcxuWHPMZ8U+u1l0CJk8J6xJmafqZ mbl+WGv3KILiKNoj/Zv5x+nnRRPR8rc+vN5FYVYqhyCzt/YxFoX/B9Ls9JD66eoHTrCH +ls7O78iNser0Eq0Ufkwp3Hm1t0ZLhIFYcXPLtU1MAmG4h1swnNx2fT6T5lOMkVLke6P Tdf0duatsd65AFaDtPOrsErHWVRv0lUhrGuxOnF/21RuL0kHETz9vLxczxE8MSugUH+d +51g== X-Gm-Message-State: AOAM5317ivp2ZUDKZOE0/tru9GHyD6IoyAwsSQ0URsZcGX9zsiJZ9wM0 SYTezju4fHnBp+spFYGRogD5mBb/QxBfD+qaUY1BpQ== X-Google-Smtp-Source: ABdhPJzCRMJJoJ5WFOxLFJ8dJpr5IJC07jMUoqgh78pAbQdS5HUDk1bSIYMqSW1xu2D/qRtFSQsvb4FNwxz1m3AGUXc= X-Received: by 2002:aca:bd45:: with SMTP id n66mr7029921oif.132.1606510492368; Fri, 27 Nov 2020 12:54:52 -0800 (PST) MIME-Version: 1.0 References: <20201125131921.vay7h3xk5qn4odgg@chazelas.org> In-Reply-To: From: Bart Schaefer Date: Fri, 27 Nov 2020 12:54:41 -0800 Message-ID: Subject: Re: More rabbit-holes with unset variables To: Felipe Contreras Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 47674 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 5:30 PM Felipe Contreras wrote: > > What zsh refers to as "scalar" internally is a string: > > char *str; /* value if declared string (PM_SCALAR) */ > > From Src/zsh.h (struct param). This is exactly the discussion I was trying to avoid when I said "in the abstract that doesn't matter". You can't just pull one field out of a union inside a struct and ignore the struct itself and the API for field access that goes with it. > So if you didn't mean string, what did you mean? I meant a struct param, containing the least specific thing so represented, as interpreted through all the layers of code that implement a dereference of its value when you write $var or any of its variations. Again this doesn't actually matter, which is why I didn't spell it out. > And what did you mean by 'so a the only useful "declared but not set" > variable is a simple scalar'? As the very first message in this thread demonstrated, in both bash and ksh (call this "example one", and to be pedantic assume that X is not inheriting its name or value from somewhere): typeset -i X echo ${X-nil} X="garbage" echo ${X-nil} will output nil 0 However (call this "example two"): typeset -i X unset X X="garbage" echo ${X-nil} outputs garbage The language you quoted from the posix proposal says "otherwise, the variable is initially unset". Given that proposed language, example one is incorrect, because an "unset" variable should not retain its (in this example) integer properties when assigned a string. > What simple scalar other than a string is useful "declared but not set"? Under this interpretation, there isn't any. That's what I said. In fact the last paragraph of the very first message in this thread: "Therefore, this isn't as simple as having zsh create an unset variable when typeset is given no assignment, because subsequent assignment has to preserve the type of the variable, which normally does not apply after unset."