3 ms·
Awesome. Naive question; is "defn" really necessary?, isn't "let" and "lambda" enough to express a program?.
by baghead66 11y ago
Awesome.
Naive question; is "defn" really necessary?, isn't "let" and "lambda" enough to express a program?.
- kpmah 11y agoYou're right, it's not necessary, it's just a preference :) Although it does 'flatten' the bindings. Defn a, Defn b… is the same as let a = … in let b = … in …
- deleted 11y ago[deleted]
- diminishedprime 11y agoOne thing I've noticed is depending on how your code is being compiled/transpiled, having smaller defn's over them being nested in a let can lead to better performance since inlining becomes an easier problem. This is particularly true in clojure, since it's being compiled to java byte-code, and the jvm has a few default settings for how deep it'll look into the call tree for inlining. See https://www.youtube.com/watch?v=0tUrbf6Uzu8 https://www.youtube.com/watch?v=0tUrbf6Uzu8 for a talk that mentions this.