Here's a little bit of amateur code to enable the use of docstrings in Chicken Scheme. I haven't written any Scheme in a few months and don't have any formal training in the ninja art of explicit renaming macros so I'd appreciate any feedback from Scheme veterans:

;;; Docstrings for Chicken!

;; The hash-table that will contain the procedures and their associated
;; documentation strings as well as their code for later use.
(define *documentation-hash-table* (make-hash-table))

;; Documented define er-macro
(define-syntax (define* form r c)
  (let* ((args-form (second form))     ; (proc args)
         (proc-name (first args-form)) ;  proc
         (doc (third form))            ; "The docstring"
         (body (drop form 3)))         ; (everything else)
    (hash-table-set! *documentation-hash-table* proc-name (list doc body)) ; insert the doc and code body
    `(,(r 'define) ,args-form ,@body))) ; Define the procedure as normal

;; Example of a documented procedure, will print a nice-ish list of documented procedures
(define* (print-docs)
  "Print a list of documented procedures"
  (hash-table-walk *documentation-hash-table*
    (lambda (key val)
      (printf "~a => ~a~n  ~a~n~n" key (first val) (second val)))))

Another example of why Scheme is such a fun language to work with :)

(Maybe) Related posts: