But these docs strings need to be generated on the fly. But the docstring that lisp accepts must be a string, not something that evaluates to a string.
What I have come up with so far is:
Code: Select all
(defmacro doclambda (args dexpr &body body)
(let ((multiquotes (mapcar (lambda(k)(list 'quote k)) body)))
`(eval `(lambda ,(quote ,args) ,,dexpr ,,@multiquotes))))
Code: Select all
(setf dlam (let* ((v 5) (vstr (write-to-string v)))
(doclambda(x) (concatenate 'string "doc" vstr) (declare (type integer x)) (+ x 2))))
(documentation dlam 'function)
(funcall dlam 3)
Code: Select all
(setf dlam (let* ((v 5) (vstr (write-to-string v)))
(doclambda(x) (concatenate 'string "doc" vstr) (declare (type integer x)) (+ x v 2))))
(documentation dlam 'function)
(funcall dlam 3)
Richard