From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Olivier Dion via General Guile related discussions Newsgroups: gmane.lisp.guile.user Subject: Re: Trouble creating SRFI-9 Record in C Date: Fri, 10 Sep 2021 23:59:27 -0400 Message-ID: <87wnnng3ts.fsf@laura> References: Reply-To: Olivier Dion Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5260"; mail-complaints-to="usenet@ciao.gmane.io" To: paul , guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat Sep 11 06:00:09 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 1mOuBT-0001BF-SN for guile-user@m.gmane-mx.org; Sat, 11 Sep 2021 06:00:07 +0200 Original-Received: from localhost ([::1]:59564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOuBS-0007iW-Eo for guile-user@m.gmane-mx.org; Sat, 11 Sep 2021 00:00:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48224) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOuB4-0007hc-UT for guile-user@gnu.org; Fri, 10 Sep 2021 23:59:43 -0400 Original-Received: from smtp.polymtl.ca ([132.207.4.11]:43900) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOuB1-0004hb-Lm for guile-user@gnu.org; Fri, 10 Sep 2021 23:59:42 -0400 Original-Received: from localhost (modemcable094.169-200-24.mc.videotron.ca [24.200.169.94]) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 18B3xRhS003285 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Sep 2021 23:59:31 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 18B3xRhS003285 In-Reply-To: X-Poly-FromMTA: (modemcable094.169-200-24.mc.videotron.ca [24.200.169.94]) at Sat, 11 Sep 2021 03:59:27 +0000 Received-SPF: pass client-ip=132.207.4.11; envelope-from=olivier.dion@polymtl.ca; helo=smtp.polymtl.ca X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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:17723 Archived-At: 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: # 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