August 23, 2006
Tom S wrote:
> While we're at it, how about allowing the construct:
> methodName (arg, arg, ..., arg, { ... });
> 
> to be equivalent to:
> methodName (arg, arg, ..., arg) { ... }
> 
> 
> and
> methodName ({ ... });
> 
> to
> methodName {}
> 
> 
> Then e.g. the 'dotimes' example from 'Lazy Evaluation of Function Arguments' would become:
> 
> void foo() {
>     int x = 0;
>     dotimes(10) {
>         writef(x++);
>     }
> }
> 
> 
> Which eliminates the need for lazy evaluation in this case, as it simply uses a delegate. Moreover, it is more readable and concise at the same time.

It is a good idea and I've bandied it around before, and it has its merits. One of its problems is it only works for cases where the delegate is the last parameter. Can't have arrays of delegates like the example in http://www.digitalmars.com/d/lazy-evaluation.html.

It also doesn't work where one wants the lazy evaluation function to return a value.
1 2
Next ›   Last »