why memoization is not a language feature?

后端 未结 11 615
无人及你
无人及你 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:06

    A) Memoization trades space for time. I imagine that this can turn out to a fairly unbound property, in the sense, that the amount of data programs or libraries would have to store could consume large parts of memory really quick.

    For a couple of languages, memoization is easy to implement and easy to customize for the given requirements.

    As an example take some natural language processing on large bodies of text, where you don't want to compute basic properties of texts (word count, frequency, cooccurrences, ...) over and over again. In that case a memoization in combination with object serialization can be useful as opposed to memory caching, since you may run your application multiple times on unchanged corpora.

    B) Another aspect: It's not true, that all functions or methods yield the same output for a same given input. Anyway some keyword or syntax for memoization would be necessary, along with configuration (memory limits, invalidation policy, ...) ...

提交回复
热议问题