>>>> "JV" == Jan Vroonhof
<vroonhof(a)math.ethz.ch> writes:
JV> [discussion moved to beta]
JV> Martin Buchholz <martin(a)xemacs.org> writes:
> XSETBUFFER is annoying because it doesn't return a value.
JV> I am wondering whether this might have been intentional originally so
JV> you don't forget to GCPRO when passing it to functions.
I'm pretty sure it's because it can't be maximally efficiently
implemented unless the compiler supports inline functions.
GCPROing was annoying before, and will be annoying after, until I
implement conservative gc for the stack, or someone beats me to it.
BEFORE:
Lisp_Object foo;
Lisp_FOO *c_foo = alloc_lrecord_type (Lisp_FOO, &lrecord_FOO);
XSETFOO (foo, c_foo);
GCPRO1 (foo);
bar (foo);
UNGCPRO (foo);
AFTER:
Lisp_FOO *c_foo = alloc_lrecord_type (Lisp_FOO, &lrecord_FOO);
Lisp_Object foo = Lisp_FOO_to_Object (c_foo);
GCPRO1 (foo);
bar (foo);
UNGCPRO (foo);
It's true that there will be the urge to just do
bar (Lisp_FOO_to_Object (alloc_lcrecord_type (Lisp_FOO, &lrecord_FOO)));
which will lose horribly. But someone will submit a patch out of the
blue to implement conservative gc for the stack, right? It happened
for mule support on Windows (thanks Tomonori!).
and then our C code will be pure beauty.
Martin