From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 5d3038c7 for ; Fri, 25 Oct 2019 14:43:09 +0000 (UTC) Received: (qmail 15971 invoked by alias); 25 Oct 2019 14:43:02 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24382 Received: (qmail 198 invoked by uid 1010); 25 Oct 2019 14:43:01 -0000 X-Qmail-Scanner-Diagnostics: from mail-s33.mailgun.us by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.0/25608. spamassassin: 3.4.2. Clear:RC:0(184.173.153.33):SA:0(-2.0/5.0):. Processed in 1.637267 secs); 25 Oct 2019 14:43:01 -0000 X-Envelope-From: bounce+88e79d.97dbd8-zsh-users=zsh.org@klanderman.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at spf1.mailgun.org designates 184.173.153.33 as permitted sender) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=klanderman.net; q=dns/txt; s=mg; t=1572014580; h=Content-Type: MIME-Version: References: Message-ID: In-Reply-To: Date: Reply-To: Subject: To: From: Sender; bh=/+Adwu/QGqkxOiYlwxMcOkt51uxn3b/pwUCbyTlmBbw=; b=QR+bfQJPgSLqH4Mg1c+bE6//7EaX6fJ5Qgf+7eCTynsirEOvfU/ABhor4zaieo2JcOF5OdM3 9czbZE2dEIk0lvw4DDSPfkBsG1q8/Znop6aMERhScD6cNeFTOJOu3C6rRc5WQm1MKHZghppy /FqRpqoE3rYh/sEqR5LliU/Z1JY= X-Mailgun-Sending-Ip: 184.173.153.33 X-Mailgun-Sid: WyIzOGFmNSIsICJ6c2gtdXNlcnNAenNoLm9yZyIsICI5N2RiZDgiXQ== Sender: gak@klanderman.net From: Greg Klanderman To: zsh-users@zsh.org Subject: Re: A tip: a technique to limit the # of global variables Reply-To: Greg Klanderman Date: Fri, 25 Oct 2019 10:41:50 -0400 In-Reply-To: (Sebastian Gniazdowski's message of "Fri, 11 Oct 2019 10:41:04 +0200") Message-ID: <871rv099ap.fsf@lwm.klanderman.net> User-Agent: Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.24 (linux) References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii IMO, just have internal vars start with '_', and use this: | # do not complete functions/parameters that start with '_' or '.' unless explicitly matched | zstyle ':completion:*' prefix-needed true Greg >>>>> On October 11, 2019 Sebastian Gniazdowski wrote: > On Fri, 11 Oct 2019 at 10:27, Roman Perepelitsa > wrote: >> >> On Fri, Oct 11, 2019 at 10:21 AM Sebastian Gniazdowski >> wrote: >> > >> > Hello, >> > when writing a plugin one often needs to keep a state during the Zsh >> > session. To do this it is natural to use global parameters. However, >> > when the number of the parameters grows one might want to limit it. >> >> What are the advantages of having fewer global parameters? Why is it >> better to have this: >> >> typeset -gA PLGMAP=(foo 42 bar hello) >> >> Than this: >> >> typeset -gi PLGMAP_foo=42 >> typeset -g PLGMAP_bar=hello >> >> Roman. > I think that it's about not "cluttering" the global namespace with the > parameters. Zplugin had 37 global parameters, now it has only 16. Even > a situation when a curious user enters print $ZPLG and sees fewer > entries is positive. This hides implementation, on the other hand, but > one can decide what to hide when writing, i.e. what isn't meaningful > for a curious user. > PS. The message should go to zsh-users, hence I'm moving it there. > -- > Sebastian Gniazdowski > News: https://twitter.com/ZdharmaI > IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin > Blog: http://zdharma.org