On Wed, 2012-07-25 at 02:40 +0000, Tabi Timur-B04825 wrote:
> Michael Ellerman wrote:
> > I agree these values are odd. But there's no rule that you can only use
> > an enum if the values are monotonically increasing.
> >
> > It can still serve as helpful documentation, and reduce the number of
> > places you pass a bare int around.
> 
> IMHO, an enum should only be used if
> 
> 1) You are doing real type checking of the enum

Yes, if you're going to define an enum you should use it, which this
patch doesn't, but that's just a bug in this patch.

> 2) You don't care what the actual values of each enum is

I disagree.

They make even more sense when you don't care what the values are, but
that doesn't mean you should only use them in those cases.

And the bible, K & R, includes an example of an enum which explicitly
specifies all its values. It goes on to say "enumeration variables offer
the chance of [type] checking and so are often better than #defines".

cheers

_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Reply via email to