chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] (use foo) versus (declare (uses foo)), csi versus cs


From: Zbigniew
Subject: Re: [Chicken-users] (use foo) versus (declare (uses foo)), csi versus csc
Date: Fri, 19 Oct 2007 18:06:59 -0500

OK, try this.

bar.scm:

(define-extension bar)

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

foo.scm:

#+compiling (declare (uses bar))

(use bar)
(write (fac 10)) (newline)

------------

bar.scm can now be compiled as a shared library or a regular .o unit.
foo.scm can be interpreted or it can have bar compiled in as a unit.

$ csc foo.scm bar.scm -o foo; ./foo
3628800
$ csi -script foo.scm
3628800

With this incantation you cannot automatically include bar into foo as
as a shared library.  To include a shared bar.so, remove the entire
#+compiling line.  Alternatively you can bypass the requirement for
this #+compiling directive in the first place by passing "-uses bar":

$ csc -uses bar foo.scm bar.scm -o foo

Then remove the -uses option if you want to compile shared.

This procedure is unusual because usually we use shared library
extensions or include directives instead of (declare (uses)).
However, it should work for you.

Zb




reply via email to

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