From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Matt Wette Newsgroups: gmane.lisp.guile.user Subject: Re: type friction C <-> scheme Date: Sun, 11 Jun 2017 06:07:14 -0700 Message-ID: <6547855C-753F-4C46-92EE-E6F6A2324B45@gmail.com> References: <87d1ab3wfr.fsf@netris.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1497186473 2900 195.159.176.226 (11 Jun 2017 13:07:53 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 11 Jun 2017 13:07:53 +0000 (UTC) Cc: guile-user@gnu.org To: Mark H Weaver Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Jun 11 15:07:49 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dK2aq-0000Fz-J4 for guile-user@m.gmane.org; Sun, 11 Jun 2017 15:07:48 +0200 Original-Received: from localhost ([::1]:34039 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dK2as-0000Ri-Lp for guile-user@m.gmane.org; Sun, 11 Jun 2017 09:07:50 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dK2aU-0000Rd-12 for guile-user@gnu.org; Sun, 11 Jun 2017 09:07:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dK2aP-0000ij-1a for guile-user@gnu.org; Sun, 11 Jun 2017 09:07:26 -0400 Original-Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:35621) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dK2aO-0000iV-Lm for guile-user@gnu.org; Sun, 11 Jun 2017 09:07:20 -0400 Original-Received: by mail-pf0-x243.google.com with SMTP id u26so13692866pfd.2 for ; Sun, 11 Jun 2017 06:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=oPpTTDa8ManQSpERKy+sYVywlrYs0VjyZPEGt6jrNPs=; b=cVTCq3LuT7wWwkOZD0ZoB8PVLVeULXOHF4qBuibTMo1AikDiwDyvUnifVK953krhy9 i76fnBqD2o+8IkDYRi5KMuRAV3CXq5J67RMv6MnXtypz515vGpFza759pDcmHQ77E5vB wJKslsgnaTAUcN62if1Beq1lKfZ74Qg/ZWgWKch9cWwHguu+d1+T/KvBrK6P5hATSgme /2WbJ0k3AMY6Sc5+Wy2zFFYXm3jje5TEeY5c0P8E8nPUoO0VOL0QmVgqfhhlow5+k2LU I6L6Qn3rmAM5I2H1Z6ffualTAXk11B8F5t6R/Tsyi8ASrw+6IR7YJ4uggXD9ZnnTxJnV TUWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=oPpTTDa8ManQSpERKy+sYVywlrYs0VjyZPEGt6jrNPs=; b=tuAcgCm4soCjykfLGg5k81fP0E4Zldyx6j1WrX4QJWZKK9VhfHUlnRToxgCgPArbxo SvdZLKTpoo0ABG00sEUlu8ypA1YJlB7/i9VuX+gKYizDsGr02D3R0gtzsrSzTPvOfEHR 8BgcezFX06JNWD6QBAUYiV3vs2zvz7cmkCR6e5cN+dw/cwICwykks2EJVUS9PawhtSOK LrRSuRDS2USZEwQumQ3wtWLLYnCVFWXwcXhhdp7s7MLm1mQeTyfrq9RbuTCZffsylsNE K6FNxPvZRc1SSONxLSRV+M/MyrCspZnLmL7x+0ZEvGe1iN3HmpmhlfP79YDe9RNi3abC WylQ== X-Gm-Message-State: AODbwcDEa4+KwTFMdxQoJGIxE1iF8Wsfkl5ifXfIZuNT5MBhhdzeGbDD vS6rGVOH7OANMA== X-Received: by 10.99.24.66 with SMTP id 2mr51401743pgy.105.1497186438075; Sun, 11 Jun 2017 06:07:18 -0700 (PDT) Original-Received: from [192.168.2.114] (216-165-236-44.championbroadband.com. [216.165.236.44]) by smtp.gmail.com with ESMTPSA id r85sm13220917pfb.61.2017.06.11.06.07.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Jun 2017 06:07:16 -0700 (PDT) In-Reply-To: <87d1ab3wfr.fsf@netris.org> X-Mailer: Apple Mail (2.3273) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:13805 Archived-At: > On Jun 10, 2017, at 10:50 PM, Mark H Weaver wrote: >=20 > Catonano > writes: >=20 >> 2017-06-10 0:33 GMT+02:00 Matt Wette : >>=20 >> I think Mike caught your real error: you were passing (list =E2=80=98* = =E2=80=98int =E2=80=98*) and >>> it wants (list =E2=80=98* int =E2=80=98*). `int=E2=80=99 is a = variable defined by guile. >>>=20 >>=20 >> And isn't `*' a variable defined in guile too ? >>=20 >>=20 >>>=20 >>> scheme@(guile-user)> (use-modules (system foreign)) >>> scheme@(guile-user)> int >>> $1 =3D 8 >>>=20 >>=20 >> yes, and >>=20 >> scheme@(freexl common)> * >> $14 =3D # >=20 > 'int' is a variable exported by (system foreign) whose sole purpose is > to represent a foreign type. >=20 > '*' is something completely different, namely a procedure to multiply > numbers. IMO, it would be a nasty hack for the FFI to check > specifically for a multiplication procedure and interpret that as a > pointer type. >=20 >> I took a look at the guile-gcrypt code again >>=20 >> it's full of things like >>=20 >> '(* * ,int ,size_t *) >>=20 >> that is, only asterisks (pointers) are quoted >>=20 >> Other types are not >>=20 >> So this must be an established convention >>=20 >> It just seems unconsistent to me >=20 > I agree that it's inconsistent, but '* is shorter than any descriptive > variable name that we might have chosen for this purpose, and pointers > are common enough to warrant a short name. >=20 > On the other hand, if we had used symbols uniformly for all foreign > types, then it would have been impossible to bind your own type names > (e.g. for struct types) without adding a global registry of foreign > types, which would have various nasty problems such as the potential = for > collisions between unrelated libraries. >=20 > Regards, > Mark Yes. In the ffi-helper I=E2=80=99m working on, which is intended to = help auto-generate ffi code from C headers, I use #:prefix to avoid = clashes:=20 (define-module (cairo cairo) #:use-module (ffi-help) #:use-module ((system foreign) #:prefix ffi:) #:use-module ((bytestructures guile) #:prefix bs:) ) (define bs:struct bs:bs:struct) =E2=80=A6 ;; cairo_matrix_t (define cairo_matrix_t (bs:struct (list `(xx ,bs:double) `(yx ,bs:double) `(xy ,bs:double) `(yy ,bs:double) `(x0 ,bs:double) `(y0 ,bs:double)))) (export cairo_matrix_t) =E2=80=A6 ;; void cairo_line_to(cairo_t *cr, double x, double y); (define cairo_line_to (let ((f (ffi:pointer->procedure ffi:void (lib-func "cairo_line_to") (list '* ffi:double ffi:double)))) (lambda (cr x y) (let ((~cr ((unwrap-cairo_t* cr)))) (f ~cr x y))))) (export cairo_line_to)