From: ludo@gnu.org (Ludovic Courtès)
To: guile-devel@gnu.org
Subject: Re: Passing C pointers through guile
Date: Wed, 09 Jul 2008 21:35:14 +0200 [thread overview]
Message-ID: <87zloqyhot.fsf@gnu.org> (raw)
In-Reply-To: Pine.LNX.4.58.0807091836560.3261@notam02.uio.no
Hi,
"Kjetil S. Matheussen" <k.s.matheussen@notam02.no> writes:
> I gave it a try. Unfortunately, I was completely unable to create
> the configure file right now, so the patch is against 1.8.5 (sorry
> if this creats trouble against git repository), and
> it's also untested, since I couldn't build configure.
You have to make sure you are on the `branch_release-1-8', and then
"autoreconf -vfi" should suffice to produce everything. Autoconf 2.61,
Automake 1.10 and Libtool 1.5.26 is all you need.
> The only thing I'm not too sure about is whether
> the new SCM_I_GSC_T_UINTPTR type in configure.in will actually be
> optional or not. I just copied the checking code for the optional
> SCM_I_GSC_T_UINT64 type though:
I think this type shouldn't be optional, because there will always be a
pointer-sized integer type (whereas there could be platform without
64-bit integers).
>> That said, using a Scheme integer to represent a pointer wouldn't be
>> efficient (pointers would likely translate to bignums).
>
> I think cleaner code would usually be more important in this case,
> but at least there will be a choice.
I'm not sure how much cleaner this is. Usually, you'll want disjoint
Scheme types, which means you'll end up enclosing the pointer-as-bignum
in a structure or SRFI-9 record or similar. This leads to even more
overhead. Conversely, using an opaque field in a Guile struct has the
same effect but with much less overhead.
Another issue is that of memory management. When using
pointers-as-bignums, all the GC will see is a collection of bignums, not
knowing that these are actually pointers to C objects that should not be
GC'd unless the integer is no longer used---as opposed to "no longer
referenced"! This actually makes it mandatory to enclose the integer in
a structure or similar, and then to have a guardian on that structure to
allow the C object's destructor to be called when that structure is no
longer referenced.
(Note that it could be a valid approach in some compiler environments.
It just doesn't fit well with Guile's design.)
Anyway, it can't hurt to have the choice. :-)
Thanks,
Ludovic.
PS: You'll have to assign copyright to the FSF so that your code can be
integrated. We can discuss it off-line if you want.
next prev parent reply other threads:[~2008-07-09 19:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cmu-lmtpd-29205-1215446748-1@mail-imap1.uio.no>
2008-07-09 16:50 ` Passing C pointers through guile Kjetil S. Matheussen
2008-07-09 18:32 ` Kjetil S. Matheussen
2008-07-09 19:37 ` Ludovic Courtès
2008-07-09 19:35 ` Ludovic Courtès [this message]
2008-07-09 19:58 Kjetil S. Matheussen
-- strict thread matches above, loose matches on Subject: below --
2008-07-09 20:09 Kjetil S. Matheussen
2008-07-09 20:43 ` Ludovic Courtès
2008-07-11 13:05 ` Greg Troxel
2008-07-11 13:12 ` Kjetil S. Matheussen
2008-07-11 14:42 ` Ludovic Courtès
2008-07-10 12:49 Kjetil S. Matheussen
2008-07-10 13:01 ` Ludovic Courtès
[not found] <cmu-lmtpd-26382-1215792388-9@mail-imap1.uio.no>
2008-07-11 17:22 ` Kjetil S. Matheussen
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=87zloqyhot.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guile-devel@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).