[plt-scheme] embedding with 3m

From: dave (dave at pawfal.org)
Date: Sat Jan 27 06:50:00 EST 2007

Hi all,

Is there an embedding example using 3m anywhere? I've hit a problem
using the 3m garbage collector (as I'm now porting my app to that) I'm
using yesterday's svn build (on linux). I've got it down to a few lines
of code (below). It runs ok for a minute or so, then I get:

#f::0: compile: bad syntax; function application is not allowed, because
no #%app syntax transformer is bound in: (display "hello")

Of course it may have nothing to do with 3m, but do I need to register
the Scheme_Env with the garbage collector? I tried that in my main app,
but it doesn't seem to make a difference.

Compile with:  g++ mz.cpp -o mz -L/usr/local/lib
-I/usr/local/include/plt -lmzscheme3m -ldl

mz.cpp:
---8<---

// if this is uncommented, scheme_setjmp won't compile?
//#define MZ_PRECISE_GC
#include <scheme.h>

void interpret(Scheme_Env *e, char *code)
{
	mz_jmp_buf * volatile save, fresh;
	save = scheme_current_thread->error_buf;
    scheme_current_thread->error_buf = &fresh;
	
    if (scheme_setjmp(scheme_error_buf)) 
	{
		scheme_current_thread->error_buf = save;
		exit(-1);
    } 
	else 
	{
		scheme_eval_string_all(code, e, 1);
		scheme_current_thread->error_buf = save;
    }
}

int main(int argc, char *argv[])
{
	void *stack_start;
	stack_start = (void *)&stack_start;
	scheme_set_stack_base(stack_start, 1);  
	
	Scheme_Env *e=NULL;
	e=scheme_basic_env();

	while(1)
	{
		interpret(e,"(display \"hello\")(newline)");
	}
		
	return 0;
}

--->8---



Posted on the users mailing list.