Ideas regarding flow control and loops

Bruce Adams tortoise_74 at yeah.who.co.uk
Sun Nov 4 01:04:55 PST 2007


Marco Aurélio Wrote:

> Charles D Hixson Wrote:
> 
> > No.  Finally should be the label on a block of code that will 
> > be executed *WHATEVER* happens in the preceding loop, 
> > including the raising of an exception.
> 
> Hmm Yeah, now that I think about it, having it on that way would make it inconsistent with the try-catch-finally behavior... Maybe adding another keyword? or something like:
> 
> for(int i = 0; i < 30; i++)
> {
>     if (something)
>         break;
> } catch (break) {
>     Foo();
> }

That's redundant. Its the same as

try {
  for(int i = 0; i < 30; i++)
  {
     if (something)
        throw breakException;
   }
 } catch (breakException) {
     Foo();
 }

Are you sure there's really a problem here? How about posting something 'evil'. If no-one in the group can think of a good refactoring
then you may have a case.  I suspect structured programming has been around too long to benefit much from anything new. That said, foreach was an awful long time coming so you may have a case.

Regards,

Bruce.



More information about the Digitalmars-d mailing list