Lazy evaluation of function arguments in D
Matej Nanut
matejnanut at gmail.com
Mon May 21 06:17:23 PDT 2012
I either think lazy should remain as it is, or that delegate
syntax should be explicit. But if delegate syntax is explicit,
»lazy« isn't needed anymore. The whole point of it is to have
nice syntax at the call site. Delegate syntax is, however,
conscise enough already.
Bugs due to lazy might happen, although its use is extremely rare
anyway.
I'm not sure what to say about "i" versus "i()" when using lazy
parameter "i" in a function. I'm leaning towards explicit "i()"
(DMD allows both on my machine), because just using "i" is kind
of misleading. EXCEPT if using plain "i" would only evaluate the
expression once, and "i()" for every time we use it. (And only
one notation would be permitted per function).
(This obviously doesn't change any confusion from the call site.)
What do you think?
More information about the Digitalmars-d
mailing list