comparison src/symbols.c @ 4337:c32e4dca0296

#'special-form-p; don't error (thank you Jerry James); flesh out docstring. 2007-12-18 Aidan Kehoe <kehoea@parhasard.net> * symbols.c (Fspecial_form_p): Following commentary from Jerry James, don't error if not passed a subr. Flesh out the docstring; give details of what a subr is, what a special form is, and why one should probably not write special forms oneself.
author Aidan Kehoe <kehoea@parhasard.net>
date Tue, 18 Dec 2007 23:00:01 +0100
parents cdc2f70d4319
children a2af1ff1761f
comparison
equal deleted inserted replaced
4336:cdc2f70d4319 4337:c32e4dca0296
731 name = XSUBR (subr)->name; 731 name = XSUBR (subr)->name;
732 return make_string ((const Ibyte *)name, strlen (name)); 732 return make_string ((const Ibyte *)name, strlen (name));
733 } 733 }
734 734
735 DEFUN ("special-form-p", Fspecial_form_p, 1, 1, 0, /* 735 DEFUN ("special-form-p", Fspecial_form_p, 1, 1, 0, /*
736 Return whether SUBR is a special form. SUBR must be built-in. 736 Return whether SUBR is a special form.
737
738 A special form is a built-in function (a subr, that is a function
739 implemented in C, not Lisp) which does not necessarily evaluate all its
740 arguments. Much of the basic XEmacs Lisp syntax is implemented by means of
741 special forms; examples are `let', `condition-case', `defun', `setq' and so
742 on.
743
744 If you intend to write a Lisp function that does not necessarily evaluate
745 all its arguments, the portable (across emacs variants, and across Lisp
746 implementations) way to go about it is to write a macro instead. See
747 `defmacro' and `backquote'.
737 */ 748 */
738 (subr)) 749 (subr))
739 { 750 {
740 subr = indirect_function (subr, 1); 751 subr = indirect_function (subr, 0);
741 CHECK_SUBR (subr); 752 return (SUBRP (subr) && XSUBR (subr)->max_args == UNEVALLED) ? Qt : Qnil;
742
743 return XSUBR (subr)->max_args == UNEVALLED ? Qt : Qnil;
744 } 753 }
745 754
746 DEFUN ("setplist", Fsetplist, 2, 2, 0, /* 755 DEFUN ("setplist", Fsetplist, 2, 2, 0, /*
747 Set SYMBOL's property list to NEWPLIST, and return NEWPLIST. 756 Set SYMBOL's property list to NEWPLIST, and return NEWPLIST.
748 */ 757 */