Clojure

Expose memoization cache and original as metadata on memoized functions.

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Trivial Trivial
  • Resolution: Declined
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code

Description

The attached patch exposes the memoization cache and original pre-memoized value as metadata on memoized functions.

The metadata keys are ::memoize-cache and ::prememoized respectively, to which I'm not too attached.

Activity

Hide
Stuart Halloway added a comment -

Can you say more about the problems(s) being solved there? Given all the other feature work that has been done/requested around memoization, tempted to let this work happen in a contrib library first. But that is partially because I don't know from this ticket what pain is being addressed.

Show
Stuart Halloway added a comment - Can you say more about the problems(s) being solved there? Given all the other feature work that has been done/requested around memoization, tempted to let this work happen in a contrib library first. But that is partially because I don't know from this ticket what pain is being addressed.
Hide
Fogus added a comment -

Unk may provide a starting point for a contrib lib. https://github.com/fogus/unk

Show
Fogus added a comment - Unk may provide a starting point for a contrib lib. https://github.com/fogus/unk
Hide
Phil Hagelberg added a comment -

I'm in support of a smarter memoize a la unk; this could be considered a stop-gap measure that helps in situations where the current memoize implementation simply cannot be used due to unbounded memory use.

I've also come across circumstances where I can't use memoize because it will make my function untestable, though admittedly these involve memoizing impure functions—perhaps the answer there is just "don't do that".

Show
Phil Hagelberg added a comment - I'm in support of a smarter memoize a la unk; this could be considered a stop-gap measure that helps in situations where the current memoize implementation simply cannot be used due to unbounded memory use. I've also come across circumstances where I can't use memoize because it will make my function untestable, though admittedly these involve memoizing impure functions—perhaps the answer there is just "don't do that".
Hide
Christopher Redinger added a comment -

Let's do one of the following instead:

  • make unk a contrib (after addressing Rich's questions)
  • recommend Guava for advanced caching
  • make a Guava-wrapping contrib
Show
Christopher Redinger added a comment - Let's do one of the following instead:
  • make unk a contrib (after addressing Rich's questions)
  • recommend Guava for advanced caching
  • make a Guava-wrapping contrib

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: