From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 3397024B46 for ; Sat, 9 Mar 2024 15:31:25 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1709994685; b=N97u7O0u7oGPt9Jh9E66pBB61obV/joCtE4mXz+UOl5XT/G2gB0kAwj0acrrBoh01MbK7BKwQV KHbGcFvlxkWIou0A+wlE159nYAdVAwE6S9MQv6200QZ70Pb3zDcW+XjXdN7APsu0URwOkQayOE Xm4wibVVe2cfsLzI+1JKDIcOSAmrJ/sfhZHuLONJIhxvCh7LLeQCDtshVPKWYLNMwvUpLYuUsd F/v7QodmQE4nRu3XfINCBfOMNMhuW3xuRE4ELGMu1Di3YPoT2GtRCALLXF1BwEZEGGexNiExua 5mAHrd4fh3pJEqbzifk9jqkDwfe5hwihDVLYYfdlfKbzFA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay6-d.mail.gandi.net) smtp.remote-ip=217.70.183.198; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1709994685; bh=5aV99AnuLiERuXXfgVKfJmcv+na0MgT6PcrFgwWHguk=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version: Message-ID:Subject:To:From:Date:DKIM-Signature; b=Xhbj9BoHJmaKYoCATKKrjs5tsKkp2jQ160iWPrSet2BVjcXC54POOr5tYFbJZ/N9ZO1vV4N953 o5DX5ZjV6FM1egpFT7RbSjVZmDSBpAR1sMAq+VkU5MjEhugQntCjD0sgx/t86G0JENw88ZlGBP sU8zpD9AoaimWyIOZh++VF/Cp/AR0GgiZk55GrGaXzLKtbLJs/5IZtNJunm2BIY0eXaybk8Pka lAdm3FLGHkH+tyM8Dp9AIMz3o/oqJC/dR5wyRDbJnhr5xjtWYBtBxZTgpi6EB6InOBuxPT2SeV +nhYCKJSBT+7a4qOFeqQXdlWLPrajvXynp62y1iuzYrX3A==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Message-ID:Subject:To:From:Date:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=t6h0exSakR0HQ6M5fXJFQhvFqUs7TzrpdYrRKB/v04Q=; b=piFB0W4DPjsvPtqIU2oMk9iGr0 iJBMHzz36iLsts/oULzcvMVyps1l05UVCJAm9MJNNxB7Ot1n0lnWnsIe9vI8Onvc3ebgjxrFlh5jT zOseIqcFB51t9exk1yzDxKbzlDg4DKyO0ybERwc+BZIDV565Sch/0v/gSypw+XrG0T4hVyeo2URbW N6r864qb5t4twTnDdOHLwSihTLZQIENcL+9hkvpJjq3cdC5XjF9r5QzB2rO2ifQ677iTUOaWMLhfQ ukC+bSbBG7yKL9wEM/hg8y3JKNLQLEmeilO5VPmu36bHq1e4lZjRDddHVbmFlHTLsPsCmjVD2sCsp yKPWL7uQ==; Received: by zero.zsh.org with local id 1rixjR-0002sR-HB; Sat, 09 Mar 2024 14:31:25 +0000 Authentication-Results: zsh.org; iprev=pass (relay6-d.mail.gandi.net) smtp.remote-ip=217.70.183.198; dmarc=none header.from=chazelas.org; arc=none Received: from relay6-d.mail.gandi.net ([217.70.183.198]:49169) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1rixih-00029v-A9; Sat, 09 Mar 2024 14:30:39 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 130A2C0002 for ; Sat, 9 Mar 2024 14:30:37 +0000 (UTC) Date: Sat, 9 Mar 2024 14:30:36 +0000 From: Stephane Chazelas To: Zsh Users List Subject: Why would I use .namespace.myvar? Message-ID: <20240309143036.xwqm234mtu5wqh2r@chazelas.org> Mail-Followup-To: Zsh Users List MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-GND-Sasl: stephane@chazelas.org X-Seq: 29722 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: (not sure which of zsh-users or zsh-workers is best suited for this discussion, I'm picking zsh-users for now but please feel free to move to zsh-workers in follow-ups). I didn't read the initial discussions around the introduction of namespaces in the current development version of zsh, but from what I can tell it means: - "." can now be used in the name of a variable, though with limitations: * .foo, foo., a.b, .a.b, a.1, .a.1x are OK, but not ..foo, .foo., .1.a, foo.., a.b.c, .a.b.c * you can refer them as ${a.b}, but not $a.b (understandably) - the ones starting with . (and not having them starting with . is discouraged, presumably because that would conflict with ksh93's compound variables which zsh might want to support in the future?) are hidden from the output of "set"/"typeset" and there's no way to unhide them even with typeset -h, except with things like: typeset -p ${(kM)parameters:#.*} It's always been possible to use . (or any character or non-character, even the empty string) in function names, so functions are not covered in the new feature. And unless I'm missing something, that's it. In particular, as noted in the doc, there's no support for ksh93's: $ namespace foo { a=1 b=2 c=3; }; echo "${.foo.a} ${.foo.b} ${.foo.c}" 1 2 3 So why would I use a ${.mynamespace.myvar} over $_mynamespace_myvar, $ːmynamespaceːmyvar or $𐅂mynamespace𐅂myvar (which do work on GNU systems at least as ː, 𐅂 as well as hundreds of other characters which look appropriately shaped for the purpose are classified as alpha (in locales whose charmap have them) there) for my variables which I would want namespaced? AFAICT, that doesn't give me more guarantee of avoiding clashes, and that means I have to use those braces. I could also hide my _mynamespace_myvar variable with typeset -h if I wanted to. Is there a chance that ksh93's namespace keyword be added in the future? Would the fact that function names have been allowing . since forever or that .foo or .foo.1 are allowed not be a problem? How about nested namespaces? Is using ${.foo.bar} going to be recommended going forward for namespacing variables in user-contributed code shipped with zsh? Is the intention to reserve those for code included with zsh to users can be sure not to clash with the zsh ones if they don't use them? Thanks Stephane