<< Back to previous view

[CMEMOIZE-9] memo-swap! is misnamed Created: 23/Sep/13  Updated: 01/Mar/18

Status: Open
Project: core.memoize
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Mark Engelberg Assignee: Sean Corfield
Resolution: Unresolved Votes: 0
Labels: None


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.

Comment by Sean Corfield [ 01/Mar/18 2:42 AM ]

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.

Generated at Mon Mar 19 01:47:38 CDT 2018 using JIRA 4.4#649-r158309.