From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: paul Newsgroups: gmane.lisp.guile.user Subject: Trouble creating SRFI-9 Record in C Date: Sat, 11 Sep 2021 12:27:27 +1000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10077"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.6.5; emacs 27.2 To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat Sep 11 04:28:38 2021 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mOskv-0002QC-Vi for guile-user@m.gmane-mx.org; Sat, 11 Sep 2021 04:28:38 +0200 Original-Received: from localhost ([::1]:54932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOsku-0000Bz-B6 for guile-user@m.gmane-mx.org; Fri, 10 Sep 2021 22:28:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37532) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOski-0000Bk-1v for guile-user@gnu.org; Fri, 10 Sep 2021 22:28:24 -0400 Original-Received: from aibo.runbox.com ([91.220.196.211]:48110) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mOskf-0007c1-R1 for guile-user@gnu.org; Fri, 10 Sep 2021 22:28:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=inktvis.org ; s=selector1; h=Content-Transfer-Encoding:Content-Type:MIME-Version: Message-ID:Date:Subject:To:From; bh=/MMP1McViRo1FExP50mgkZZUDIzsnpVDfhM67Qx6HBw=; b=VoA3hy6RzUaHjD+2OgdsSOEdIi IF97jDITAOWPdfkKkuxndiJ/q1Ou1SNeXV91dQ44FfyNVeI7cwWUrGgJI4tRudYd9MIUQU1SZnsHz l3sR00UtAtgHlUZ/idN278By5mQgBUPrAu5BhoCbh2ZdCMDHKjBGpNqmD1X1b+Aq9Zl6zkRYraLmF kJypRXL6ENXEqRrmpiLn+Y9ej2Iuy2BFPf3r/NOW6oK0A2WDPwvMlE7MOaghObiJRPOubpBNJhNAU IeSfcROSvEjRmQYQ7yn5PbGidT9bBpqrebEuUmRH1DU+qobyC6OZIIrV56BTDIzjp3lqTRcC4Plc+ uxPDlEZw==; Original-Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1mOskb-0005Qv-5M for guile-user@gnu.org; Sat, 11 Sep 2021 04:28:17 +0200 Original-Received: by submission03.runbox with esmtpsa [Authenticated ID (826552)] (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) id 1mOskN-0002eO-9R for guile-user@gnu.org; Sat, 11 Sep 2021 04:28:03 +0200 Received-SPF: pass client-ip=91.220.196.211; envelope-from=paul@inktvis.org; helo=aibo.runbox.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:17722 Archived-At: Good day guile-users, I am having a struggle with SRFI-9 records. They look very=20 convenient, so i'd like to use them in my Guile scripts. However,=20 i'm not sure how to correctly construct them from C-land. I have=20 something like the following: ``` (define-record-type (make-foo a b) foo? (a foo-a) (b foo-b)) ``` In Guile land, that works great. Now, i want to create a foo in C=20 and pass it to a function in the Guile script. I do something=20 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: # I've tried with and without (define-module foo) at the top of the=20 file, that doesn't seem to make a difference. I've been able to=20 work around the issue by defining a wrapper (define (foo-prime a=20 b) (make-foo a b)) and using that in C as shown above, but that=20 feels ugly. I'm probably missing something obvious, but trawling=20 the mailing list didn't turn up anything i could understand. Does anyone see what i'm doing wrong, or can i simply not use=20 SRFI-9 records in this way? Thanks, =F0=9F=99=8C p.