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: Re: Trouble creating SRFI-9 Record in C Date: Sun, 12 Sep 2021 09:42:11 +1000 Message-ID: References: <873cf8f4-9a99-91f1-5c81-a5afeee32473@gmail.com> Mime-Version: 1.0 (1.0) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13692"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user@gnu.org To: Matt Wette Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sun Sep 12 01:42:52 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 1mPCe2-0003LV-Ua for guile-user@m.gmane-mx.org; Sun, 12 Sep 2021 01:42:51 +0200 Original-Received: from localhost ([::1]:41102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPCe0-0004zL-S1 for guile-user@m.gmane-mx.org; Sat, 11 Sep 2021 19:42:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPCdf-0004zC-KA for guile-user@gnu.org; Sat, 11 Sep 2021 19:42:27 -0400 Original-Received: from aibo.runbox.com ([91.220.196.211]:37716) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mPCdc-0003Le-5z for guile-user@gnu.org; Sat, 11 Sep 2021 19:42:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=inktvis.org ; s=selector1; h=To:In-Reply-To:Cc:References:Message-Id:Date:Subject: Mime-Version:From:Content-Transfer-Encoding:Content-Type; bh=Wz68+18zPrkiLk38flUO4lUhjLIxGpgw9U4A2QHDvBs=; b=d+Lxhv+mGAdojEXiA7TAEOSLyQ yVpQezD+qb5ufWWoOohbcnBmesNX5TxUU+/YX1pFgy/u6V+5NrkzK6x7ERDVUHCqn4JAz9wMa1A4E BcEeyeBV96xB8V2kDYyab+JJIcYh+istbyL1xVstrS9zz1tqOmqny4PC/lBCDCQVMdrORFR3w8gHP BTorLwFSC3Li36wOmBwHtD7WpfgncHARhjt/k9y6uUYWDu9ZIjgKEdtAq7NK+aDwY7ydmNrB+ZDWX uE0PuR8KDO1EQJSlmexq8YepJa8zN0FWJ2qc7TCmWHtJO1WzYtNlEETfiI0sO71KtPdn0lyDZ8TR+ 6PERxbJw==; Original-Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1mPCdY-0008IY-Nb; Sun, 12 Sep 2021 01:42:20 +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 1mPCdW-0000RE-QX; Sun, 12 Sep 2021 01:42:19 +0200 In-Reply-To: <873cf8f4-9a99-91f1-5c81-a5afeee32473@gmail.com> X-Mailer: iPhone Mail (18G82) 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:17726 Archived-At: Hey Matt, Yeah that was exactly my workaround =F0=9F=99=82 I was wondering whether i c= ould use the syntax transformer more "directly" from C, or something like th= at.=20 Thanks, paul > On 11 Sep 2021, at 23:31, Matt Wette wrote: >=20 > =EF=BB=BFmaybe add >=20 > (define (make-foo-x a b) (make-foo a b)) >=20 > then call make-foo-x (or reverse names) >=20 >> On 9/10/21 7:27 PM, paul wrote: >> Good day guile-users, >>=20 >> I am having a struggle with SRFI-9 records. They look very convenient, s= o i'd like to use them in my Guile scripts. However, i'm not sure how to co= rrectly construct them from C-land. I have something like the following: >>=20 >> ``` >> (define-record-type >> (make-foo a b) >> foo? >> (a foo-a) >> (b foo-b)) >> ``` >>=20 >> In Guile land, that works great. Now, i want to create a foo in C and pa= ss it to a function in the Guile script. I do something like the following:= >>=20 >> ``` >> 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))) >> ``` >>=20 >> However, this results in an error: >>=20 >> guile: uncaught exception: >> Wrong type to apply: # >>=20 >> I've tried with and without (define-module foo) at the top of the file, t= hat doesn't seem to make a difference. I've been able to work around the is= sue by defining a wrapper (define (foo-prime a b) (make-foo a b)) and using t= hat in C as shown above, but that feels ugly. I'm probably missing somethin= g obvious, but trawling the mailing list didn't turn up anything i could und= erstand. >>=20 >> Does anyone see what i'm doing wrong, or can i simply not use SRFI-9 reco= rds in this way? >>=20 >> Thanks, =F0=9F=99=8C >> p. >>=20 >=20 >=20