At 10:00 AM 5/3/2006, Joe Orton wrote:
On Wed, May 03, 2006 at 09:41:14AM -0400, Greg Marr wrote:
> At 05:32 AM 5/3/2006, Joe Orton wrote:
> >> +    me->cnt_max = max_threads;
> >> +    me->idle_max = init_threads;
> >> +    rv = apr_thread_mutex_create(&me->lock,
> >APR_THREAD_MUTEX_NESTED,
> >> +                                 me->pool);
> >> +    if (APR_SUCCESS != rv) {
> >
> >Personally I find the "constant != variable" style very distracting,
> >not sure if this is a widely held view...
>
> FYI, I use it almost exclusively, because if you mean to type
>
> if (APR_SUCCESS == rv)
>
> and instead you type
>
> if (APR_SUCCESS = rv)
>
> the compiler will catch it for you. If you normally do variable ==
> constant instead, you have no such protection.

GCC has issued a warning for "if (foo = 2)" forever, if you aren't running your code through gcc -Wall regularly you have more serious problems anyway, certainly that's not worth sacrificing readability for IMO.

I mostly work on Windows, and VC++ only recently added a warning for that. I've been using this style for so long that it doesn't sacrifice readability, and in fact, the var == const form looks wrong now. However, this is entirely a personal preference.

Reply via email to