guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing C pointers through guile


From: Ludovic Courtès
Subject: Re: Passing C pointers through guile
Date: Wed, 09 Jul 2008 21:54:59 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Hi,

"Kjetil S. Matheussen" <address@hidden> writes:

> On Wed, 9 Jul 2008, Greg Troxel wrote:

>> Does C guarantee that pointers fit in unsigned long?
>
> I don't know. But in practice: Yes.

That's usually the case but it's not guaranteed, which is why C99
provides `uintptr_t' in <stdint.h>.

> Sure, if you just do this now and then, SMOBs aren't a problem.
> But that doesn't change the fact that all the functionality SMOB
> provides is overkill when the only thing you need is to hold
> a pointer.

It's not overkill, it's exactly what you need: disjoint SMOB type,
`free' and `mark' procedures.

> For those who needs the full functionality of SMOB's, or need
> the extra speed and memory advantages of SMOB's, they are free
> to use SMOB's. If not, the functions scm_to/from_uintptr
> can be used instead, which is a billion times easier to use.

Not really: as mentioned on `guile-devel', you'll need to implement that
functionality (disjoint type, garbage collection) on top of your
integer.  One advantage is that this can be done in Scheme (except for
the `mark' procedure, but it's not always needed); the main drawback in
the context of Guile is poor performance.

Thanks,
Ludovic.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]