Paul Boddie wrote:
> good_to_go = (a > 10) || (a == 0);

warning: redundant parentheses

> /* Some time later... */
> 
> if (good_to_go) ...

Breaking down complex expressions is often a good idea to improve
readability. The compiler usually doesn't care anyway - a modern
compiler would usually turn something like

        if ((a > 10) || (a == 0))
                ...

into a canonical format maybe like

        v1 = a;
        v2 = v1 > 10;
        v3 = a;
        v4 = v3 == 0;
        v5 = v2 || v4;
        if (v5) ...

and then it will filter out all the redundancy.
The version with storing to good_to_go would become

        ...
        good_to_go = v5;
        v6 = good_to_go;
        if (v6) ...

If "good_to_go" is local and no pointer to it exists, the compiler
will find out quickly enough that it can remove it.

> featuring some kind of cartoon figure showing off different code 
> examples, soliciting audience opinions, and then demonstrating that the code 
> doesn't behave at all as they would expect. I think it was a PDF.

Sounds like fun :)

- Werner

_______________________________________________
Qi Hardware Discussion List
Mail to list (members only): [email protected]
Subscribe or Unsubscribe: 
http://lists.en.qi-hardware.com/mailman/listinfo/discussion

Reply via email to