[plt-scheme] syntax-rules version of this...

From: David Van Horn (dvanhorn at cs.uvm.edu)
Date: Fri Jun 20 13:48:50 EDT 2003

Ed Cavazos wrote:

> I have this macro called 'define-c-const' that is shorthand for doing
> the extraction:
> ;; Macro: (define-c-const FOO)

You might have a look at


Basically, I have a function that maps a scheme symbol to a C enum symbol
(just upcase the symbol and replace hyphens with underscores) and some macros
built on top of that.


(c-enum foo-bar) ~> ((c-lambda () int "___result = FOO_BAR;"))

And then some convenience macros are provided like



(define foo-bar ((c-lambda () int "___result = FOO_BAR;")))
(define bar-baz ((c-lambda () int "___result = BAR_BAZ;")))

If you'd like to change the naming convention, simply replace the
scheme-symbol->c-enum-symbol function in c-syntax-transformer.ss.

I would appreciate any feedback you might have, Ed.



Posted on the users mailing list.