I think what you are doing is analogous to the peek and pop operations in
core.

To get and remove and item you would peek to get the first item, and then
alter your ref with a pop, which returns the structure minus with the first
item removed.

If you do all of this within a dosync, including the peek, then if the
transaction is retried you'll get the new first value, and everything will
remain consistent.

Paul

On Jul 17, 2010 6:20 PM, "Peter Schuller" <peter.schul...@infidyne.com>
wrote:

Another thing occurred to me: While not necessarily important in the
cache of an LRU cache, one might want a data structure, even if it
tends to be used in a side-effectful manner, to participate in STM
co-ordinated transactions. If one hides an underlying ref, this means
that either callers do not have full control (to do, for example,
(ensure ..) on the ref), or the interface needs to provide specific
features to support this (e.g., lru-ensure).

Again, for an LRU cache I think this may be a far-fetched desire to
have and so it is probably not an issue. Maybe there are other data
structures though, with a similar inappropriateness for a functional
interface, where full participation as a persistent data structure
with respect to STM would be desirable.


-- 
/ Peter Schuller

-- 
You received this message because you are subscribed to the Google
Groups...

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