why memoization is not a language feature?

后端 未结 11 634
无人及你
无人及你 2021-01-31 09:00

I was wondering... why memoization is not provided natively as a language feature by any language I know about?

Edit: to clarify, what I mean is that th

11条回答
  •  遇见更好的自我
    2021-01-31 09:17

    In order for memoization to work as a language feature there would be a couple requirements.

    1. The compiler would need to be identify valid functions for memoization (e.g. they are referentially transparent).
    2. The run-time would have to be able to intelligently select candidates for memoization without slowing down the overall performance.

    There are some assumptions in the other language, but if we can have performance gains by just-in-time compilation of hot-spots in a Java VM, then one can surely write an automated memoziation system.

    While non-trivial I think this is all theoretically possible to get performance gains in a language (especially an interpreted one) and is a worthwhile area for research.

提交回复
热议问题