Loop iterator - example.txt
James Dunne
james.jdunne at gmail.com
Mon May 1 09:17:49 PDT 2006
Derek Parnell wrote:
> On Sun, 30 Apr 2006 20:06:34 -0700, Walter Bright wrote:
> [snip]
>>6) to, for instance, collect all error handling code in one spot in a
>>function
>
> Yes, this is a very common usage for goto statements. Not so much as a
> performance enhancer because errors are supposed to be infrequent, but to
> improve source code maintainability. However, I believe that the benefit of
> goto usage here is lost due to the 'uncontrolled' nature of it. It
> introduces labels that can theoretically be reached from places other than
> the error handlers. In spite of that, I feel that this is a prime candidate
> for new syntax to deal with the problem of consolidating error handling
> code. It could be thought of an extension to D's 'try-catch' and 'scope'
> constructs, so I would encourage you to consider further evolving D into a
> language to delight code authors and maintainers, and also compiler
> writers.
In my own language I've come up with the try/failure block in
combination with the 'fail' statement. It's basically like this:
try {
if (conditionA) fail;
if (conditionB) fail;
if (conditionC) fail;
success;
} failure {
writef("An error occurred! Cannot proceed.\n");
}
--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/MU/S d-pu s:+ a-->? C++++$ UL+++ P--- L+++ !E W-- N++ o? K? w--- O
M--@ V? PS PE Y+ PGP- t+ 5 X+ !R tv-->!tv b- DI++(+) D++ G e++>e
h>--->++ r+++ y+++
------END GEEK CODE BLOCK------
James Dunne
More information about the Digitalmars-d
mailing list