Peter Schuller <peter.schul...@infidyne.com> writes:

>   lru-peak -> [value]

I take it you meant "peek", not "peak".

[...]

> One possibility I was thinking of was that, since the expected use
> case of an LRU cache is so specific, it may be acceptable to have the
> lru "library" itself provide a side-effect aware interface directly.

The LRU aspect of the cache is no business of those using the "get" and
"put" parts of the interface. Those callers should just think they're
using an associative array, dictionary, map, or whatever you want to
call it. That having called "get" may influence what gets evicted next
from some other function isn't germane to the caller's interest.

Unless you're willing to use something like the State monad to represent
(and help hide) the side effects of calling your "get" function, I think
you're better of making no claim about what "get" does beyond its normal
contract: promise only that it returns the value mapped to the given
key, if any. This data structure doesn't seem like a good fit for a
functional-style interface.

-- 
Steven E. Harris

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to