GC safety and return values
Tom Lord 22 Dec 2003 21:22 UTC
Some of the functions defined in the interface, for example:
scheme_value SCHEME_REAL_PART(scheme_value) (may GC)
return a scheme_value as a C return value.
This seems inherently error-prone.
For example:
x = SCHEME_CONS (SCHEME_REAL_PART (a), SCHEME_REAL_PART (b));
although a very natural seeming C statement, is incorrect code. SCM
makes that mistake (though its not a mistake within the goals of the
SCM project itself), Guile inherited it (where it really is a
mistake), and it proved to be a serious obstacle to, for example,
implementing either precise or copying GC.
For starters, I would like to see all return values passed via
output parameters so that one would have to write:
SCHEME_REAL_PART (&tmp1, a);
SCHEME_REAL_PART (&tmp2, b);
SCHEME_CONS (&x, tmp1, tmp2);
In fact I'd go beyond that in a few ways -- but let me just start with
this and see where we get.
-t