Ideas regarding flow control and loops

BCS ao at pathlink.com
Sun Nov 4 16:38:33 PST 2007


Reply to Bruce,

> 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();
> }

Tell me that is a joke. If you don't see the problems with that then....

Do you have any idea how mush potential for overhead there is in that? The 
other solution has one jump, that has a memory allocation (and a free at 
some point) a bit of stack un winding, Maybe a RTTI work and who only known 
what else. Plus it will (incorrectly) trigger any intervening scope(failure) 
and sooner or later you will need to start fabricating types to keep track 
of what loop the break is for.

> 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