Lazy eval -- an example issue

kris foo at bar.com
Tue Aug 22 01:41:24 PDT 2006


Walter Bright wrote:

> I've been thinking a lot about the escape problem. I'm pretty sure that:
>     char[] delegate() { return "foo"; }
> can be detected and so I can assure you it won't cause the enclosing 
> function's variables to be allocated on the heap.

And what about those cases where the expression is somewhat more 
complex? Will you revert all this ambiguity when a bogus heap-frame is 
demonstrated? One where the intent was never to create a delegate, but 
simply to evaluate an argument expr instead? Or will you insist that a 
smarter detector is the solution?

One has to suspect that there are far more productive ways to take risks 
with a language than this one:

# somefunk (++i);
#
# vs
#
# somefunk ({++i});

the latter is not only unambiguous, it even /looks/ like a delegate. The 
former? Who knows what it does anymore



More information about the Digitalmars-d mailing list