From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13086 invoked from network); 15 Oct 2003 06:22:03 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 15 Oct 2003 06:22:03 -0000 Received: (qmail 12695 invoked by alias); 15 Oct 2003 06:21:46 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6704 Received: (qmail 12640 invoked from network); 15 Oct 2003 06:21:46 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 15 Oct 2003 06:21:46 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [4.3.58.249] by sunsite.dk (MessageWall 1.0.8) with SMTP; 15 Oct 2003 6:21:45 -0000 Received: (from schaefer@localhost) by candle.brasslantern.com (8.11.6/8.11.6) id h9F6Lh723224 for zsh-users@sunsite.dk; Tue, 14 Oct 2003 23:21:43 -0700 From: Bart Schaefer Message-Id: <1031015062143.ZM23223@candle.brasslantern.com> Date: Wed, 15 Oct 2003 06:21:43 +0000 In-Reply-To: <20031014171741.GG211@DervishD> Comments: In reply to DervishD "Re: Is this an orthodox use of zstyle?" (Oct 14, 7:17pm) References: <20031014160041.GA343@DervishD> <1031014164250.ZM22562@candle.brasslantern.com> <20031014171741.GG211@DervishD> X-Mailer: Z-Mail (5.0.0 30July97) To: Zsh Users Subject: Re: Is this an orthodox use of zstyle? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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.