chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] How to structure a project


From: Daniel Sadilek
Subject: [Chicken-users] How to structure a project
Date: Tue, 9 Jan 2007 19:22:37 +0100

Hello,

I am wondering what is the best way to structure a project in Chicken.
I found no contiguous explanation of the different available concepts
and how to use them (declare, unit, uses, use, define-extension,
eval-when, ...).
Specifically, I want to be able to run my application in interpreter
and compile them without source code modification.
The best option I could figure out is this one (although I have no
clue if it is meant to be done this way):
I have a module bar:

;;; bar.scm
(define-extension bar)

(define (fac n)
 (if (zero? n)
     1
     (* n (fac (- n 1))) ) )

I use bar in foo:

;;; foo.scm
(declare (uses bar))
(use bar)

(write (fac 10)) (newline)

And, of course there are some unit tests:

;;; bar-test.scm
(use bar unittests)

(assert-equals 3628800 (fac 10))

Now, I can run everything in the interpreter:
csi foo.scm
csi bar-test.scm

And I can compile it:
csc -c bar.scm
csc bar.o foo.scm

This works (at least for this small example). But I don't like the
doubled "use" of bar in foo. Is there a better way to do this?

Best regards
Daniel Sadilek




reply via email to

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