Result Caching

12 December 2020 — Bryan Mehall

One of the reasons for the last re-write of lynx was the speed of recursive functions. When an attribute of an object was accessed more than one time in the same scope it's value was recomputed with each access instead of being stored. With recursive functions this leads to exponential time complexity whenever an attribute is evaluated more then once.

The intended fix is to ensure that the lynx expression keeps the evaluated results of attributes whenever a primitive is being evaluated. This way the value does not need to be re-computed. A problem with this approach is the complexity of invalidating the cache whenever a cached value changes. This is handled by the modules system that will be explained elsewhere.

The first solution for caching used the