Lazy eval

Walter Bright newshound at digitalmars.com
Tue Aug 22 17:10:12 PDT 2006


BCS wrote:
> I feel confident I can document all sorts of bazaar things in my own 
> code. I also feel confident that if they are allowed/promoted then other 
> people will use them and *NOT* document them.
> 
> As to others using your/my code, you can put a page and a half of 
> documentation in warning about side effects and it wont do one wit of 
> good if the other guy doesn't read it. And there is no way to ensure 
> that it will get read.
> 
> I can just see the buzz now: "Did you hear about the bonehead over in 
> XYZ department that messed up the billing program? He didn't read all of 
> the comments in the new library and ended up costing the cooperation $n 
> million dollars because of this "cool" feature in the D programming 
> language. I'll never use a D lib in /my/ work."

I agree with you that comments are always wrong, out of date, or 
missing. With the delegate feature, one doesn't need to document it, as 
it is there in the declaration of the function.

The fact that the delegate parameter exists is a pretty good sign that 
the function isn't intended to evaluate the argument exactly once, so it 
is worth trying to figure out what the function is doing before calling 
it with parameters that have side effects.

Sometimes, corporations have coding standards that ban certain 
constructs - like using templates in C++. If a particular feature does 
turn out to cause grief, it can be so banned.



More information about the Digitalmars-d mailing list