Re: [Jastadd] [Q] lazy attributes

From: Görel Hedin <>
Date: Wed, 4 Jan 2012 10:46:01 +0100

Hi Hyunik,

The overhead is usually small: for each AST node that declares the cached attribute, the overhead is a boolean flag and a reference to the cached object. The overhead could also be larger if more memory is tied up as part of computing the attribute, for example if the attribute is another object than an existing AST node.

The attributes are called "lazy" rather than "cached" for historical reasons. We often refer to them as cached attributes in papers, and yes, "cached" would have been a better term.

To cache all attributes makes sense if you are prototyping. But you can get better performance by avoiding to cache some attributes. Emma Söderberg and I wrote a paper about this at SLE 2010. See

I agree it would have been better to have had "cached/lazy" as default. Again, historical reasons. To get all attributes cached, there is an option in JastAdd: --cacheAll . This is not yet documented on the website, but you see it if you do

  java -jar jastadd2.jar --help

However, if you turn on the cacheAll option for an extension to JastAddJ, you will see a performance drop. It would be nice to be able to turn on cacheAll for just your own extension modules, but that is currently not possible.

So, to sum up, I would recommend to continue to put in those "lazy" modifiers in your extensions.


4 jan 2012 kl. 10.05 skrev Na, Hyunik:

> Hello JastAdd developers,
> Is the overhead for declaring an attribute as ‘lazy’ big?
> ( I guess that the overhead is caused to the amount of memory use. )
> Why should we declare an attribute as lazy explicitly if lazy attributes are beneficial in efficient calculation?
> Why isn’t ‘lazy’ the default?
> Anyway, the keyword ‘lazy’ seems to be rather misleading.
> Every attribute of JastAdd nodes is lazy in that it is calculated only when accessed.
> I believe that ‘cached’ is a better word.
> Am I understanding correctly?
> - Hyunik.
> _______________________________________________
> JastAdd mailing list
Received on Wed Jan 04 2012 - 10:46:03 CET

This archive was generated by hypermail 2.3.0 : Wed Apr 16 2014 - 17:19:06 CEST