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

> I can turn 'get' into 'peek' and have another function that more
> specifically advertises, by its name, that it produces both a value
> and a new cache. That only helps naming though, and not usability of
> said function.

Yes, and though it does so for a completely different reason, there's
precedence for this in the Standard C++ Library's stack¹, queue², and
vector³ class templates (as well as some other containers). There,
reading (e.g. std::queue::front()) and mutating (e.g. std::queue::pop())
are kept separate, because mutating exposes us to exception safety
concerns; for popping an item off the front of a queue, trying to return
a value that needs to be copy-constructed could trigger an error /after/
the underlying container has been mutated to no longer contain that
value.

What's less clear to me here, though, is how a caller would know when to
call on the mutating LRU adjuster function. If the "peek" function tells
him what he needed to know, you're still left with the odd contract of
needing him to call some other function to actually note his interest's
effect on the LRU ordering.


Footnotes: 
¹ 
http://www.dinkumware.com/manuals/default.aspx?manual=compleat&page=stack.html#stack
² 
http://www.dinkumware.com/manuals/default.aspx?manual=compleat&page=queue.html#queue
³ 
http://www.dinkumware.com/manuals/default.aspx?manual=compleat&page=vector.html#vector

-- 
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