Given is this s-exp:
(let [temp 30
temp (* temp 9/5)
temp (+ temp 32)]
temp)
Ignoring the fact that the arithmetic could be inlined, would rebinding temp
like this be objectionable in Clojure? Why/Why not?
This is used in core.clj in the definition of the conditional threading macros for an example. If splitting the construction of a value into segments makes it clear for human consumption then I would confidently say that this is a fine use of this pattern.
It's worth noting that many Clojurians will interpret the word 'rebinding' to mean using the bind
function. You are using it accurately, though it has another meaning as well.
That's not very functional--in a let
every variable should mean something. I would refactor it to this:
(let [celsius 30
fahrenheit-unnormalized (* celsius 9/5)
fahrenheit (+ fahrenheit 32)
fahrenheit)
(I'm ignoring the better solution:)
(+ (* temp 9/5) 32)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With