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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 6592 invoked from network); 5 Mar 2023 09:11:13 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 5 Mar 2023 09:11:13 -0000 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:Message-ID:Date:Content-ID: Content-Type:MIME-Version:Subject:To:References:From:In-reply-to:cc:Reply-To: Content-Transfer-Encoding:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=VSKWpuijNDLpGO6ru07ivOj9Ga0vJX6yBZfB94Q8IXw=; b=NJrPTY2L5r9Jp/9Uf5S/EIJ78Z Hpg56+MQ1LRQOSU3mb0JomdCADlbDZGZOvRzQlHxml7HLP7x1yBucf30iynDqo5UcN8+BmNZFn9ZP SUKamxXuQDNJEOtuIAZMcjcjRSJjTW4yCPDm80Vbj85US2+LYjK45pcplN6fws/E8/VHxlONqGWWl V2lO6kwfw+ZnP/IawUXrZP8t27rz0EFTyIio1MoRjIoC88lUqGf2BKmRs0VMskPovhP8FxJiMz/Dk CEnX/cmikIKBp4+jOVNm3GuIBzRcjBlK930N1dQUgck0kecbfLUk1m5V+r8d9gDvo53yQoFha0+K8 b2rRVX0g==; Received: by zero.zsh.org with local id 1pYkOe-000DlF-MK; Sun, 05 Mar 2023 09:11:12 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1pYkO4-000DQn-KY; Sun, 05 Mar 2023 09:10:36 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.95) (envelope-from ) id 1pYkO3-0006o7-6F; Sun, 05 Mar 2023 10:10:35 +0100 cc: Zsh hackers list In-reply-to: From: Oliver Kiddle References: To: Bart Schaefer Subject: Re: [PATCH 1/3] Extended ksh compatibility: namespace parameter syntax MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <26169.1678007435.1@hydra> Date: Sun, 05 Mar 2023 10:10:35 +0100 Message-ID: <26170-1678007435.186071@mDq6.Euc0.bAwZ> X-Seq: 51502 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: On 26 Feb, Bart Schaefer wrote: > The attached patch enables assignment of and reference to parameters > prefixed with ksh-style namespace syntax, e.g., ${.namespace.param}. > As yet, there's no special significance to use of this syntax, that > is, parameters having such a prefix are ordinary parameters like any > others, with the usual dynamic scoping rules, etc. Each of namespace > and param must be an identifier in the original zsh semantics of > identifiers. I've been running this patch since you posted it and haven't found it to cause any problems as such. It also holds up to testing but with no way to assign to variables with a dot in their name, there's a limit to what's possible to test. My main concern is that in the absence of special significance to the syntax up-front it could be harder to add later. At least the documentation should warn so users should not be surprised if e.g, in the future, `local foo` will hide a ${foo.bar}. But every new module like ksh93 could need reworking if the implementation changes so that this is a bar entry in a foo hash table instead of a foo.bar entry in a global hash table. I'm not sure how ksh implements the initial dot. It effectively blocks consecutive dots because you have to declare the parent first. Ksh uses dots both for namespaces and compound variables. Of the two, compound variables are definitely the most useful. The namespace { ... } syntax of ksh was not designed with the interactive nature of the shell being considered foremost. I like the aspect of hiding shell specific variables away below .sh - could also be good for .zle. I think it is a mistake to not make compound variables, namespaces and associative arrays merely different facets of the exact same underlying thing. I'd like to be able to dump variables out as json/xml/yaml and reimport them back without the loss of detail of which type they started out as. Oliver