lazy evaluation

Manfred Nowak svv1999 at hotmail.com
Mon Jun 4 02:35:35 PDT 2007


Frits van Bommel wrote

> How about something like this:

You describe a generic pattern for memoizing the obvious result of 
calls; obvious in the sense of forgetting about side effects.

The question Pierre's post rises: is there a way to implement this 
pattern in D in a way, which is easy to capture?

As it seems there is currently no such way.

If my remark above is true and if it is feasable, then D is in the 
need of a further paradigm, which at least allows for defining a 
`memo' qualifier for parameters, where `memo' has the obvious 
property of evaluating the parameter at most once lazily for each 
possible parameter value.

As it seems such paradigm is infeasable in general because it must 
take care of parameters that are itself function calls with lazy 
parameters. Those calls are not distinguishable before hand even for 
only one instance, because each of the calls look the same. But 
because they are evaluated lazily without memoizing the obvious 
results may vary for consecutive calls.

The question now is: for what kinds of parameters is memoizing 
allowed? Besides that: my former question in what cases general 
memoizing makes an algorithm indeed more efficient, stays unanswered.

-manfred 



More information about the Digitalmars-d mailing list