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
Afficher les réponses par date
Hallo,
Arnaud Bergeron wrote:
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 ";")))))
There is a misplaced comma:
(define-macro (c-define-const name c-name) `(define ,name ((c-lambda () int ,(string-append "___result = " c-name ";")))))
Cheers, -alex http://www.ventonegro.org/