Loop iterator - example.txt
Alexander Panek
alexander.panek at brainsware.org
Sun Apr 30 07:26:58 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
> }
How about we all try to avoid GOTOs and you implement this keyword? :P
Regards,
Alexander Panek
More information about the Digitalmars-d
mailing list