Hi, On Thursday, November 21, 2013 11:58:31 AM UTC+1, Jim foo.bar wrote: > > [...]
1. [...] Since there is a single > identity, perhaps STM is an overkill... > If I read your example correctly, it is not a typical use-case for STM. > > 2. can you ellaborate why you think this is debatable? All the > ref-managing fns return the in-transaction value of the ref (i.e. > 'alter'). My problem was with 'doseq' which returns nil so I followed > the general approach of returning the in-transaction value of the ref > after it commits. > Clojure is not really consistent here. Many functions that are used for their side-effects return nil, e.g. doseq, dorun, println. On the other hand, you are right, that in the realm of reference types, some return value seems to be the norm (e.g. alter, ref-set, swap!, alter-meta!). I do not know the design principles behind this. However, in your calling code you'll end up with the Ref, that you passed to transfer! to be manipulated, and the new value which you returned. What are you going to do with those two? Why did you need the Ref, couldn't you just pass a plain old map and use the return value for further processing? > 3. As I understand it these 2 transactions will be composed/merged into > a single transaction. That is my understanding, too. > Again, originally I had a bare 'alter' (no dosync) > on the private fn transfer1 simply because it is hidden and not supposed > to be used...think of it as a helper fn for 'transfer'. but then I read > somewhere that transaction can be nested AFAIK, that usually refers to transactions on different refs on different levels of the stack which will be merged into one transaction. > without a problem so I thought > it is safer to include 'dosync' in tranfer1 as well... > It is probably safe, but is it necessary? Cheers, Stefan -- -- 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.