comparison src/eval.c @ 27554:229352fdbf68

Fix various doc strings not to duplicate information from help-manyarg-func-alist.
author Dave Love <fx@gnu.org>
date Tue, 01 Feb 2000 14:54:52 +0000
parents 1e2af531f308
children e809aae28ae6
comparison
equal deleted inserted replaced
27553:49dd86912d71 27554:229352fdbf68
1 /* Evaluator for GNU Emacs Lisp interpreter. 1 /* Evaluator for GNU Emacs Lisp interpreter.
2 Copyright (C) 1985, 86, 87, 93, 94, 95, 1999 Free Software Foundation, Inc. 2 Copyright (C) 1985, 86, 87, 93, 94, 95, 99, 2000
3 Free Software Foundation, Inc.
3 4
4 This file is part of GNU Emacs. 5 This file is part of GNU Emacs.
5 6
6 GNU Emacs is free software; you can redistribute it and/or modify 7 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
305 UNGCPRO; 306 UNGCPRO;
306 return val; 307 return val;
307 } 308 }
308 309
309 DEFUN ("if", Fif, Sif, 2, UNEVALLED, 0, 310 DEFUN ("if", Fif, Sif, 2, UNEVALLED, 0,
310 "(if COND THEN ELSE...): if COND yields non-nil, do THEN, else do ELSE...\n\ 311 "If COND yields non-nil, do THEN, else do ELSE...\n\
311 Returns the value of THEN or the value of the last of the ELSE's.\n\ 312 Returns the value of THEN or the value of the last of the ELSE's.\n\
312 THEN must be one expression, but ELSE... can be zero or more expressions.\n\ 313 THEN must be one expression, but ELSE... can be zero or more expressions.\n\
313 If COND yields nil, and there are no ELSE's, the value is nil.") 314 If COND yields nil, and there are no ELSE's, the value is nil.")
314 (args) 315 (args)
315 Lisp_Object args; 316 Lisp_Object args;
325 return Feval (Fcar (Fcdr (args))); 326 return Feval (Fcar (Fcdr (args)));
326 return Fprogn (Fcdr (Fcdr (args))); 327 return Fprogn (Fcdr (Fcdr (args)));
327 } 328 }
328 329
329 DEFUN ("cond", Fcond, Scond, 0, UNEVALLED, 0, 330 DEFUN ("cond", Fcond, Scond, 0, UNEVALLED, 0,
330 "(cond CLAUSES...): try each clause until one succeeds.\n\ 331 "Try each clause until one succeeds.\n\
331 Each clause looks like (CONDITION BODY...). CONDITION is evaluated\n\ 332 Each clause looks like (CONDITION BODY...). CONDITION is evaluated\n\
332 and, if the value is non-nil, this clause succeeds:\n\ 333 and, if the value is non-nil, this clause succeeds:\n\
333 then the expressions in BODY are evaluated and the last one's\n\ 334 then the expressions in BODY are evaluated and the last one's\n\
334 value is the value of the cond-form.\n\ 335 value is the value of the cond-form.\n\
335 If no clause succeeds, cond returns nil.\n\ 336 If no clause succeeds, cond returns nil.\n\
359 360
360 return val; 361 return val;
361 } 362 }
362 363
363 DEFUN ("progn", Fprogn, Sprogn, 0, UNEVALLED, 0, 364 DEFUN ("progn", Fprogn, Sprogn, 0, UNEVALLED, 0,
364 "(progn BODY...): eval BODY forms sequentially and return value of last one.") 365 "Eval BODY forms sequentially and return value of last one.")
365 (args) 366 (args)
366 Lisp_Object args; 367 Lisp_Object args;
367 { 368 {
368 register Lisp_Object val, tem; 369 register Lisp_Object val, tem;
369 Lisp_Object args_left; 370 Lisp_Object args_left;
397 UNGCPRO; 398 UNGCPRO;
398 return val; 399 return val;
399 } 400 }
400 401
401 DEFUN ("prog1", Fprog1, Sprog1, 1, UNEVALLED, 0, 402 DEFUN ("prog1", Fprog1, Sprog1, 1, UNEVALLED, 0,
402 "(prog1 FIRST BODY...): eval FIRST and BODY sequentially; value from FIRST.\n\ 403 "Eval FIRST and BODY sequentially; value from FIRST.\n\
403 The value of FIRST is saved during the evaluation of the remaining args,\n\ 404 The value of FIRST is saved during the evaluation of the remaining args,\n\
404 whose values are discarded.") 405 whose values are discarded.")
405 (args) 406 (args)
406 Lisp_Object args; 407 Lisp_Object args;
407 { 408 {
430 UNGCPRO; 431 UNGCPRO;
431 return val; 432 return val;
432 } 433 }
433 434
434 DEFUN ("prog2", Fprog2, Sprog2, 2, UNEVALLED, 0, 435 DEFUN ("prog2", Fprog2, Sprog2, 2, UNEVALLED, 0,
435 "(prog2 X Y BODY...): eval X, Y and BODY sequentially; value from Y.\n\ 436 "Eval X, Y and BODY sequentially; value from Y.\n\
436 The value of Y is saved during the evaluation of the remaining args,\n\ 437 The value of Y is saved during the evaluation of the remaining args,\n\
437 whose values are discarded.") 438 whose values are discarded.")
438 (args) 439 (args)
439 Lisp_Object args; 440 Lisp_Object args;
440 { 441 {
465 UNGCPRO; 466 UNGCPRO;
466 return val; 467 return val;
467 } 468 }
468 469
469 DEFUN ("setq", Fsetq, Ssetq, 0, UNEVALLED, 0, 470 DEFUN ("setq", Fsetq, Ssetq, 0, UNEVALLED, 0,
470 "(setq SYM VAL SYM VAL ...): set each SYM to the value of its VAL.\n\ 471 "Set each SYM to the value of its VAL.\n\
471 The symbols SYM are variables; they are literal (not evaluated).\n\ 472 The symbols SYM are variables; they are literal (not evaluated).\n\
472 The values VAL are expressions; they are evaluated.\n\ 473 The values VAL are expressions; they are evaluated.\n\
473 Thus, (setq x (1+ y)) sets `x' to the value of `(1+ y)'.\n\ 474 Thus, (setq x (1+ y)) sets `x' to the value of `(1+ y)'.\n\
474 The second VAL is not computed until after the first SYM is set, and so on;\n\ 475 The second VAL is not computed until after the first SYM is set, and so on;\n\
475 each VAL can use the new value of variables set earlier in the `setq'.\n\ 476 each VAL can use the new value of variables set earlier in the `setq'.\n\
566 return Qt; 567 return Qt;
567 return Qnil; 568 return Qnil;
568 } 569 }
569 570
570 DEFUN ("defun", Fdefun, Sdefun, 2, UNEVALLED, 0, 571 DEFUN ("defun", Fdefun, Sdefun, 2, UNEVALLED, 0,
571 "(defun NAME ARGLIST [DOCSTRING] BODY...): define NAME as a function.\n\ 572 "Define NAME as a function.\n\
572 The definition is (lambda ARGLIST [DOCSTRING] BODY...).\n\ 573 The definition is (lambda ARGLIST [DOCSTRING] BODY...).\n\
573 See also the function `interactive'.") 574 See also the function `interactive'.")
574 (args) 575 (args)
575 Lisp_Object args; 576 Lisp_Object args;
576 { 577 {
585 LOADHIST_ATTACH (fn_name); 586 LOADHIST_ATTACH (fn_name);
586 return fn_name; 587 return fn_name;
587 } 588 }
588 589
589 DEFUN ("defmacro", Fdefmacro, Sdefmacro, 2, UNEVALLED, 0, 590 DEFUN ("defmacro", Fdefmacro, Sdefmacro, 2, UNEVALLED, 0,
590 "(defmacro NAME ARGLIST [DOCSTRING] BODY...): define NAME as a macro.\n\ 591 "Define NAME as a macro.\n\
591 The definition is (macro lambda ARGLIST [DOCSTRING] BODY...).\n\ 592 The definition is (macro lambda ARGLIST [DOCSTRING] BODY...).\n\
592 When the macro is called, as in (NAME ARGS...),\n\ 593 When the macro is called, as in (NAME ARGS...),\n\
593 the function (lambda ARGLIST BODY...) is applied to\n\ 594 the function (lambda ARGLIST BODY...) is applied to\n\
594 the list ARGS... as it appears in the expression,\n\ 595 the list ARGS... as it appears in the expression,\n\
595 and the result should be a form to be evaluated instead of the original.") 596 and the result should be a form to be evaluated instead of the original.")
607 LOADHIST_ATTACH (fn_name); 608 LOADHIST_ATTACH (fn_name);
608 return fn_name; 609 return fn_name;
609 } 610 }
610 611
611 DEFUN ("defvar", Fdefvar, Sdefvar, 1, UNEVALLED, 0, 612 DEFUN ("defvar", Fdefvar, Sdefvar, 1, UNEVALLED, 0,
612 "(defvar SYMBOL INITVALUE DOCSTRING): define SYMBOL as a variable.\n\ 613 "Define SYMBOL as a variable.\n\
613 You are not required to define a variable in order to use it,\n\ 614 You are not required to define a variable in order to use it,\n\
614 but the definition can supply documentation and an initial value\n\ 615 but the definition can supply documentation and an initial value\n\
615 in a way that tags can recognize.\n\n\ 616 in a way that tags can recognize.\n\n\
616 INITVALUE is evaluated, and used to set SYMBOL, only if SYMBOL's value is void.\n\ 617 INITVALUE is evaluated, and used to set SYMBOL, only if SYMBOL's value is void.\n\
617 If SYMBOL is buffer-local, its default value is what is set;\n\ 618 If SYMBOL is buffer-local, its default value is what is set;\n\
647 LOADHIST_ATTACH (sym); 648 LOADHIST_ATTACH (sym);
648 return sym; 649 return sym;
649 } 650 }
650 651
651 DEFUN ("defconst", Fdefconst, Sdefconst, 2, UNEVALLED, 0, 652 DEFUN ("defconst", Fdefconst, Sdefconst, 2, UNEVALLED, 0,
652 "(defconst SYMBOL INITVALUE DOCSTRING): define SYMBOL as a constant variable.\n\ 653 "Define SYMBOL as a constant variable.\n\
653 The intent is that neither programs nor users should ever change this value.\n\ 654 The intent is that neither programs nor users should ever change this value.\n\
654 Always sets the value of SYMBOL to the result of evalling INITVALUE.\n\ 655 Always sets the value of SYMBOL to the result of evalling INITVALUE.\n\
655 If SYMBOL is buffer-local, its default value is what is set;\n\ 656 If SYMBOL is buffer-local, its default value is what is set;\n\
656 buffer-local values are not affected.\n\ 657 buffer-local values are not affected.\n\
657 DOCSTRING is optional.") 658 DOCSTRING is optional.")
662 663
663 sym = Fcar (args); 664 sym = Fcar (args);
664 if (!NILP (Fcdr (Fcdr (Fcdr (args))))) 665 if (!NILP (Fcdr (Fcdr (Fcdr (args)))))
665 error ("too many arguments"); 666 error ("too many arguments");
666 667
667 Fset_default (sym, Feval (Fcar (Fcdr (args)))); 668 tem = Feval (Fcar (Fcdr (args)));
669 if (!NILP (Vpurify_flag))
670 tem = Fpurecopy (tem);
671 Fset_default (sym, tem);
668 tem = Fcar (Fcdr (Fcdr (args))); 672 tem = Fcar (Fcdr (Fcdr (args)));
669 if (!NILP (tem)) 673 if (!NILP (tem))
670 { 674 {
671 if (!NILP (Vpurify_flag)) 675 if (!NILP (Vpurify_flag))
672 tem = Fpurecopy (tem); 676 tem = Fpurecopy (tem);
710 return Qt; 714 return Qt;
711 return Qnil; 715 return Qnil;
712 } 716 }
713 717
714 DEFUN ("let*", FletX, SletX, 1, UNEVALLED, 0, 718 DEFUN ("let*", FletX, SletX, 1, UNEVALLED, 0,
715 "(let* VARLIST BODY...): bind variables according to VARLIST then eval BODY.\n\ 719 "Bind variables according to VARLIST then eval BODY.\n\
716 The value of the last form in BODY is returned.\n\ 720 The value of the last form in BODY is returned.\n\
717 Each element of VARLIST is a symbol (which is bound to nil)\n\ 721 Each element of VARLIST is a symbol (which is bound to nil)\n\
718 or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).\n\ 722 or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).\n\
719 Each VALUEFORM can refer to the symbols already bound by this VARLIST.") 723 Each VALUEFORM can refer to the symbols already bound by this VARLIST.")
720 (args) 724 (args)
748 val = Fprogn (Fcdr (args)); 752 val = Fprogn (Fcdr (args));
749 return unbind_to (count, val); 753 return unbind_to (count, val);
750 } 754 }
751 755
752 DEFUN ("let", Flet, Slet, 1, UNEVALLED, 0, 756 DEFUN ("let", Flet, Slet, 1, UNEVALLED, 0,
753 "(let VARLIST BODY...): bind variables according to VARLIST then eval BODY.\n\ 757 "Bind variables according to VARLIST then eval BODY.\n\
754 The value of the last form in BODY is returned.\n\ 758 The value of the last form in BODY is returned.\n\
755 Each element of VARLIST is a symbol (which is bound to nil)\n\ 759 Each element of VARLIST is a symbol (which is bound to nil)\n\
756 or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).\n\ 760 or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).\n\
757 All the VALUEFORMs are evalled before any symbols are bound.") 761 All the VALUEFORMs are evalled before any symbols are bound.")
758 (args) 762 (args)
805 elt = Fprogn (Fcdr (args)); 809 elt = Fprogn (Fcdr (args));
806 return unbind_to (count, elt); 810 return unbind_to (count, elt);
807 } 811 }
808 812
809 DEFUN ("while", Fwhile, Swhile, 1, UNEVALLED, 0, 813 DEFUN ("while", Fwhile, Swhile, 1, UNEVALLED, 0,
810 "(while TEST BODY...): if TEST yields non-nil, eval BODY... and repeat.\n\ 814 "If TEST yields non-nil, eval BODY... and repeat.\n\
811 The order of execution is thus TEST, BODY, TEST, BODY and so on\n\ 815 The order of execution is thus TEST, BODY, TEST, BODY and so on\n\
812 until TEST returns nil.") 816 until TEST returns nil.")
813 (args) 817 (args)
814 Lisp_Object args; 818 Lisp_Object args;
815 { 819 {
908 } 912 }
909 return form; 913 return form;
910 } 914 }
911 915
912 DEFUN ("catch", Fcatch, Scatch, 1, UNEVALLED, 0, 916 DEFUN ("catch", Fcatch, Scatch, 1, UNEVALLED, 0,
913 "(catch TAG BODY...): eval BODY allowing nonlocal exits using `throw'.\n\ 917 "Eval BODY allowing nonlocal exits using `throw'.\n\
914 TAG is evalled to get the tag to use; it must not be nil.\n\ 918 TAG is evalled to get the tag to use; it must not be nil.\n\
915 \n\ 919 \n\
916 Then the BODY is executed.\n\ 920 Then the BODY is executed.\n\
917 Within BODY, (throw TAG) with same tag exits BODY and exits this `catch'.\n\ 921 Within BODY, (throw TAG) with same tag exits BODY and exits this `catch'.\n\
918 If no throw happens, `catch' returns the value of the last BODY form.\n\ 922 If no throw happens, `catch' returns the value of the last BODY form.\n\
1018 1022
1019 _longjmp (catch->jmp, 1); 1023 _longjmp (catch->jmp, 1);
1020 } 1024 }
1021 1025
1022 DEFUN ("throw", Fthrow, Sthrow, 2, 2, 0, 1026 DEFUN ("throw", Fthrow, Sthrow, 2, 2, 0,
1023 "(throw TAG VALUE): throw to the catch for TAG and return VALUE from it.\n\ 1027 "Throw to the catch for TAG and return VALUE from it.\n\
1024 Both TAG and VALUE are evalled.") 1028 Both TAG and VALUE are evalled.")
1025 (tag, value) 1029 (tag, value)
1026 register Lisp_Object tag, value; 1030 register Lisp_Object tag, value;
1027 { 1031 {
1028 register struct catchtag *c; 1032 register struct catchtag *c;
1040 } 1044 }
1041 1045
1042 1046
1043 DEFUN ("unwind-protect", Funwind_protect, Sunwind_protect, 1, UNEVALLED, 0, 1047 DEFUN ("unwind-protect", Funwind_protect, Sunwind_protect, 1, UNEVALLED, 0,
1044 "Do BODYFORM, protecting with UNWINDFORMS.\n\ 1048 "Do BODYFORM, protecting with UNWINDFORMS.\n\
1045 Usage looks like (unwind-protect BODYFORM UNWINDFORMS...).\n\
1046 If BODYFORM completes normally, its value is returned\n\ 1049 If BODYFORM completes normally, its value is returned\n\
1047 after executing the UNWINDFORMS.\n\ 1050 after executing the UNWINDFORMS.\n\
1048 If BODYFORM exits nonlocally, the UNWINDFORMS are executed anyway.") 1051 If BODYFORM exits nonlocally, the UNWINDFORMS are executed anyway.")
1049 (args) 1052 (args)
1050 Lisp_Object args; 1053 Lisp_Object args;
1065 1068
1066 struct handler *handlerlist; 1069 struct handler *handlerlist;
1067 1070
1068 DEFUN ("condition-case", Fcondition_case, Scondition_case, 2, UNEVALLED, 0, 1071 DEFUN ("condition-case", Fcondition_case, Scondition_case, 2, UNEVALLED, 0,
1069 "Regain control when an error is signaled.\n\ 1072 "Regain control when an error is signaled.\n\
1070 Usage looks like (condition-case VAR BODYFORM HANDLERS...).\n\
1071 executes BODYFORM and returns its value if no error happens.\n\ 1073 executes BODYFORM and returns its value if no error happens.\n\
1072 Each element of HANDLERS looks like (CONDITION-NAME BODY...)\n\ 1074 Each element of HANDLERS looks like (CONDITION-NAME BODY...)\n\
1073 where the BODY is made of Lisp expressions.\n\n\ 1075 where the BODY is made of Lisp expressions.\n\n\
1074 A handler is applicable to an error\n\ 1076 A handler is applicable to an error\n\
1075 if CONDITION-NAME is one of the error's condition names.\n\ 1077 if CONDITION-NAME is one of the error's condition names.\n\