zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@sunsite.dk>
Subject: Re: Is this an orthodox use of zstyle?
Date: Wed, 15 Oct 2003 06:21:43 +0000	[thread overview]
Message-ID: <1031015062143.ZM23223@candle.brasslantern.com> (raw)
In-Reply-To: <20031014171741.GG211@DervishD>

On Oct 14,  7:17pm, DervishD wrote:
}
}     Well, the first widgets I want to modify using state information
} really don't need contexts, but I think that I may need it in the
} future, for example if I write any completion widget (I don't use
} compsys), so it may be a good thing using styled from the beginning.

That's a good argument for looking up configuration options with styles,
but not for storing transient state with zstyle.  Ask yourself whether
you'll ever be looking up the state with a more-specific context than
that under which you stored it.  If the answer is that you always know
the precise context for both storage and retrieval (even if there may
be more than one such context), then parameters are probably the better
way to go.

However, if you've got some really creative way to use "zstyle -e" or
some such, go for it.

}     [...] I don't want nor need to export the state, so
} this is not an issue. Anyway, since styles doesn't pollute namespace,
} wouldn't be better to directly use them for storing state information
} even without contexts?

True, styles don't pollute the parameter namespace, but they do pollute
the zstyle namespace.  In either case all you need is a convention for
your names that isn't likely to collide with someone else's convention.

Drawbacks of using zstyle for transient data:

Styles are looked up by matching a series of pattern keys against the
probe, rather than by matching a single pattern probe against a series
of keys.  It's therefore more expensive to look up a style than a
parameter.  (It's like using ${assoc[(k)probe]} when ${assoc[probe]}
would suffice.)

To use styles as arrays or associative arrays, you have to assign them
to a parameter with "zstyle -g", then reset the style from the value
of the parameter again to save the state.


  reply	other threads:[~2003-10-15  6:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-14 16:00 DervishD
2003-10-14 16:42 ` Bart Schaefer
2003-10-14 17:17   ` DervishD
2003-10-15  6:21     ` Bart Schaefer [this message]
2003-10-15  9:54       ` DervishD
2003-10-15 15:15         ` Bart Schaefer
2003-10-15 19:00           ` DervishD
2003-10-16 14:40             ` Bart Schaefer

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=1031015062143.ZM23223@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.dk \
    /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).