Earlier quoted context omitted.
I think you're misunderstanding, because (a) no it doesn't, and (b) no it isn't :) Clojure docstrings need to precede the argument list. e.g. this is correct: (defn foo "Some docstring" [] "Some return value")) But this is not: (defn foo [] "Some docstring" "Some return value")) It will still compile, but the first string will be treated as an expression, and therefore ignored as it has no side effects. The reason do…
Other Lisps do it that way without a problem: - If the function body starts with a string literal, it is always the doc-string - If that string is the only thing in the function body, it is also the return value.
My Clojure Workflow, Reloaded
31–33 of 33 posts
Re: My Clojure Workflow, Reloaded
#32Earlier quoted context omitted.
> because you want to be able to document the different implementations differently. I disagree with this. Since the normal functions cannot dispatch on type⁺, only arity, the different implementations are typically very related and should share same documentation. Your proposal would lead to massive duplication, and reduce the likelihood of people actually documenting the functions. ⁺ There are two separate mechanis…
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 ori…
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.
Re: My Clojure Workflow, Reloaded
#33http://docs.racket-lang.org/reference/eval-model.html#%28par...