Lazy evaluation

Peter Alexander peter.alexander.au at gmail.com
Tue Nov 22 15:06:12 PST 2011


On 22/11/11 10:00 PM, Manu wrote:
> So, I've been thinking about this const/lazy evaluation problem again.
>
> I think most of the complaints about D's const is due to the use of lazy
> evaluation for optimisation. I started wondering if there was room for a
> 'lazy' keyword.

There already is one :-)

http://d-programming-language.org/lazy-evaluation.html


> Perhaps if you declared some function as lazy, then the compiler would
> be expected to cache the return value

How does it cache it?

i.e.

- What data structure does it use?
- Is there a size limit, or does it just keep adding into the cache 
until you run out of memory?
- What allocator does it use?
- If there is a size limit, what is the eviction policy?
- and what is the size limit?
- How do I manually flag the cache as dirty if I want to clear it?

There is no automatic way to do caching. Every single application of 
caching has its own needs and you need control over that. You can't just 
stick it all in a hash table and be done with it.


More information about the Digitalmars-d mailing list