[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] docstrings

From: felix
Subject: [Chicken-users] docstrings
Date: Wed, 14 Aug 2002 09:17:51 +0200

> I'm also interested in getting docstrings into Chicken somehow. How
> tricky do you think that might be, Felix?
> (define (myfunction foo bar)
>   "Returns the result of mapping blorch over foo, followed by appending
>   ...)
> Combine that with an interation protocol for enumerating all the symbols
> in the symbol table, (even (*all-symbols*) returning a list might be
> good enough) and we could have both online and autogenerated offline
> documentation...

Sounds good. There are two ways to handle this: a separate data-structure
mapping procedures to docstrings, or putting the docstring right into
the closure object. The former way is tricky, because we don't have
weak hash-tables (and finalizers aren't an option, there would be too
many of them), the latter should not collide with `extend-procedure'.
Well, actually this should be done differently: `extend-procedure'
adds an extra-slot to a closure object and one accesses the data
directly from this slot. But perhaps the slot should contain an a-list.
Then we can add arbitrary data to any closure object and

(lambda () "foo" ...)

would expand into something like

(let ([p (lambda () ...)])
  (extend-procedure p 'docstring "foo") )

> >>> (documentation car)
> "Returns the car of the pair passed in as an argument."
> >>> (documentation (lambda () 'dummy))
> #f
> >>> (documentation (lambda () "hi"))
> #f
> >>> (documentation (lambda () "hi" "there"))
> "hi"
> >>> (documentation-parameters with-exception-handler)
> (new-handler body-thunk)

It has to be seen how much extra storage is needed, but we can make this
optional, anyway (Say, using a parameter "(enable-procedure-information


reply via email to

[Prev in Thread] Current Thread [Next in Thread]