[plt-scheme] Cooperating with 3m

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Jan 2 20:46:35 EST 2006

At Tue, 3 Jan 2006 02:33:14 +0800 (CST), mathematica at citiz.net wrote:
> 1. <3.1.1  Tagged Objects> says that for a new type of object, I need to
> call scheme_malloc_tagged to allocate memory and call GC_register_traversers
> to register size, mark, and fixup procedure for my type. But my type 
> has no point to Scheme_Object in it. So could I still allcate it by
> scheme_malloc_atomic (instead of scheme_malloc_tagged) and not register
> anything?

Yes. If the allocated object has no pointers to GCed objects, then
scheme_malloc_atomic() is fine.

> 2. For objects used only in C (such as C strings), I just need to use 
> calloc and free to allocate memory for them. Right?


> 3. When compiling, I got the following error message:
> Error [ARITH] 53 in ml.c: suspicious arithmetic, LHS ends arg.
> line 53 is 
> 	if (lp == (MLINK)0)
> lp is a variable previously defined as:
> 	MLINK lp;
> The reason of the error is mentioned in <3.1.3  Local Pointers and mzc>. 
> Could anyone help to change my code so that I can avoid the error?

I suspect that xform is confused about the line, since I don't see how
`arg' could be in the expansion of this code. Do you see an `arg'
anywhere with an arithmetic operation?

> 4. <1.2  Embedding MzScheme into a Program>: "MzScheme3m can be embedded 
> the same as MzScheme, as long as the embedding program cooperates with the 
> precise garbage collector as described in section 3.1." But no explicit 
> instruction of how to build such a program is given.

I'll have to work on this. The MzScheme library name is the same as
non-3m, except with "3m" in the name, and there's no separate GC
library (because the GC is folded into the MzScheme library). Also, the
embedding program must use scheme_set_stack_base() with non-zero


Posted on the users mailing list.