:: Re: [DNG] Icerbergs aren't small ju…
Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Didier Kryn
Ημερομηνία:  
Προς: dng
Αντικείμενο: Re: [DNG] Icerbergs aren't small just because they're mostly underwater
Le 25/01/2016 13:23, Rainer Weikusat a écrit :
>      while (*r) if (*r++ == '/') n = r;


     Does it mean


     while (*r)
       {
         if (*r == '/')
    {
            n = r;
            r++;
         }
       }


or

     while (*r)
       {
         if (*r == '/')
    {
            r++;
            n = r;
         }
       }



     I think the second answer is the good one. It is more readable and 
less error-prone than your example and the compiler will produce exactly 
the same instructions. You don't need to do the work of the compiler; it 
does it better. Better concentrate on writing programs easier to read 
and less error-prone. These pre-increment and post-increment 
instructions should be deprecated - I already advocated that on this 
list, although it is not the place :-)


     The reason why seasonned programmers prefer the kind of expression 
you wrote, with post-increment, is a perfect example of a style dictated 
by pure aesthetics. This an error I used to make when I was younger, 
but, with age and learning, I have found true reasons to do otherwise.


     Didier


     Didier