[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble creating SRFI-9 Record in C

From: Olivier Dion
Subject: Re: Trouble creating SRFI-9 Record in C
Date: Fri, 10 Sep 2021 23:59:27 -0400

On Sat, 11 Sep 2021, paul <> wrote:

> In Guile land, that works great.  Now, i want to create a foo in C 
> and pass it to a function in the Guile script.  I do something 
> like the following:
> ```
> scm_c_primitive_load("foo.scm");
> scm_call_5(scm_variable_ref(scm_c_lookup("make-foo")),
>            scm_from_utf8_string("blah"),
>            scm_from_int32(Int32(42)))
> ```
> However, this results in an error:
> guile: uncaught exception:
> Wrong type to apply: #<syntax-transformer make-foo>

Seems like `make-foo` is a syntax-transformer and not a procedure.  You
can not call a syntax-transformer.  I don't think you can do much with a
syntax-transformer in C.

> I've tried with and without (define-module foo) at the top of the 
> file, that doesn't seem to make a difference.  I've been able to 
> work around the issue by defining a wrapper (define (foo-prime a 
> b) (make-foo a b)) and using that in C as shown above, but that 
> feels ugly.  I'm probably missing something obvious, but trawling 
> the mailing list didn't turn up anything i could understand.

By making a wrapper, you're effectively creating a procedure that can
use the `make-foo` syntax because it's in Scheme and it's solved a
expansion time.

Olivier Dion

reply via email to

[Prev in Thread] Current Thread [Next in Thread]