3 ms·
Yeah, I guess you've got a point there. However, if this only applies to different arities, please also compare to the following style: (defun function (a
by kleiba 13y ago
Yeah, I guess you've got a point there.
However, if this only applies to different arities, please also compare to the following style:
(defun function (a b &optional c d e)
"Documentation string"
"return value"))
I still think that the function signature is more readable when the doc string comes after the parameters, but perhaps it's just a matter of taste.
The above is obviously not Clojure. But as I commented originally, I just wasn't aware that this is the way Clojure does it.
- Tuna-Fish 13y agoThat could be done as: (defn function "doc" [a b & rest] "body") However, matching by arity at the front really helps make simple functions clean. I really like the multiple body approach, as in my code there's typically one "standard" case, and the rest are special cases that just call the standard one with new params. Having to deal with a rest arg with potentially multiple possible lengths just doesn't look as clear in practice. It's all tradeoffs. I can see why you'd like the arglist first -- I have some Haskell background, and I do miss it's types in Clojure, just for the documentation they provide.