[Bf-committers] Style issue
Martin Poirier
theeth at yahoo.com
Fri Apr 14 20:10:30 CEST 2006
--- Alexander Ewering <blender at instinctive.de> wrote:
>
> On Fri, 14 Apr 2006, Davide Vercelli wrote:
>
> > r1 = get_res_1();
> >
> > if (r1) {
> > /* do stuff */
> > r2 = get_res_2();
> > if (r2) {
> > /* do stuff */
> > r3 = get_res_3()
> > if (r3) {
> > /* and so on indenting... */
> > }
> > }
> > }
> >
> > On the other hand I prefer to organize my code
> like this:
> >
> > r1 = get_res_1();
> > if (!r1)
> > return; /* or break, or continue */
> >
> > r2 = get_res_2();
> > if (!r2)
> > return;
>
> Both styles are used - for example, at the beginning
> of draw_object(), the
> second style is used..
>
> Also, there's of course always this, which is my
> preferred style in simple
> situations :)
>
> if (get_res_1() && get_res_2() && get_res_3()) {
> }
Unless you can be 100% sure all compiler garranty (or
turn off) short circuit evaluation, the execution of
your expression is undefined.
Martin
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Bf-committers
mailing list