unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Re: Passing C pointers through guile
@ 2008-07-10 12:54 Kjetil S. Matheussen
  0 siblings, 0 replies; 10+ messages in thread
From: Kjetil S. Matheussen @ 2008-07-10 12:54 UTC (permalink / raw)
  To: guile-user

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1589 bytes --]


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

^ permalink raw reply	[flat|nested] 10+ messages in thread
[parent not found: <cmu-lmtpd-16223-1215360367-2@mail-imap1.uio.no>]
* Passing C pointers through guile
@ 2008-07-04 22:18 Maciek Godek
  2008-07-05 16:59 ` Ludovic Courtès
  0 siblings, 1 reply; 10+ messages in thread
From: Maciek Godek @ 2008-07-04 22:18 UTC (permalink / raw)
  To: guile-user

Hi,
is there any portable and recommended way for passing C pointers around
in guile environment?
I think of something like scm_to_ptr (analogous to scm_to_int etc.).
Certainly such a value would be completely useless for the interpreter.
One can achieve simillar functionality using the aforementioned
scm_to_int (keeping track on the word length of the build target),
but it seems rather unnatural.

Perhaps the need for passing pointers is a sign of a weakness
in design of a given system, is it so?

very good regards
mg




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-07-23 11:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-10 12:54 Passing C pointers through guile Kjetil S. Matheussen
     [not found] <cmu-lmtpd-16223-1215360367-2@mail-imap1.uio.no>
2008-07-06 16:13 ` Kjetil S. Matheussen
2008-07-06 19:20   ` Ludovic Courtès
2008-07-09 16:48   ` Greg Troxel
2008-07-09 16:55     ` Kjetil S. Matheussen
2008-07-09 19:54       ` Ludovic Courtès
2008-07-10 15:11       ` Ken Raeburn
2008-07-23 11:19         ` Greg Troxel
  -- strict thread matches above, loose matches on Subject: below --
2008-07-04 22:18 Maciek Godek
2008-07-05 16:59 ` Ludovic Courtès

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