On Fri, 8 Jun 2001, Mike A. Harris wrote:

> On Fri, 8 Jun 2001, Andrew James Richardson wrote:
> 
> >> > <    if ( !image )
> >> > ---
> >> > >    if ( !image || !image->Data)
> >> >
> >
> >Brian,
> >
> >   I thought that in the C specs you can't be guarenteed the order of
> >evaluation in an if brace. Surely a safer bet is
> >
> >     if(!image){
> >             if(!image->Data){
> >                     ...
> >             }
> >     }
> >
> >  If you know better I stand corrected, I'm just thinking that not all
> >target platforms will use gcc (which I presume is the one that is used in
> >this case).
> 
> The associativity is left to right.  It is guaranteed standard C.
> 
> if(a && b && c && d)
> 
> Where a is evaluated first always, then b, but only if a is true.
> The first left to right statement that is false stops further
> conditions from being checked.
> 
> This allows for example - optimization, by putting the
> conditionals in order of most likely to be false to least likely,
> you optimize for the most common case in the test.
> 
> When using ||, the associativity is the same, but then in the
> case:
> 
> if(a || b || c || d)
> 
> b is only evaluated if a is false.  The first one evaluating
> "true" from left to right makes the whole statement true, and
> thus no further condition testing need be made.
> 
> Also, your above example does not do the same as the original.
> The original says  "if a and b then c", while yours says:
> 
> "if a and b then c"
> 
> Your multiple if block is syntactically equivalent to
> 
> if ( !image && !image->Data)
> 
> Notice the flipping of || to && from the original example.

Your right :)

Ok we can all re-write it to work proper, but as one is assured that
associativity is strict left2right then were all OK, maybe Im thinking
if the , operator (but youll problably say that that is strict left2right
too!!).

        Cheers
                Andy

> 
> 
> 
> ----------------------------------------------------------------------
> Mike A. Harris                  Shipping/mailing address:
> OS Systems Engineer             190 Pittsburgh Ave., Sault Ste. Marie,
> Red Hat Inc.                    Ontario, Canada, P6C 5B3
> http://www.redhat.com           Phone: (705)949-2136
> ----------------------------------------------------------------------
> Latest XFree86 test RPMS:      ftp://people.redhat.com/mharris/testing
> 
> 
> 
> 
> _______________________________________________
> Dri-devel mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/dri-devel
> 

                    \\  - -  //
                     (  @ @  )
+---------------o00o----(_)----o00o-------------------------------------+
|Andy Richardson                          Dept. of Chemistry            |
|t(w): +44 171 380 (7465)                 University college London     |
|t(h): +44 181 352 (0848)                 Gordon street                 |
|e: [EMAIL PROTECTED]        London WC1E 6BT         UK    |
+------------------------------0ooo-------------------------------------+
                   ooo0        (   )
                  (   )         ) /
                   \ (         (_/
                    \_)


_______________________________________________
Dri-devel mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to