Ideas regarding flow control and loops
Charles D Hixson
charleshixsn at earthlink.net
Sat Nov 3 10:05:47 PDT 2007
Marco Aurélio wrote:
> Hello! I've been following the development of the D programming language for some time (around 1 year), and I have to say it keeps looking better.
> ...
> 2 - for .. finally, while .. finally:
>
> This would allow having something like:
>
> while(someCondition)
> {
> DoSomething();
> } finally {
> DoOtherThing();
> }
>
> The "finally" block would be called at the end of the repetition, only if no "break" was used. This may not seem useful at first, but I think can reduce the number of flags needed to implement various algorithms, making the code faster and more elegant. I'm not sure if this is already possible with scope guards.
>
> That's it.. What do you think?
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.
More information about the Digitalmars-d
mailing list