On 4/2/07, Tato Norren <[EMAIL PROTECTED]> wrote:
Hi,
I feel like an idiot asking,
Never feel like an idiot among the chicken-users. Unless you get duped
by one of the April Fool's jokes. :-)
but what exactly are the sequence of
commands needed to make the following C function callable from the
chicken interpretor? on Linux.
Minh's advice is good; but you can also embed C functions directly
into Scheme code (if you're going to compile it). If you only need
little functions like this, it can be a good strategy. For example,
using the "foreign-lambda*" form:
;; foo.scm
(define test
(foreign-lambda* double ((double x))
"return (x*x);"))
[EMAIL PROTECTED] tmp]$ csc -s foo.scm
[EMAIL PROTECTED] tmp]$ csi -q
csi> (use foo)
csi> (test 555)
308025.0
You can also download and use the "inline" egg, which will let you
compile stuff on the fly, right in the interpreter:
csi> (use inline)
csi> (inline "double tt(double x) { return x*x; }")
csi> (tt 55)
3025.0
Neat, huh? There's also the easy-ffi, lazy-ffi, etc. Chicken's really
good at this kind of thing, if you're the kind of person who likes
having choices.
Graham
-- Graham
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users