Parameterizing inline C code

Diogo via Chicken-users <[email protected]>
Newsgroups gmane.lisp.scheme.chicken
Message-ID <[email protected]>
Dear mailing list,

the syntax #> ... <# allows us to inline C code in CHICKEN code. Can I
"parameterize" it?

I'd like to have something like this:

    (begin-for-syntax
        (define count 0) 
    
        (define (foo-transformer x r c)
          (let ((name (generate-function-name x)))
            #>
            void ,name(void) {
                printf("hello world: %s\n", c_special_func(,name));
            }
            <#
        )
    )
    
    (define-syntax foo
      (er-macro-transformer foo-transformer))
    
    (foo 1) ;; creates void foo_1(void) {...}
    (foo 2) ;; creates void foo_2(void) {...}
    ...

I know that using define-external I could define a function foo_n and then
using foreign-safe-lambda* in the function definition of define-external 
I could adapt the body as well. But that will add a lot of CHICKEN 
bookkeeping and function calls. In my case I really just want a plain 
C function to be generated.

Thanks in advance.

Best,
-Diogo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.