Groups Images Directory Web
Recently Visited Groups | Help | Sign in
Google Groups Home
Group info
Members: 209
Language: English
Group categories:
Science and Technology
Computers
Schools and Universities
More group info »
Recent pages and files
Documentation Strings    
Here is some function documentation sugar functions assuming the document function that might show up in later code here is the code from Marks post.
(transparent SETF) 

(define document
F String -> (let Type (qi::pretty-type (typecheck [] F A))
DocString (FORMAT NIL "~A~%The type is ~A" String Type)
Attach (SETF (DOCUMENTATION F FUNCTION)) DocString)
documented)

(define documentation
F -> (DOCUMENTATION F FUNCTION))

(declare document [[A --> B] --> string --> symbol])
(declare documentation [[A --> B] --> string])
1. doc-define0 to get lispy documentation strings inside functions
(define doc-define0
[doc-define Name Str | L] -> [do [define Name | L]
[document Name Str]]
X -> X)
and sugaring it by
(sugar in doc-define0 1)
Now this will be used as
(doc-define id
"The identity-map" {A --> A}
X -> X)
Now we can see the documentation for id
(21-) (documentation id)
"identity function
The type is [A --> A]" : string
Another sugar macro can be used to get java style documentation strings by combining the definition of several functions. Here is the sugar fuinction
(define doc-defines0
   [doc-defines Str Def |L] -> (let Name (CADR Def)
                                  [do Def 
                                      [document Name Str] 
				      (doc-defines0 [doc-defines|L])])
   [doc-defines]            -> finished-defines
   X                        -> X)
And here is how it works
(doc-defines
"The identity map"
(define id {A --> A} X -> X)

"verbose addition"
(define addition
{number --> number --> number}
X Y -> (+ X Y)))
And looking at the docstrings you get
(61+) (documentation id)
"The identity map
The type is [A --> A]" : string

(62+) (documentation addition)
"verbose addition
The type is [number --> [number --> number]]" : string
Version: 
2 messages about this page
5 May 2009 by snorgers
This might be a possible solution to get better formatted code in our
discussions
It is very basic, I'm not especially good at this, but minimally you
can just choose
the html view and enter stuff just as with our discussion forum, all
code can be enclosed
acording to
<pre>
(code)
</pre>
5 May 2009 by snorgers
Click on http://groups.google.co.uk/group/Qilang/web/documentation-strings
- or copy & paste it into your browser's address bar if that doesn't
work.
Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google