[gambit-list] Expose C constants to Scheme

Arnaud Bergeron abergeron at gmail.com
Fri Sep 26 13:12:03 EDT 2008


For the LLVM interface to Scheme I am working on I need to export some
constants in C to Scheme.

I was advised to proceed with the following construct:

(define <scheme-name> ((c-lambda () int "__result = <c-name>;")))

Since it is boring to retype the same thing a lot of times I
considered making a macro, but I am facing the problem that c-lambda
wants a literal string as its third argument.  I can make the string I
need with string-append, but I have no idea how to build a literal
string in a macro.

Here is what I have right now:

(define-macro (c-define-const name c-name)
  `(define ,name ((c-lambda () int (string-append "___result = "
,c-name ";")))))

If anybody has a better idea on how to do this or a way to fix my
macro, I would appreciate.

Arnaud



More information about the Gambit-list mailing list