From: Greg Klanderman <gak@klanderman.net>
To: zsh-users@zsh.org
Subject: Re: A tip: a technique to limit the # of global variables
Date: Fri, 25 Oct 2019 10:41:50 -0400 [thread overview]
Message-ID: <871rv099ap.fsf@lwm.klanderman.net> (raw)
In-Reply-To: <CAKc7PVC05MTPJXrSOC_n5NGs=08Yg6TV2wMryPsG+tH0XwEh7g@mail.gmail.com> (Sebastian Gniazdowski's message of "Fri, 11 Oct 2019 10:41:04 +0200")
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 <sgniazdowski@gmail.com> wrote:
> On Fri, 11 Oct 2019 at 10:27, Roman Perepelitsa
> <roman.perepelitsa@gmail.com> wrote:
>>
>> On Fri, Oct 11, 2019 at 10:21 AM Sebastian Gniazdowski
>> <sgniazdowski@gmail.com> 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<TAB> 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
prev parent reply other threads:[~2019-10-25 14:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAKc7PVDfuyP0Q8AOazMDtRetg6ZWDGqFhu1KT3927a-Ze4RFxQ@mail.gmail.com>
[not found] ` <CAN=4vMq7CJjaYyfnWzrGCbomf9HaDha5xTRbnQP6fVk1g5Oh7g@mail.gmail.com>
2019-10-11 8:41 ` Sebastian Gniazdowski
2019-10-25 14:41 ` Greg Klanderman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871rv099ap.fsf@lwm.klanderman.net \
--to=gak@klanderman.net \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).