[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How and when to use GCPRO?
From: |
Leo |
Subject: |
How and when to use GCPRO? |
Date: |
Mon, 27 Dec 2010 09:21:54 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2.91 (Mac OS X 10.6.5) |
Hello,
I wonder if anyone can point me to a more detailed explanation of how
and when to use GCPRO other than what's in the elisp manual.
Is there any symptom in a gdb session that one should suspect a GCPRO is
missing?
For example, Could someone comment on the following function I just
wrote, which tries to add support for feature expressions like in common
lisp?
static Lisp_Object
eval_feature_expression (form)
Lisp_Object form;
{
Lisp_Object val, exp;
struct gcpro gcpro1;
if (! NILP(Fatom(form)))
return NILP(Fmemq(form, Vfeatures)) ? Qnil:Qt;
if (EQ (Fcar(form), Qnot))
{
if (XINT(Flength(form)) != 2)
error ("Invalid feature expression");
val = eval_feature_expression (Fcar(Fcdr(form)));
return NILP(val) ? Qt:Qnil;
}
if (EQ (Fcar(form), Qand))
{
if (NILP (Fcdr (form)))
error ("Invalid feature expression");
val = eval_feature_expression (Fcar (Fcdr (form)));
if (NILP (Fcdr (Fcdr (form))))
return val;
else if (NILP(val))
return Qnil;
else
{
GCPRO1(exp);
exp = Fcons (Qand, (Fcdr(Fcdr(form))));
val = eval_feature_expression (exp);
UNGCPRO;
return val;
}
}
if (EQ (Fcar(form), Qor))
{
if (NILP (Fcdr (form)))
error ("Invalid feature expression");
val = eval_feature_expression (Fcar (Fcdr (form)));
if (NILP (Fcdr (Fcdr (form))))
return val;
else if (NILP (val))
{
GCPRO1(exp);
exp = Fcons (Qor, (Fcdr(Fcdr(form))));
UNGCPRO;
return eval_feature_expression (exp);
}
else
return Qt;
}
error ("Invalid feature expression");
}
I am also reading the XEmacs internals manual on GCPROing but I have
little idea what is still true for GNU Emacs.
Thanks in advance and happy holidays.
Leo
- How and when to use GCPRO?,
Leo <=
- Re: How and when to use GCPRO?, Andreas Schwab, 2010/12/27
- Re: How and when to use GCPRO?, Leo, 2010/12/27
- Re: How and when to use GCPRO?, Stefan Monnier, 2010/12/27
- Re: How and when to use GCPRO?, Andreas Schwab, 2010/12/27
- Re: How and when to use GCPRO?, Stefan Monnier, 2010/12/27
- Re: How and when to use GCPRO?, Daniel Colascione, 2010/12/27
- Re: How and when to use GCPRO?, Stefan Monnier, 2010/12/27
- Re: How and when to use GCPRO?, Daniel Colascione, 2010/12/27
- Re: How and when to use GCPRO?, Stefan Monnier, 2010/12/27