Hi, On Sun, Mar 14, 2010 at 01:26:10AM +0100, Christophe Grand wrote:
> I agree: it can be concurrently computed several times (but a given thread > would only compute it at most once). I must confess I was a little insisting on a point which has probably only little impact in the real life. But a) I prefer to have correct solution and b) it was a nice exercise. :) > You're right of course. I apologize. ^^^^^^^^^ Huh? What for? This was a really enlightening discussion! Who would have thought, that memoize is so non-trivial. :) > As a minor note: couldn't a future replace your promise? Or couldn't you get > rid of the other thread and deliver the promise in the same thread but > outside of the (locking ..) form? The problem with the future is, that it starts immediately. A similar issue is with the same thread: the behaviour after the swap! must be identical to hits and misses. So I needed the locking to really start the computation only once. > Hmm or even a delay!? And of course, this is the solution to get rid of the locking! I should have thought of delay much earlier. > Do you see a problem in my latest implementation? > http://gist.github.com/330644#LID153 No. This one looks fine. Christophe, Eugen! I will summarise this discussion in blog post. It really shows, that concurrent programming is not trivial. Not even for „trivial“ things like a memoised function. Sincerely Meikel -- 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