Lazy evaluation of function arguments in D

Roman D. Boiko rb at d-coding.com
Sat May 19 22:32:26 PDT 2012


On Saturday, 19 May 2012 at 23:03:50 UTC, Walter Bright wrote:
> http://www.reddit.com/r/programming/comments/tui75/lazy_evaluation_of_function_arguments_in_d/

Lazy evaluation has been discussed previously, but this topic is 
important and the problems have not been solved yet.

Functional languages, like Haskel, Scala or F#, have the 
semantics of lazy evaluation which is to evaluate things at most 
once. Evaluating many times is accomplished via a function or 
delegate.

Thus lazy in D is (IMO):
* confusing, because it doesn't take into account lazy semantics
* close to useless, because functions or delegates could do the 
same job and not confuse the users
* somehow hiding the need to have the functionality of evaluating 
an expression at most once. For example, I need this to work with 
immutable data, but it is not possible conceptually at this 
moment (clearly, evaluating and storing the result would mutate 
the data). I understand that designing this would mean there is 
the need for synchronization for immutable data. But at least 
this functionality could exist for pure functions.


More information about the Digitalmars-d mailing list