Re: [dwm] using bitaray for tags (PATCH)

From: Anselm R. Garbe <arg_AT_suckless.org>
Date: Wed, 21 May 2008 11:26:57 +0200

Hi I like your patches (also the version of anydot).

On Wed, May 21, 2008 at 10:49:16AM +0200, Enno Gottox Boland wrote:
> 2008/5/21, Szabolcs Nagy <nszabolcs_AT_gmail.com>:
> > in config.h referencing tags has changed in rules but not in keys.
> Yes, arg has discussed yesterday if it's possible to change const char
> *arg to void *arg. if this works, i'll change the key behavior too.

Ok, I won't touch the code until the evening today, so feel free
to use the (int[]) 1 syntax, we are going to change the
argument of Key-functions to void *.

> > the (1 << tagnum) in rules is a bit nasty
> > it is probably nicer to do the shifting in setup();
> you mean in applyrules? - No I don't think so. It adds much more
> flexibility. You can define bitmasks as 0b10001 to tag a client to the
> first and the fifth tag or you can use ~0 to make it "sticky".

I agree, that allows also to get rid of cloned rules.

> > instead of
> > i < LENGTH(tags) && i < sizeof(int) * 8;
> > what about checking once
> > if(LENGTH(tags) > sizeof(int) * CHAR_BIT)
> > eprint("Maximum number of tags: %d\n", sizeof(int) * CHAR_BIT);
> > in setup();
> The problem about this is it denies users from using one config.h with
> many tags on different architectures. Furthermore I wouldn't check
> this at runtime but at compiletime. (maybe we can use "#warning" as
> compromise)

Well, regarding to

http://coding.derkeiler.com/Archive/C_CPP/comp.lang.c/2005-01/1697.html

a compile time evaluation isn't possible. So I think we should
stick to Szabolcs proposal to reject the setup in setup():

        if(sizeof(unsigned int) * CHAR_BIT < LENGTH(tags))
                eprint("error: number of tags is restricted to: %u\n", sizeof(unsigned int) * CHAR_BIT);

Usually nobody will use more than 16 tags imho, so that we
should not expect a problem here if sizeof(int) is only 2 on
some exotic hosts.

Kind regards,

-- 
 Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361
Received on Wed May 21 2008 - 11:26:57 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:43:12 UTC