Lazy eval

Frank Benoit keinfarbton at nospam.xyz
Mon Aug 21 15:44:36 PDT 2006


> Just as Walter stated, that's the same case as with 'in' vs 'inout' vs
> 'out' arguments. You don't know what will happen in either case

If an argument is in/out/inout it is clear from the content and context.
If it is out, you call the function to get something.

lazy-eval syntax
When I code, I often guess what the method is called and what arguments
it has.
For example i have a container with a add( element ) method. Now this
method is implemented with lazy-eval, if the container is already full,
the argument is not evaluated.
Or the get( index ) method does not eval the arg if the container is
empty. And every time I have not only to remember the method name and
arguments, now I have to know details of the implementation.
Great, that was the silly thing they wanted to take away from me with
this OOP ;)

Solution: Force the user the make {} around a delegate argument.

Now I get a compiler error when writing container.get(i++); Then I know,
this is a delegate, take care with the increment, writing
container.get({i}); i++;





More information about the Digitalmars-d mailing list