Docstrings in Clojure?

2,011 views
Skip to first unread message

Paddy3118

unread,
Aug 19, 2010, 4:22:30 PM8/19/10
to Clojure
Hi, Does clojure have docstrings: http://en.wikipedia.org/wiki/Docstring
and, if so, do you have a link to the feature in the Clojure
documentation? Thanks.

Joop Kiefte

unread,
Aug 19, 2010, 4:37:19 PM8/19/10
to clo...@googlegroups.com
(defn function-name
"Your docstring goes here"
[your argument list & more]
(call some functions))

2010/8/19 Paddy3118 <padd...@googlemail.com>:


> Hi, Does clojure have docstrings: http://en.wikipedia.org/wiki/Docstring
> and, if so, do you have a link to the feature in the Clojure
> documentation? Thanks.
>

> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

--
Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004

Demandoj en aŭ pri Esperanto? Questions about Esperanto? Vragen over
Esperanto? Perguntas sobre o Esperanto? - http://demandoj.tk

Ameen

unread,
Aug 19, 2010, 10:09:23 PM8/19/10
to Clojure
So it is before arguments. What is the motivation behind that
opposition to other lisps and python ?

On 19 août, 22:37, Joop Kiefte <iko...@gmail.com> wrote:
> (defn function-name
>     "Your docstring goes here"
>     [your argument list & more]
>    (call some functions))
>
> 2010/8/19 Paddy3118 <paddy3...@googlemail.com>:

Grayswx

unread,
Aug 19, 2010, 4:47:42 PM8/19/10
to Clojure
On Aug 19, 4:37 pm, Joop Kiefte <iko...@gmail.com> wrote:
> (defn function-name
> "Your docstring goes here"
> [your argument list & more]
> (call some functions))

And then you can access it with (doc function-name).
(find-doc #"regexp") or (find-doc "string") searches all doc strings.
There is also (clojure.repl/source function-name), which tries to
print out the source and doc-string. It doesn't work all the time,
though.


> 2010/8/19 Paddy3118 <paddy3...@googlemail.com>:

David Nolen

unread,
Aug 19, 2010, 10:53:12 PM8/19/10
to clo...@googlegroups.com
On Thu, Aug 19, 2010 at 10:09 PM, Ameen <amy...@gmail.com> wrote:
So it is before arguments. What is the motivation behind that
opposition to other lisps and python ?

Functions support mutiple arity.

(defn foo
   "..."
   ([a] ...)
   ([a b] ...))

ngocdaothanh

unread,
Aug 20, 2010, 1:18:08 AM8/20/10
to Clojure
> (defn foo
>    "..."
>    ([a] ...)
>    ([a b] ...))

Is there any way to add docstring for each case? (One for summary, one
for [a], and one for [a b].)

Meikel Brandmeyer

unread,
Aug 20, 2010, 1:43:38 AM8/20/10
to Clojure
Hi,
No. (And honestly: I don't see any use for this. Why is one docstring
not enough to describe the behaviour of the function?)

Sincerely
Meikel

Paddy3118

unread,
Aug 20, 2010, 1:56:07 AM8/20/10
to Clojure


On Aug 19, 9:37 pm, Joop Kiefte <iko...@gmail.com> wrote:
> (defn function-name
>     "Your docstring goes here"
>     [your argument list & more]
>    (call some functions))
>
> 2010/8/19 Paddy3118 <paddy3...@googlemail.com>:
>
> > Hi, Does clojure have docstrings:http://en.wikipedia.org/wiki/Docstring
> > and, if so, do you have a link to the feature in the Clojure
> > documentation? Thanks.
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clo...@googlegroups.com
> > Note that posts from new members are moderated - please be patient with your first post.
> > To unsubscribe from this group, send email to
> > clojure+u...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en
>
> --
> Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004
>
> Demandoj en aŭ pri Esperanto? Questions about Esperanto? Vragen over
> Esperanto? Perguntas sobre o Esperanto? -http://demandoj.tk

Hi Joop,
Do you have a link to this in the official Clojure documentation? I
would like to add the link to the Wikipedia article.

Thanks, Paddy.

Meikel Brandmeyer

unread,
Aug 20, 2010, 9:30:36 AM8/20/10
to Clojure
> Do you have a link to this in the official Clojure documentation? I
> would like to add the link to the Wikipedia article.

http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/defn

Paddy3118

unread,
Aug 28, 2010, 6:08:09 AM8/28/10
to Clojure
Thanks guys. I have mentioned Clojure in the Wikipedia entry for
Docstrings at: http://en.wikipedia.org/wiki/Docstring
Reply all
Reply to author
Forward
0 new messages