Re: Avoid duplicate computation in commute?

2012-05-18 Thread nicolas.o...@gmail.com
I think part of the problem is that commute should not return any result. You are not sure this is actually the value that will be returned, this is costly and misleading. There should be at least a variant of commute that return nil. -- You received this message because you are subscribed to

Avoid duplicate computation in commute?

2012-05-17 Thread Warren Lynn
Hi, The duplicate computation in commute seems to me quite a blemish on clojure's beauty. I even see somebody's code with comments pre- compute x because otherwise commute will call it twice. So I need to keep that fact in the back of my mind when using it? That is not what I was hoping for. I

Re: Avoid duplicate computation in commute?

2012-05-17 Thread Stuart Sierra
a conflict. All this doesn't mean that it's impossible to avoid the duplicate computation on `commute`. The code to study would be here: https://github.com/clojure/clojure/blob/8fda34e4c77cac079b711da59d5fe49b74605553/src/jvm/clojure/lang/LockingTransaction.java#L459 -S -- You received

Re: Avoid duplicate computation in commute?

2012-05-17 Thread DAemon
if there's a conflict. All this doesn't mean that it's impossible to avoid the duplicate computation on `commute`. The code to study would be here: https://github.com/clojure/clojure/blob/8fda34e4c77cac079b711da59d5fe49b74605553/src/jvm/clojure/lang/LockingTransaction.java#L459 -S -- You

Re: Avoid duplicate computation in commute?

2012-05-17 Thread Warren Lynn
more than once if there's a conflict. All this doesn't mean that it's impossible to avoid the duplicate computation on `commute`. The code to study would be here: https://github.com/clojure/clojure/blob/8fda34e4c77cac079b711da59d5fe... -S  -- You received this message because you

Re: Avoid duplicate computation in commute?

2012-05-17 Thread DAemon
to avoid the duplicate computation on `commute`. The code to study would be here: https://github.com/clojure/clojure/blob/8fda34e4c77cac079b711da59d5fe. .. -S -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group

Re: Avoid duplicate computation in commute?

2012-05-17 Thread Warren Lynn
once, you can use `alter`. Keep in mind that *any* code in a Ref transaction has the potential to be called more than once if there's a conflict. All this doesn't mean that it's impossible to avoid the duplicate computation on `commute`. The code to study would be here

Re: Avoid duplicate computation in commute?

2012-05-17 Thread DAemon
in a Ref transaction has the potential to be called more than once if there's a conflict. All this doesn't mean that it's impossible to avoid the duplicate computation on `commute`. The code to study would be here: https://github.com/clojure/clojure/blob