I was just wondering if there are any advantages/disadvantages to choose one over the other, or if it is purely just a design choice for a project's scope/workflow?
Scenario 1 : Using var and eval
(defn fun1 [x] (prn (* x x)))
(defn fun2 [y] (#'fun1 y))
(eval (fun2 2))
4
nil
Scenario 2 : Creating a sequential chaining of function calls
(defn fun1 [x] (prn (* x x)))
(defn fun3 [y] (fun1 y))
(fun3 2)
4
nil
I really appreciate your responses, Thanks in advance!
In Scenario 1, I believe you meant to do this:
(defn fun1 [x] (prn (* x x)))
(defn fun2 [y] (#'fun1 y))
(fun2 2)
It is almost never necessary (nor desirable) to use eval
For more detail on the difference between these Scenario 1 & 2, please see this question.
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