From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matt Wette Newsgroups: gmane.lisp.guile.user Subject: Re: Trouble creating SRFI-9 Record in C Date: Sat, 11 Sep 2021 06:30:42 -0700 Message-ID: <873cf8f4-9a99-91f1-5c81-a5afeee32473@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13178"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat Sep 11 15:31:05 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 1mP361-0003Ko-2t for guile-user@m.gmane-mx.org; Sat, 11 Sep 2021 15:31:05 +0200 Original-Received: from localhost ([::1]:47780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mP35z-0000tO-FE for guile-user@m.gmane-mx.org; Sat, 11 Sep 2021 09:31:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mP35k-0000tC-6j for guile-user@gnu.org; Sat, 11 Sep 2021 09:30:48 -0400 Original-Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:35839) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mP35i-0002qd-HB for guile-user@gnu.org; Sat, 11 Sep 2021 09:30:47 -0400 Original-Received: by mail-pj1-x1032.google.com with SMTP id f3-20020a17090a638300b00199097ddf1aso3469080pjj.0 for ; Sat, 11 Sep 2021 06:30:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=1Ash1Bc4YrSk/tSyzM6JhHw8QhjTgZW0YsgcIe2vGI8=; b=EvgnYj3K1H2y4Q79veyw/sBKOaSAU7Tdk6kym3ZHLMjm9+ZpPpXEFkfT67qxG1Vv9a yfQ3Bw3mDsAkH7g55dXcm+byHyQLoL9t7shq3asWJzAUl/4SNVjBUib1kN9hmo3L8YYt 05FQ2LIJM4W/nJLeAsexSV5jcj/FfoeYACeQOcbJzsEYB8It/iZaTt504QiY69O6Klyg k8cW2JlsoXgGWgYYYtdSLuLXPN2G1ErDIBNZ1CEz7mVSk/i8V1WANTFMjwnrf+RbdtHJ eSV1gHYmTvV0uja+UIA/FA56HSAH729u8N3J5nZyDJTilk/26C8NIZgwW5SKiR3hUdpF fxlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=1Ash1Bc4YrSk/tSyzM6JhHw8QhjTgZW0YsgcIe2vGI8=; b=lafs/o6oWpcLacjTQ74t+RnGJzqhWpQyCtIRTOKkL48vzOZvgrh8phggxzwlJhWL7n R7S47LJ5SQ2EFhy31m04LK9k8aajFy63kSDD/u3hw3mPX3LlvO/1s94Mdh6t9OGPVkwf 88Y0w2QJ5JAM7drwfXy9z5lgL90gyJspNaDpzboSX3Nof+Vuj4r0JKcMoQp0KCrHmOZv AMk+j9pxr2kg1i2FokCCjAAmi8XXv7iJ8CvubN3mn1Z+HA0CpOZLgHMRXEDQUMvbJnP0 Z/r3rp7rLGDb7E0ORAuSiLyxdIJObmQDh2vWjMKJY+NCDbNonfhGGZ7qlFRLON4mWGbT LBcg== X-Gm-Message-State: AOAM532E4WUBoDSXsWOjNn0rCXdMj1pKsezvOKBXt7NB3+7P+jR0LbCr GJu2w9iM6rNdmENFyUUONFQsJgUnnRs= X-Google-Smtp-Source: ABdhPJx6LvWU+uOCdX3Wij/wg94NxVQydLbElWAC5KwZJHHQxmqynt2EHFhmpethrrpvAuNSI1OW8A== X-Received: by 2002:a17:902:680d:b0:13a:6909:3c8e with SMTP id h13-20020a170902680d00b0013a69093c8emr2430006plk.16.1631367044278; Sat, 11 Sep 2021 06:30:44 -0700 (PDT) Original-Received: from [192.168.2.163] (64-52-176-132.championbroadband.com. [64.52.176.132]) by smtp.gmail.com with ESMTPSA id w14sm2147789pge.40.2021.09.11.06.30.43 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 11 Sep 2021 06:30:43 -0700 (PDT) In-Reply-To: Content-Language: en-US Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=matt.wette@gmail.com; helo=mail-pj1-x1032.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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:17725 Archived-At: maybe add (define (make-foo-x a b) (make-foo a b)) then call make-foo-x (or reverse names) On 9/10/21 7:27 PM, paul wrote: > Good day guile-users, > > I am having a struggle with SRFI-9 records.  They look very > convenient, so i'd like to use them in my Guile scripts.  However, i'm > not sure how to correctly construct them from C-land.  I have > 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 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: # > > 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. > > Does anyone see what i'm doing wrong, or can i simply not use SRFI-9 > records in this way? > > Thanks, 🙌 > p. >