Loop iterator - example.txt

kellywilson at nowhere.com kellywilson at nowhere.com
Sun Apr 30 12:28:17 PDT 2006


Thanks Derek,

I see your point, I was just sort of going off of Kyle's quote "and the
functionality is clearly the same" without realising he meant the overall
functionality, and not the keywords (oops). I was also looking at the while loop
example code and it seemed that the two would be the same (just for that
construct though, I see). However, since we can just write the code with a
different construct and/or 'goto's, then should we use extra keywords and make
the language even bigger? Maybe you are suggesting that it would be easier to
just let the compiler add in the correct jumps instead of making the user add in
explicit 'goto's and possibly use a different construct? 

I think the new keyword (or words if we include 'restart' as well) may lead to
some nasty little logic bugs for new users, if they aren't careful, though. I
know that can be said about many 'new' keywords/features for newer languages,
but still, in this case it may be troublesome for those moving from C/C++.
Maybe? Thoughts?

Thanks,
Kelly Wilson

P.S. Your example does rather pointedly show that this can all be solved easily
with some 'goto's as Walter showed/suggested earlier ;) One argument for goto's
follows:  http://www.ppig.org/papers/12th-marshall.pdf
or here:  http://www.stevemcconnell.com/ccgoto.htm


In article <op.s8tl32d56b8z09 at ginger.vic.bigpond.net.au>, Derek Parnell says...
>
>On Sun, 30 Apr 2006 20:34:09 +1000, <kellywilson at nowhere.com> wrote:
>
>
>> Anyways, easy to add keyword, but in the same place as "continue", so  
>> why do it?
>
>Because 'continue' and 'retry' are not the same thing. 'continue' means go  
>to the next iteration, and 'retry' means repeat the same iteration.
>
>....CONCEPTUAL CODE....
>
>    for_start:
>        init_code;
>    for_test:
>        if ( end_condition ) goto for_end;
>    for_body:
>        do_something;
>        if <A> goto for_index; // continue
>        if <B> goto for_test; // retry
>        if <C> goto for_start; // restart
>        if <D> goto for_end; // break;
>    for_index:
>        update_index;
>        goto for_test;
>    for_end:
>
>
>-- 
>Derek Parnell
>Melbourne, Australia





More information about the Digitalmars-d mailing list