[plt-scheme] Adding primitive c procedure

From: Erlend Lorentzen (erlendlor at gmail.com)
Date: Tue Jul 29 13:00:54 EDT 2008

On Sat, Jul 26, 2008 at 1:02 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:

> At Thu, 24 Jul 2008 17:50:22 +0200, "Erlend Lorentzen" wrote:
> > I'm trying to add a primitive c procedure to MzScheme. I can't show all
> the
> > code, but I'm basically doing something like this:
> Are you embedding the CGC or 3m variant of MzScheme?
> From the crash dump fragment, it looks like 3m --- but that's an
> indirect guess, based on "scheme_add_global + 98" as a call to
> scheme_do_add_global_symbol().
> The C code you showed, meanwhile, didn't cooperate with the garbage
> collector as required for 3m.
> So that's my guess about that problem.
> If you want to MzScheme to substitute for Guile, and if your
> application has a wide interface with Scheme, then you probably want
> the CGC variant. If the interface is narrow enough (e.g., just setting
> up a few callback functions), then 3m could work, and you'll need to
> help the GC see local and static variables when you call into Scheme.
> I agree with the suggestions to use the FFI when possible. That
> approach may insulate you from some 3m versus CGC issues, though you
> still have to deal with the difference when calling into Scheme to get
> things started.
> Matthew
At the moment I'm using 3m, and as you said the reason for the crash was
that I didn't cooperate correctly with the garbage collector.

I had a discussion about FFI with my employer. He agrees that ideally FFI
should be used, but because of the current codebase we will not choose FFI
in this particular instance.

I'm considering switching to CGC since performance is a low priority in this
case and sicne it will be easier to implement. My only hesitation is whether
CGC is as future proof as 3m?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20080729/949531e3/attachment.html>

Posted on the users mailing list.