Caching in CFLAELazyThunksInterp

Jannis
Mausschubser
Mausschubser
Beiträge: 63
Registriert: 15. Apr 2015 17:10

Caching in CFLAELazyThunksInterp

Beitrag von Jannis » 1. Mär 2018 16:11

Hi!

In the interpreter inside interpreters/lazy_eval/CFLAELazyThunksInterp.scala, there is a comment which states that this interpreter uses caching.

How does it achieve caching? Looking at the Id-case and the definition of strict, I do not see where the caching of EClosure interpretations is implemented.

mirko-koehler
Mausschubser
Mausschubser
Beiträge: 79
Registriert: 16. Okt 2017 12:28

Re: Caching in CFLAELazyThunksInterp

Beitrag von mirko-koehler » 2. Mär 2018 09:33

The comment seems to be wrong. There is no caching implemented in this interpreter. I guess the comment was copy/pasted from the CFLAELazyCachingInterp.scala, which uses caching in the EClosures. :)

Jannis
Mausschubser
Mausschubser
Beiträge: 63
Registriert: 15. Apr 2015 17:10

Re: Caching in CFLAELazyThunksInterp

Beitrag von Jannis » 2. Mär 2018 10:14

Regarding the caching in the EClosures: This is the approach which was introduced in the lecture (using an additional field for the cache inside the EClosure). I initially guessed that the CFLAELazyThunksInterp could implement the way caching was used in the exercises.

In ex10 task 2, we did call-by-need by replacing the EClosures in the environment with the value the expression inside the closure evaluated to (when we needed this value). Do we have names for these two tactics to distinguish between them? Or can we always just use the approach from the exercise when we have to evaluate something with the call-by-need evaluation strategy?

mirko-koehler
Mausschubser
Mausschubser
Beiträge: 79
Registriert: 16. Okt 2017 12:28

Re: Caching in CFLAELazyThunksInterp

Beitrag von mirko-koehler » 2. Mär 2018 12:00

Or can we always just use the approach from the exercise when we have to evaluate something with the call-by-need evaluation strategy?
You can use the approach you want in the exam (unless specified otherwise). The approach from the exercise is not as much to write though. :)

Note, however, that for the approach in the exercise you would need to implement your interpreter with mutable environments instead of just a mutable field in the expression closure.

Do we have names for these two tactics to distinguish between them?
Not that I know of.

Antworten

Zurück zu „Archiv“