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: Kjetil S. Matheussen
Subject: Re: Passing C pointers through guile
Date: Thu, 10 Jul 2008 14:54:49 +0200 (CEST)


Ludovic Courtès:
> 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.

My point is that SMOB's are overkill if you _don't_ need either free or mark.


> 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.

I'm just copying my answer to the guile-devel mailing list:

"
Point is that you very often don't need any kind of free functionality.
For example, if you create a gui widget, you probably have a callback
function which is called if the gui is closed. That callback
function can free any allocated memory. Another example from snd
is creating ladspa plugins (audio plugins in linux). Handlers
from those, plus variuos configuration stuff, is alive througout
the whole session and will be automatically freed when the program
closes.
"

reply via email to

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