From: taylanbayirli@gmail.com (Taylan Ulrich Bayırlı/Kammer)
To: Amirouche Boubekki <amirouche@hypermove.net>
Cc: guile-user@gnu.org,
guile-user <guile-user-bounces+amirouche=hypermove.net@gnu.org>
Subject: Re: Bytestructures, FFI
Date: Wed, 01 Jun 2016 00:07:52 +0300 [thread overview]
Message-ID: <87k2iaaqc7.fsf@T420.taylan> (raw)
In-Reply-To: <c465d7bc7d8fff5a8a0617f433ad0761@hypermove.net> (Amirouche Boubekki's message of "Tue, 31 May 2016 22:13:32 +0200")
Amirouche Boubekki <amirouche@hypermove.net> writes:
> On 2016-05-31 21:29, taylanbayirli@gmail.com wrote:
>> scheme@(guile-user)> (define testfunc
>> (bs:pointer->proc
>> foo_t ;return value type
>> (dynamic-func "testfunc" (dynamic-link
>> "libtest"))
>> (list foo_t))) ;list of argument types
>
> Why don't you use dynamic-link* signature like described in [1]:
>
> ((dynamic-link* [library-name]) return-type function-name . arguments)
>
> [1] http://www.hyperdev.fr/notes/gnu-guile-ffi.html
Hmm, if one wishes, one can wrap bs:pointer->proc in a similar fashion;
I'll leave that up to the users of the library. :-)
>> scheme@(guile-user)> (define foo2 (testfunc foo))
>
> isn't foo2 `equal?' to foo?
I'm not sure how you mean exactly. Firstly, foo and foo2 are separate
record instances, so they wouldn't be equal? even if they contained the
same values in the same fields (using equal? on record objects falls
back to using eqv?), but they also contain different values in their
fields, since foo2 is the one returned by 'testfunc'. (Also remember
that structs are passed by-value in C, so testfunc receives a *copy* of
foo as its argument when it's called, which it then modifies and
returns.)
Hope that helps!
Taylan
next prev parent reply other threads:[~2016-05-31 21:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-31 19:29 Bytestructures, FFI Taylan Ulrich Bayırlı/Kammer
2016-05-31 20:13 ` Amirouche Boubekki
2016-05-31 21:07 ` Taylan Ulrich Bayırlı/Kammer [this message]
2016-06-01 21:40 ` Ludovic Courtès
2016-06-02 0:07 ` Taylan Ulrich Bayırlı/Kammer
2016-06-02 7:04 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k2iaaqc7.fsf@T420.taylan \
--to=taylanbayirli@gmail.com \
--cc=amirouche@hypermove.net \
--cc=guile-user-bounces+amirouche=hypermove.net@gnu.org \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).