Loop iterator - example.txt
Bruno Medeiros
brunodomedeirosATgmail at SPAM.com
Sun Apr 30 10:34:44 PDT 2006
Walter Bright wrote:
> Rick C. Hodgin wrote:
>> int i;
>> for (i=0; i<10; i++)
>> {
>> if (string.substr(i,1) == something)
>> {
>> i += some_other_function();
>> retry;
>> }
>> else if (string.substr(i,1) == something_else)
>> {
>> i += some_other_function2();
>> retry;
>> }
>> // Otherwise, simply execute the "i++" and re-test
>> }
>
> I know goto's are evil, but I tend to write such as:
>
> int i;
> for (i=0; i<10; i++)
> {
> Lretry:
> if (string.substr(i,1) == something)
> {
> i += some_other_function();
> goto Lretry;
> }
> else if (string.substr(i,1) == something_else)
> {
> i += some_other_function2();
> goto Lretry;
> }
> // Otherwise, simply execute the "i++" and re-test
> }
That wouldn't be the same, since for what they said, "retry" should
re-test the condition (i<10), not just re-execute the block.
--
Bruno Medeiros - CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d
mailing list