<div dir="ltr"><br><br><div class="gmail_quote">On Sat, Jul 26, 2008 at 1:02 AM, Matthew Flatt <span dir="ltr"><<a href="mailto:mflatt@cs.utah.edu">mflatt@cs.utah.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="Ih2E3d">At Thu, 24 Jul 2008 17:50:22 +0200, "Erlend Lorentzen" wrote:<br>
> I'm trying to add a primitive c procedure to MzScheme. I can't show all the<br>
> code, but I'm basically doing something like this:<br>
<br>
</div>Are you embedding the CGC or 3m variant of MzScheme?<br>
<br>
>From the crash dump fragment, it looks like 3m --- but that's an<br>
indirect guess, based on "scheme_add_global + 98" as a call to<br>
scheme_do_add_global_symbol().<br>
<br>
The C code you showed, meanwhile, didn't cooperate with the garbage<br>
collector as required for 3m.<br>
<br>
So that's my guess about that problem.<br>
<br>
<br>
If you want to MzScheme to substitute for Guile, and if your<br>
application has a wide interface with Scheme, then you probably want<br>
the CGC variant. If the interface is narrow enough (e.g., just setting<br>
up a few callback functions), then 3m could work, and you'll need to<br>
help the GC see local and static variables when you call into Scheme.<br>
<br>
<br>
I agree with the suggestions to use the FFI when possible. That<br>
approach may insulate you from some 3m versus CGC issues, though you<br>
still have to deal with the difference when calling into Scheme to get<br>
things started.<br>
<font color="#888888"><br>
Matthew<br>
<br>
</font></blockquote></div><div><br></div><div>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.</div><div><br></div><div>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.</div>
<div><br></div><div>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? </div><div><br>
</div><div>Thanks,</div><div><br></div><div>Erlend</div><div><br></div></div>