Loop iterator - example.txt

Bruno Medeiros brunodomedeirosATgmail at SPAM.com
Mon May 1 02:36:56 PDT 2006


Derek Parnell wrote:
> On Mon, 01 May 2006 05:18:11 +1000, Sean Kelly <sean at f4.ca> wrote:
> 
>> Bruno Medeiros wrote:
>>>  I was thinking of an example which used continues and retries in the 
>>> same for, as yours can be cleanly rewritten as the example in my 
>>> later post.
>>> Anyway, Derek's example serves as a good example of the keyword's 
>>> usage, but for "foreach", for "for" I'm still finding it a bit odd.
>>
>> I think it's more useful for "foreach" because there's no way to avoid 
>> progressing with each iteration.  However, goto still works here as in 
>> Walter's example.  "retry" is handy, but it's more a convenience than 
>> anything.
> 
> And *expressive*. That is, it signals the coder's intent more clearly 
> than a goto can because in theory the goto can go to anywhere but that 
> is not the case with 'retry'. Thus the use of 'retry' is more likely to 
> lead to less misunderstanding and bugs. So even though it is a 'goto' in 
> disguise, it is a controlled goto.
> 
> 
> 
> --Derek Parnell
> Melbourne, Australia

Hum, now that you mention it, what if goto could only jump to labels 
that are lexically visible in the current scope, using the same rules as 
  variables. Seems to me it would make goto more safe, but is such 
behavior acceptable? I mean, is there a reasonable use scenario for goto 
that requires a cross-scope jump? (I wonder if any of the cases 
presented by Walter would require such thing)


-- 
Bruno Medeiros - CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list