>> Why does Clojure not need retry or orElse when another implementer of
>> STM considers them essential?
> What are retry and orElse? What do they do?

I had hoped to get a reply from someone with experience of both, as
the quote suggests they are for blocking and choice (The article was
the first time I'd seen STM so am absolutely not an expert)

>From the Haskell docs:
retry :: STM a
Retry execution of the current memory transaction because it has seen
values in TVars which mean that it should not continue (e.g. the TVars
represent a shared buffer that is now empty). The implementation may
block the thread until one of the TVars that it has read from has been
udpated. (GHC only)
(this is what made me think of watchers in clojure,
http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/add-watch)

orElse :: STM a -> STM a -> STM a
Compose two alternative STM actions (GHC only). If the first action
completes without retrying then it forms the result of the orElse.
Otherwise, if the first action retries, then the second action is
tried in its place. If both actions retry then the orElse as a whole
retries.

> "Santa repeatedly sleeps until wakened by either all of his nine
> reindeer, back from their holidays, or by a group of three of his ten
> elves. If awakened by the reindeer, he harnesses each of them to his
> sleigh, delivers toys with them and finally unharnesses them (allowing
> them to go off on holiday). If awakened by a group of elves, he shows
> each of the group into his study, consults with them on toy R&D and
> finally shows them each out (allowing them to go back to work). Santa
> should give priority to the reindeer in the case that there is both a
> group of elves and a group of reindeer waiting."

I think it's a shame he wrote the article around Christmas and chose a
less well known problem, I have looked at several Clojure Barbershop
Problem solutions so have a better idea now what an idiomatic solution
to this sort of problem might be.

Cheers Phil,
Tom

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


Reply via email to