Welcome! Please see the About page for a little more info on how this works.

0 votes
in core.memoize by

In order to be analogous to atoms, the current behavior of memo-swap! should be called memo-reset! since it overwrites the entire memo map. Similarly, there should be a function called memo-swap! that does an atomic swap operation on the memo cache so, for example, you can add a single value to the cache.

2 Answers

0 votes
by
_Comment made by: seancorfield_

Good point! Backward compatibility could be maintained by checking if {{(map? base)}} -- and perhaps giving a deprecation warning? -- but users would have to be very careful that they would be manipulating the cache and core.memoize wraps raw values in {{IDeref}} instances so a simple

(memo-swap! f assoc [42] 99)
 
would not work -- it would need to be

(memo-swap! f assoc [42] (delay 99))

which would make this the only place in the API where that is really exposed.
0 votes
by
Reference: https://clojure.atlassian.net/browse/CMEMOIZE-9 (reported by markengelberg)
...