On Mon, May 09, 2005 at 10:53:16PM +0300, Oron Peled wrote:

> #define D_(op,d,txt)    \
>            [ FOO_##op ] {       \
>                    .opcode = FOO_##op, \
>                    .dir = d, \
>                    .name = #op, \
>                    .desc = txt \
>            }
> 
> static foo_commands_t foo_commands[] = {
>         D_(RING,   LEFT,  "Start/Stop Ring"),
>         D_(STATUS, RIGHT, "Status Detect"),
>               ... assume a long list ...
> };

Oh no, I have flashbacks of the Xen ring macros.

> Now I'll admit this was written by me (kernel code, not yet
> distributed). These sort of ugliness is justified IMO only when
> the alternative is uglier. In this case, you'd need to initialize
> the array and assure that each opcode (which comes from a separate
> enum BTW), falls into its index and contains the correct name --
> and remember that repetitions are a big no-no in vomit-land.

While this code is rapidly changing and evolving, assuming indeed that
the list is long (over 10 entries?), I conceded that the principle of
least ugliness wins. Once the code is no longer changing (is in
maintenance mode, so to speak), I'd argue that this should be
unrolled, unless the list is *really* long (let's say, several tens of
entries). 

But hey, it's a matter of taste. 

Cheers,
Muli
-- 
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/


=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to