Arc Forumnew | comments | leaders | submitlogin
We Have Docstrings
24 points by nex3 6116 days ago | 8 comments
Thanks to work by cpfr on #arc, my Git repo and both Anarkies now have support for documentation strings in calls to def. For example:

  arc> (def add (n1 n2)
         "Adds two numbers."
         (+ n1 n2))
  #<procedure: add>
  arc> (help add)
  Adds two numbers.
  nil
  arc>
It only works for def right now, but a little hacking could fix that right up.

Using git:

  $ git clone git://nex-3.com/arc-wiki.git
  $ cd arc-wiki
  ... hack ...
  $ git push
Or svn:

  $ svn co http://ambitioushacker.com/s/arc/
  $ cd arc/arc
  ... hack ...
  $ svn ci --username public --password archer


8 points by bogomipz 6116 days ago | link

I didn't study the code in your repo, but could help also print the signature for the function?

  arc> (help add)
  (add n1 n2)
  Adds two numbers.

-----

7 points by nex3 6116 days ago | link

Actually, yes, this would be quite easy. I've just pushed it.

-----

7 points by cpfr 6116 days ago | link

A proper generalization is in the works. Ideally all symbols can have potential documentation.

-----

3 points by reb 6114 days ago | link

How would you feel about starting to add docstrings to the Arc language itself? - i.e. patching arc.arc and pushing the changes back to the git repository. We could then use docstings and the sigs table to auto generate an Arc manual in say HTML or PDF?

-----

2 points by nex3 6114 days ago | link

That's exactly what I was hoping would happen once we added docstrings.

-----

4 points by skenney26 6116 days ago | link

Perhaps we could call this doc rather than help.

-----

3 points by randallsquared 6116 days ago | link

While "doc" is more historical, it would also be a nice, short name for a variable containing a document.

Of course, presumably most people using a help or docstring function would be doing so at a prompt, where they're not inside a let...

-----

2 points by chaos 6116 days ago | link

oh? Maybe I should read the diffs a bit closer.

-----