chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] Re: A few questions


From: Hans Nowak
Subject: [Chicken-users] Re: A few questions
Date: Tue, 29 Jan 2008 14:08:57 -0500
User-agent: Thunderbird 2.0.0.0 (Macintosh/20070326)


First of all, thanks to everybody who replied.

Re docstrings: My next question would be, is it possible to add them (e.g. as a library)? And would it be desirable to do so? Apparently it is already possible to write code like:

(define (foo x)
  "docstring for foo"
  ...body...)

It just has no effect, currently (or so I assume). Would it be possible to write a function/macro/etc like this:

> (get-docstring foo)
"docstring for foo"

...?

The reason I am asking is that someone suggested I should write doctest for Scheme. For those not familiar with it, this is a Python module that allows you to add tests to docstrings. It does so by emulating the interactive interpreter; e.g. you could write:

(define (plus a b)
  "Add two numbers.

   >>> (plus 2 2)
   4
   >>> (plus 1 2 3)
   Error: bad argument count
  "
  ...implementation...)

More here:

http://docs.python.org/lib/module-doctest.html

Does Chicken have something similar? It doesn't have docstrings, but it would still be possible to write unit tests like you're typing them in the REPL. I did not find an egg that does this kind of testing, though. Does such a library exist? Would it be useful to have?


Re using files as modules and scripts: I just found csi's -ss option, which pretty much does what I want, although in a different way.

Anyway, I have another question: when you define a function, how much "introspection" is possible? E.g. from another thread ("Runtime arity") I learned that it's possible to get the function's signature. Is there also a way to get e.g. the function's body? (My guess is, probably not, but I thought I'd ask.)

Thanks,

--Hans





reply via email to

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