Subject: Re: PROPOSAL: API for environmental sensors
To: None <tech-kern@netbsd.org>
From: Greg A. Woods <woods@most.weird.com>
List: tech-kern
Date: 11/22/1999 00:22:07
[ On Sunday, November 21, 1999 at 13:13:55 (-0500), der Mouse wrote: ]
> Subject: Re: PROPOSAL: API for environmental sensors
>
> So generate them mechanically; I have a program "renumber" that's
> specifically designed for producing the numbers for lists of #defines
> like these, and it has a mode where it generates walking bits instead
> of consecutive small integers.

That doesn't help much -- just add more custom tools and junk.

> > I'm beginning to find that one-bit bit-fields are much more elegant
> > and make my code very easy to understand.
> 
> And they have plenty of problems of their own, most notably that they
> make it impossible to manipulate more than one bit (or field, if you
> use multi-bit fields) at a time.

That's not quite true -- unions to the rescue!

In any case it's rare, at least in my experience, to want to manipulate
multiple bits in APIs like this, and indeed if you do so it's much much
much better to be 100% clear about what you're doing and let the
compiler worry about optimisation.

-- 
							Greg A. Woods

+1 416 218-0098      VE3TCP      <gwoods@acm.org>      <robohack!woods>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>