zsh-users
 help / color / Atom feed
* Re: A tip: a technique to limit the # of global variables
       [not found] ` <CAN=4vMq7CJjaYyfnWzrGCbomf9HaDha5xTRbnQP6fVk1g5Oh7g@mail.gmail.com>
@ 2019-10-11  8:41   ` Sebastian Gniazdowski
  2019-10-25 14:41     ` Greg Klanderman
  0 siblings, 1 reply; 2+ messages in thread
From: Sebastian Gniazdowski @ 2019-10-11  8:41 UTC (permalink / raw)
  To: Roman Perepelitsa; +Cc: Zsh Users

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: A tip: a technique to limit the # of global variables
  2019-10-11  8:41   ` A tip: a technique to limit the # of global variables Sebastian Gniazdowski
@ 2019-10-25 14:41     ` Greg Klanderman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Klanderman @ 2019-10-25 14:41 UTC (permalink / raw)
  To: zsh-users

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAKc7PVDfuyP0Q8AOazMDtRetg6ZWDGqFhu1KT3927a-Ze4RFxQ@mail.gmail.com>
     [not found] ` <CAN=4vMq7CJjaYyfnWzrGCbomf9HaDha5xTRbnQP6fVk1g5Oh7g@mail.gmail.com>
2019-10-11  8:41   ` A tip: a technique to limit the # of global variables Sebastian Gniazdowski
2019-10-25 14:41     ` Greg Klanderman

zsh-users

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-users

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git