[plt-scheme] syntax-rules version of this...
David Van Horn answered my last question about extracting C
constants. He says it has worked for him just fine. Very cool.
I have this macro called 'define-c-const' that is shorthand for doing
the extraction:
;; Macro: (define-c-const FOO)
(defmacro define-c-const
(lambda (name)
`(define ,name
((c-lambda ()
int
,(format "___result = ~a" name))))))
My understanding of how to use syntax-rules and syntax-case is
limited to really trivial rewrites... Can anyone suggest a version of
define-c-const that uses syntax-rules or syntax-case? (er, I guess
this is a really trivial rewrite.. :-/)
I know it should be something like this:
(define-syntax define-c-const
(syntax-rules ()
((_ name)
(define name
((c-lambda ()
int
c-code-string))))))
Where the c-code-string is computed as follows:
(let ((c-code-string (format "___result = ~a" name)))
...)
Ed