:: Re: [DNG] Icerbergs aren't small ju…
Top Page
Delete this message
Reply to this message
Author: Didier Kryn
Date:  
To: dng@lists.dyne.org
Subject: Re: [DNG] Icerbergs aren't small just because they're mostly underwater
Le 25/01/2016 19:11, Rainer Weikusat a écrit :
> Didier Kryn <kryn@???> writes:
>
> [...]
>
>>> A multi-line version could look like this:
>>>
>>> while (c = *r) {
>>>     ++r;
>>>           if (c == '/') n = r;
>>> }

>>>
>>      It might be done with a for loop.  eg:

>>
>>      for ( ; *r ; ++r) if(*r=='/') n=r;
>> n++;
> [...]

>
>> The for loop is the best construct for a loop with an incremental
>> cursor.
> That's nicely exemplified by the fact that the code above does a
> redundant increment (or did a redundant increment would it work, the {}
> are missing)

     There needs only be one increment of n at the end of the loop, but, 
maybe it should be:
     if(n) n++;
     because I guess n starts from 0.

> solely to work around the fact that the "for loop
> mechanics" of checking the condition before the loop body is executed
> and performing a "variable increment step" afterwards are ill-suited to
> this particular problem ...
>


     I must agree, and I didn't think it was true before reading your 
example, that the post-increment may have a true semantic value beyond 
an attempt to optimise execution which would be futile. Which doesn't 
mean I'm convinced it :-)


     Didier