From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Bogatov Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH 18/25] write documentation for (system foreign declarative) Date: Mon, 18 Jul 2016 23:11:04 +0300 Message-ID: References: <1468855068-7029-1-git-send-email-KAction@gnu.org> <1468855068-7029-19-git-send-email-KAction@gnu.org> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1468872713 29903 80.91.229.3 (18 Jul 2016 20:11:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 18 Jul 2016 20:11:53 +0000 (UTC) Cc: guile-devel@gnu.org, KAction@gnu.org To: Amirouche Boubekki Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Jul 18 22:11:40 2016 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bPEt9-0004mm-8B for guile-devel@m.gmane.org; Mon, 18 Jul 2016 22:11:39 +0200 Original-Received: from localhost ([::1]:50111 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPEt8-0003r5-Hz for guile-devel@m.gmane.org; Mon, 18 Jul 2016 16:11:38 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37305) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPEsm-0003pI-Af for guile-devel@gnu.org; Mon, 18 Jul 2016 16:11:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPEsi-0000mW-1Q for guile-devel@gnu.org; Mon, 18 Jul 2016 16:11:15 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:58705) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPEsh-0000m9-Ti; Mon, 18 Jul 2016 16:11:11 -0400 Original-Received: from broadband-46-188-10-23.2com.net ([46.188.10.23]:60404 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bPEsg-0005O0-4V; Mon, 18 Jul 2016 16:11:10 -0400 In-reply-to: Comments: In-reply-to Amirouche Boubekki message dated "Mon, 18 Jul 2016 21:41:04 +0200." X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:18586 Archived-At: [2016-07-18 21:41] Amirouche Boubekki > > On 2016-07-18 17:17, KAction@gnu.org wrote: > > From: Dmitry Bogatov > > > > Document '' record type and 'define-foreign-type' > > procedure. > > Can you compare this 'foreign-type' library with scheme-bytestructures > [0]. How > can both libraries help each other? Work hand in hand? Seems that 'scheme-bytestructures' can be used to implement something like `define-foreign-struct', but since it is not currently part of Guile, I, sure, can't depend on it. Also, 'parse-c-struct' provides similiar functionality. > Tell me if I'm wrong but it looks like you have to define validate, > encode and decode proc for every single structure with no > helpers. Not true. Sure, if your conversion is somewhat unusual, you have to invoke `(define-foreign-type)', but if it conventional, you can use - define-foreign-bitmask (in future) - define-foreign-struct (did not extracted from guile-bash) - define-foreign-enumeration - define-foreign-opaque (last two are really trivial, just I did not needed them for xattr library) > It seems to me that it's some kind of framework for doing validation > of static typed procedures which also handles automatic conversion > between C land and scheme land. Honestly this is not the kind of > library I would use, I seldom do input validation when the client of > my program is a developer. Maybe I'm wrong but IMO dynamic languages > help that. Our opinions on validation differs. I think, that foreign function binding, created by (system foreign declarative) should be as good, as if written in C. By this I mean, I want to get error message out of function itself, not from some guts of (system foreign declarative). > Also based on my small experience of ffi, there is not much > conversion to do between scheme and C and what's best is to avoid > any copy which is what does scheme-bytestructures. (system foreign declarative) provide a way to work with memory with no copy: (with-pointer ((memory *--> 1024)) (foreign-call memory) (work-with-bytevector memory)) But take a look at (ice9 xattr) (patches 21-25). Conversion from Scheme string to `const char *' have O(n) price, but I prefered natural interface to perfomance. But again, (system foreign declarative) does not force such choice. It seems to me, that I responded to every point, but feel free to refine your question. -- Accept: text/plain, text/x-diff Accept-Language: eo,en,ru X-Web-Site: sinsekvu.github.io