chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Integrating unit tests into source code


From: elf
Subject: Re: [Chicken-users] Integrating unit tests into source code
Date: Thu, 14 Dec 2006 04:58:35 -0500 (EST)

do it the lisp way, perhaps?

(define (foo ...) "docstring" body ...)
(define foo (lambda (...) "docstring" body ...))

?
or, more generally (if the compiler runs a pass to change the first form
into the second)

(lambda (lambda-list) "docstring" body ...)

which would also allow generic lambdas to be documented...

downsides:  there would need to be a check to distinguish a docstring from
a string return value.

another possibility:  special form, either for lambda or define, like
(define/doc (foo ...) "docstring" body ...)
(lambda/doc (lambda-list) "docstring" body ...)

which would be easy to implement as a macro.

-elf

On Thu, 14 Dec 2006, felix winkelmann wrote:

> Hi!
>
> While reading a bit about "doctest" (the Python utility), I thought
> it would be relatively easy to support embedded documentation
> in definitions, like:
>
> (define (foo ...)
>   '(test (...))
>   <body>...)
>
> The basic idea is to extend the idea of Lisp/Scheme docstrings
> (a string as the first form inside a procedure, when the body
> has more than one expression) to doc-sexprs.
> So one could embed test-cases directly in the code, in a backwards-
> and R5RS-compatible way.
>
> It's no big deal to extend the compiler to extract this info. What I'm
> looking for is ideas about the exact mechanism, the syntax, etc.
>
> Pointless or useful?
>
>
> cheers,
> felix
>
>
> _______________________________________________
> Chicken-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/chicken-users
>
>

-----
Humans always do the most intelligent thing after every stupid alternative
has failed.                   -- R. Buckminster Fuller

A year spent in artificial intelligence is enough to make one believe in G-d.
                              -- Alan Perlis






reply via email to

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