Mercurial > hg > xemacs-beta
comparison man/internals/internals.texi @ 265:8efd647ea9ca r20-5b31
Import from CVS: tag r20-5b31
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:25:37 +0200 |
parents | 11cf20601dec |
children | c5d627a313b1 |
comparison
equal
deleted
inserted
replaced
264:682d2a9d41a5 | 265:8efd647ea9ca |
---|---|
1735 If all args return nil, return nil. | 1735 If all args return nil, return nil. |
1736 */ | 1736 */ |
1737 (args)) | 1737 (args)) |
1738 @{ | 1738 @{ |
1739 /* This function can GC */ | 1739 /* This function can GC */ |
1740 REGISTER Lisp_Object val; | 1740 Lisp_Object val = Qnil; |
1741 Lisp_Object args_left; | |
1742 struct gcpro gcpro1; | 1741 struct gcpro gcpro1; |
1743 | 1742 |
1744 if (NILP (args)) | 1743 GCPRO1 (args); |
1745 return Qnil; | 1744 |
1746 | 1745 while (!NILP (args)) |
1747 args_left = args; | |
1748 GCPRO1 (args_left); | |
1749 | |
1750 do | |
1751 @{ | 1746 @{ |
1752 val = Feval (Fcar (args_left)); | 1747 val = Feval (XCAR (args)); |
1753 if (!NILP (val)) | 1748 if (!NILP (val)) |
1754 break; | 1749 break; |
1755 args_left = Fcdr (args_left); | 1750 args = XCDR (args); |
1756 @} | 1751 @} |
1757 while (!NILP (args_left)); | |
1758 | 1752 |
1759 UNGCPRO; | 1753 UNGCPRO; |
1760 return val; | 1754 return val; |
1761 @} | 1755 @} |
1762 @end group | 1756 @end group |
4069 speed of anything. | 4063 speed of anything. |
4070 | 4064 |
4071 @item | 4065 @item |
4072 The general rule to follow is that caller, not callee, @code{GCPRO}s. | 4066 The general rule to follow is that caller, not callee, @code{GCPRO}s. |
4073 That is, you should not have to explicitly @code{GCPRO} any Lisp objects | 4067 That is, you should not have to explicitly @code{GCPRO} any Lisp objects |
4074 that are passed in as parameters, but if you create any Lisp objects | 4068 that are passed in as parameters. |
4075 (remember, this happens in all sorts of circumstances, e.g. with | 4069 |
4076 @code{Fcons()}, etc.), you are responsible for @code{GCPRO}ing the | 4070 One exception from this rule is if you ever plan to change the parameter |
4077 objects unless you are @emph{absolutely sure} that there's no | 4071 value, and store a new object in it. In that case, you @emph{must} |
4078 possibility that a garbage-collection can occur while you need to use | 4072 @code{GCPRO} the parameter, because otherwise the new object will not be |
4079 the object. Even then, consider @code{GCPRO}ing. | 4073 protected. |
4074 | |
4075 So, if you create any Lisp objects (remember, this happens in all sorts | |
4076 of circumstances, e.g. with @code{Fcons()}, etc.), you are responsible | |
4077 for @code{GCPRO}ing them, unless you are @emph{absolutely sure} that | |
4078 there's no possibility that a garbage-collection can occur while you | |
4079 need to use the object. Even then, consider @code{GCPRO}ing. | |
4080 | 4080 |
4081 @item | 4081 @item |
4082 A garbage collection can occur whenever anything calls @code{Feval}, or | 4082 A garbage collection can occur whenever anything calls @code{Feval}, or |
4083 whenever a QUIT can occur where execution can continue past | 4083 whenever a QUIT can occur where execution can continue past |
4084 this. (Remember, this is almost anywhere.) | 4084 this. (Remember, this is almost anywhere.) |