From: Olivier Dion via General Guile related discussions <guile-user@gnu.org>
To: paul <paul@inktvis.org>, guile-user@gnu.org
Subject: Re: Trouble creating SRFI-9 Record in C
Date: Fri, 10 Sep 2021 23:59:27 -0400 [thread overview]
Message-ID: <87wnnng3ts.fsf@laura> (raw)
In-Reply-To: <m235qbalsh.fsf@inktvis.org>
On Sat, 11 Sep 2021, paul <paul@inktvis.org> 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
Polymtl
next prev parent reply other threads:[~2021-09-11 3:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-11 2:27 Trouble creating SRFI-9 Record in C paul
2021-09-11 3:59 ` Olivier Dion via General Guile related discussions [this message]
2021-09-11 13:30 ` Matt Wette
2021-09-11 23:42 ` paul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wnnng3ts.fsf@laura \
--to=guile-user@gnu.org \
--cc=olivier.dion@polymtl.ca \
--cc=paul@inktvis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).