On Tue, Feb 19, 2013 at 2:28 AM, Philip Potter <philip.g.pot...@gmail.com> wrote: > > They sound like very interesting features. They also sound lower-level > than Clojure's STM -- if a Clojure STM transaction fails, it will > automatically retry until it succeeds (or hits > LockingTransaction/RETRY_LIMIT, currently 10000, when it throws an > exception.) Is this the case in Haskell?
I don't know if there's a limit, but transactions retry automatically, and transaction failure is detected automatically. I'm confused by the characterization of orElse as lower-level than Clojure's STM: it's a way of combining two independent STM actions and thus strikes me as a higher-level operation. Here's the way "retry" is introduced in "Beautiful Concurrency": """ Atomic blocks as we have introduced them so far are utterly inadequate to coordinate concurrent programs. They lack two key facilities: blocking and choice. In this section I’ll describe how the basic STM interface is elaborated to include them in a fully-modular way. Suppose that a thread should block if it attempts to overdraw an account (i.e. withdraw more than the current balance). Situations like this are common in concurrent programs: for example, a thread should block if it reads from an empty buffer, or when it waits for an event. We achieve this in STM by adding the single function retry, whose type is retry :: STM a Here is a modified version of withdraw that blocks if the balance would go negative: limitedWithdraw :: Account -> Int -> STM () limitedWithdraw acc amount = do { bal <- readTVar acc ; if amount > 0 && amount > bal then retry else writeTVar acc (bal - amount) } """ So it isn't really about restarting failed transactions because (e.g.) someone else has written to the ref while we've been executing, but detecting a case within an otherwise successful transaction---where "successful" means "we can read and write to all these refs with no problem"---where we actually want to start over and wait until some values have changed. -- Ben Wolfson "Human kind has used its intelligence to vary the flavour of drinks, which may be sweet, aromatic, fermented or spirit-based. ... Family and social life also offer numerous other occasions to consume drinks for pleasure." [Larousse, "Drink" entry] -- -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.