DMD 0.148 - scope guard

Unknown W. Brackets unknown at simplemachines.org
Sun Feb 26 12:26:44 PST 2006


I'm not at all disagreeing; but aside from language constructs like 
looping, which seem to be (in my experience) the easiest thing to get a 
good grasp on for newcomers, there aren't many ways in which (general) 
programming is non-linear.

I am saying this is strange; tasks, in many cases, are not linear. 
Obviously it must map well to something the computer understands, but 
that can often be handled by the compiler (as in this case.)

For example, academic programming typically teaches that multiple 
returns in a function are evil.  This is because it is mixing non linear 
programming (not returning always at the very end) with linear programming.

Scope exit and such cases are a good example of a clean way to resolve 
this problem without saying that "returns and continues are evil." What 
more, they are logical.

-[Unknown]


> Consider the for loop:
> 
>     for (expr; expr; expr)
> 
> The 3rd expression is executed at the *end* of the loop, yet it is placed at 
> the beginning. So there is precedent for the utility of putting code where 
> it conceptually belongs rather than where it is executed.



More information about the Digitalmars-d mailing list