comparison src/eval.c @ 5118:e0db3c197671 ben-lisp-object

merge up to latest default branch, doesn't compile yet
author Ben Wing <ben@xemacs.org>
date Sat, 26 Dec 2009 21:18:49 -0600
parents 3742ea8250b5 17f7e9191c0b
children 623d57b7fbe8
comparison
equal deleted inserted replaced
5117:3742ea8250b5 5118:e0db3c197671
239 Lisp_Object Qsetq; 239 Lisp_Object Qsetq;
240 Lisp_Object Qdisplay_warning; 240 Lisp_Object Qdisplay_warning;
241 Lisp_Object Vpending_warnings, Vpending_warnings_tail; 241 Lisp_Object Vpending_warnings, Vpending_warnings_tail;
242 Lisp_Object Qif; 242 Lisp_Object Qif;
243 243
244 Lisp_Object Qthrow;
245 Lisp_Object Qobsolete_throw;
246 Lisp_Object Qmultiple_value_list_internal;
247
248 static int first_desired_multiple_value;
249 /* Used outside this file, somewhat uncleanly, in the IGNORE_MULTIPLE_VALUES
250 macro: */
251 int multiple_value_current_limit;
252
253 Fixnum Vmultiple_values_limit;
254
244 /* Flags specifying which operations are currently inhibited. */ 255 /* Flags specifying which operations are currently inhibited. */
245 int inhibit_flags; 256 int inhibit_flags;
246 257
247 /* Buffers, frames, windows, devices, and consoles created since most 258 /* Buffers, frames, windows, devices, and consoles created since most
248 recent active 259 recent active
431 static const struct memory_description subr_description[] = { 442 static const struct memory_description subr_description[] = {
432 { XD_DOC_STRING, offsetof (Lisp_Subr, doc), 0, { 0 }, XD_FLAG_NO_KKCC }, 443 { XD_DOC_STRING, offsetof (Lisp_Subr, doc), 0, { 0 }, XD_FLAG_NO_KKCC },
433 { XD_END } 444 { XD_END }
434 }; 445 };
435 446
436 DEFINE_BASIC_LISP_OBJECT ("subr", subr, 447 DEFINE_DUMPABLE_FROB_BLOCK_LISP_OBJECT ("subr", subr,
437 0, print_subr, 0, 0, 0, 448 0, print_subr, 0, 0, 0,
438 subr_description, 449 subr_description,
439 Lisp_Subr); 450 Lisp_Subr);
440 451
441 /************************************************************************/ 452 /************************************************************************/
442 /* Entering the debugger */ 453 /* Entering the debugger */
443 /************************************************************************/ 454 /************************************************************************/
444 455
597 } 608 }
598 609
599 610
600 /* Return 1 if an error with condition-symbols CONDITIONS, 611 /* Return 1 if an error with condition-symbols CONDITIONS,
601 and described by SIGNAL-DATA, should skip the debugger 612 and described by SIGNAL-DATA, should skip the debugger
602 according to debugger-ignore-errors. */ 613 according to debug-ignored-errors. */
603 614
604 static int 615 static int
605 skip_debugger (Lisp_Object conditions, Lisp_Object data) 616 skip_debugger (Lisp_Object conditions, Lisp_Object data)
606 { 617 {
607 /* This function can GC */ 618 /* This function can GC */
813 824
814 /* Except for Fprogn(), the basic special forms below are only called 825 /* Except for Fprogn(), the basic special forms below are only called
815 from interpreted code. The byte compiler turns them into bytecodes. */ 826 from interpreted code. The byte compiler turns them into bytecodes. */
816 827
817 DEFUN ("or", For, 0, UNEVALLED, 0, /* 828 DEFUN ("or", For, 0, UNEVALLED, 0, /*
818 Eval args until one of them yields non-nil, then return that value. 829 Eval ARGS until one of them yields non-nil, then return that value.
819 The remaining args are not evalled at all. 830 The remaining ARGS are not evalled at all.
820 If all args return nil, return nil. 831 If all args return nil, return nil.
832
833 Any multiple values from the last form, and only from the last form, are
834 passed back. See `values' and `multiple-value-bind'.
835
836 arguments: (&rest ARGS)
821 */ 837 */
822 (args)) 838 (args))
823 { 839 {
824 /* This function can GC */ 840 /* This function can GC */
825 REGISTER Lisp_Object val; 841 Lisp_Object val = Qnil;
826 842
827 LIST_LOOP_2 (arg, args) 843 LIST_LOOP_3 (arg, args, tail)
828 { 844 {
829 if (!NILP (val = Feval (arg))) 845 if (!NILP (IGNORE_MULTIPLE_VALUES (val = Feval (arg))))
830 return val; 846 {
831 } 847 if (NILP (XCDR (tail)))
832 848 {
833 return Qnil; 849 /* Pass back multiple values if this is the last one: */
850 return val;
851 }
852
853 return IGNORE_MULTIPLE_VALUES (val);
854 }
855 }
856
857 return val;
834 } 858 }
835 859
836 DEFUN ("and", Fand, 0, UNEVALLED, 0, /* 860 DEFUN ("and", Fand, 0, UNEVALLED, 0, /*
837 Eval args until one of them yields nil, then return nil. 861 Eval ARGS until one of them yields nil, then return nil.
838 The remaining args are not evalled at all. 862 The remaining ARGS are not evalled at all.
839 If no arg yields nil, return the last arg's value. 863 If no arg yields nil, return the last arg's value.
864
865 Any multiple values from the last form, and only from the last form, are
866 passed back. See `values' and `multiple-value-bind'.
867
868 arguments: (&rest ARGS)
840 */ 869 */
841 (args)) 870 (args))
842 { 871 {
843 /* This function can GC */ 872 /* This function can GC */
844 REGISTER Lisp_Object val = Qt; 873 Lisp_Object val = Qt;
845 874
846 LIST_LOOP_2 (arg, args) 875 LIST_LOOP_3 (arg, args, tail)
847 { 876 {
848 if (NILP (val = Feval (arg))) 877 if (NILP (IGNORE_MULTIPLE_VALUES (val = Feval (arg))))
849 return val; 878 {
879 if (NILP (XCDR (tail)))
880 {
881 /* Pass back any multiple values for the last form: */
882 return val;
883 }
884
885 return Qnil;
886 }
850 } 887 }
851 888
852 return val; 889 return val;
853 } 890 }
854 891
855 DEFUN ("if", Fif, 2, UNEVALLED, 0, /* 892 DEFUN ("if", Fif, 2, UNEVALLED, 0, /*
856 \(if COND THEN ELSE...): if COND yields non-nil, do THEN, else do ELSE... 893 If COND yields non-nil, do THEN, else do ELSE.
857 Returns the value of THEN or the value of the last of the ELSE's. 894 Returns the value of THEN or the value of the last of the ELSE's.
858 THEN must be one expression, but ELSE... can be zero or more expressions. 895 THEN must be one expression, but ELSE... can be zero or more expressions.
859 If COND yields nil, and there are no ELSE's, the value is nil. 896 If COND yields nil, and there are no ELSE's, the value is nil.
897
898 arguments: (COND THEN &rest ELSE)
860 */ 899 */
861 (args)) 900 (args))
862 { 901 {
863 /* This function can GC */ 902 /* This function can GC */
864 Lisp_Object condition = XCAR (args); 903 Lisp_Object condition = XCAR (args);
865 Lisp_Object then_form = XCAR (XCDR (args)); 904 Lisp_Object then_form = XCAR (XCDR (args));
866 Lisp_Object else_forms = XCDR (XCDR (args)); 905 Lisp_Object else_forms = XCDR (XCDR (args));
867 906
868 if (!NILP (Feval (condition))) 907 if (!NILP (IGNORE_MULTIPLE_VALUES (Feval (condition))))
869 return Feval (then_form); 908 return Feval (then_form);
870 else 909 else
871 return Fprogn (else_forms); 910 return Fprogn (else_forms);
872 } 911 }
873 912
874 /* Macros `when' and `unless' are trivially defined in Lisp, 913 /* Macros `when' and `unless' are trivially defined in Lisp,
875 but it helps for bootstrapping to have them ALWAYS defined. */ 914 but it helps for bootstrapping to have them ALWAYS defined. */
876 915
877 DEFUN ("when", Fwhen, 1, MANY, 0, /* 916 DEFUN ("when", Fwhen, 1, MANY, 0, /*
878 \(when COND BODY...): if COND yields non-nil, do BODY, else return nil. 917 If COND yields non-nil, do BODY, else return nil.
879 BODY can be zero or more expressions. If BODY is nil, return nil. 918 BODY can be zero or more expressions. If BODY is nil, return nil.
919
920 arguments: (COND &rest BODY)
880 */ 921 */
881 (int nargs, Lisp_Object *args)) 922 (int nargs, Lisp_Object *args))
882 { 923 {
883 Lisp_Object cond = args[0]; 924 Lisp_Object cond = args[0];
884 Lisp_Object body; 925 Lisp_Object body;
892 933
893 return list3 (Qif, cond, body); 934 return list3 (Qif, cond, body);
894 } 935 }
895 936
896 DEFUN ("unless", Funless, 1, MANY, 0, /* 937 DEFUN ("unless", Funless, 1, MANY, 0, /*
897 \(unless COND BODY...): if COND yields nil, do BODY, else return nil. 938 If COND yields nil, do BODY, else return nil.
898 BODY can be zero or more expressions. If BODY is nil, return nil. 939 BODY can be zero or more expressions. If BODY is nil, return nil.
940
941 arguments: (COND &rest BODY)
899 */ 942 */
900 (int nargs, Lisp_Object *args)) 943 (int nargs, Lisp_Object *args))
901 { 944 {
902 Lisp_Object cond = args[0]; 945 Lisp_Object cond = args[0];
903 Lisp_Object body = Flist (nargs-1, args+1); 946 Lisp_Object body = Flist (nargs-1, args+1);
904 return Fcons (Qif, Fcons (cond, Fcons (Qnil, body))); 947 return Fcons (Qif, Fcons (cond, Fcons (Qnil, body)));
905 } 948 }
906 949
907 DEFUN ("cond", Fcond, 0, UNEVALLED, 0, /* 950 DEFUN ("cond", Fcond, 0, UNEVALLED, 0, /*
908 \(cond CLAUSES...): try each clause until one succeeds. 951 Try each clause until one succeeds.
909 Each clause looks like (CONDITION BODY...). CONDITION is evaluated 952 Each clause looks like (CONDITION BODY...). CONDITION is evaluated
910 and, if the value is non-nil, this clause succeeds: 953 and, if the value is non-nil, this clause succeeds:
911 then the expressions in BODY are evaluated and the last one's 954 then the expressions in BODY are evaluated and the last one's
912 value is the value of the cond-form. 955 value is the value of the cond-form.
913 If no clause succeeds, cond returns nil. 956 If no clause succeeds, cond returns nil.
914 If a clause has one element, as in (CONDITION), 957 If a clause has one element, as in (CONDITION),
915 CONDITION's value if non-nil is returned from the cond-form. 958 CONDITION's value if non-nil is returned from the cond-form.
959
960 arguments: (&rest CLAUSES)
916 */ 961 */
917 (args)) 962 (args))
918 { 963 {
919 /* This function can GC */ 964 /* This function can GC */
920 REGISTER Lisp_Object val; 965 REGISTER Lisp_Object val;
921 966
922 LIST_LOOP_2 (clause, args) 967 LIST_LOOP_2 (clause, args)
923 { 968 {
924 CHECK_CONS (clause); 969 CHECK_CONS (clause);
925 if (!NILP (val = Feval (XCAR (clause)))) 970 if (!NILP (val = IGNORE_MULTIPLE_VALUES (Feval (XCAR (clause)))))
926 { 971 {
927 if (!NILP (clause = XCDR (clause))) 972 if (!NILP (clause = XCDR (clause)))
928 { 973 {
929 CHECK_TRUE_LIST (clause); 974 CHECK_TRUE_LIST (clause);
975 /* Pass back any multiple values here: */
930 val = Fprogn (clause); 976 val = Fprogn (clause);
931 } 977 }
932 return val; 978 return val;
933 } 979 }
934 } 980 }
935 981
936 return Qnil; 982 return Qnil;
937 } 983 }
938 984
939 DEFUN ("progn", Fprogn, 0, UNEVALLED, 0, /* 985 DEFUN ("progn", Fprogn, 0, UNEVALLED, 0, /*
940 \(progn BODY...): eval BODY forms sequentially and return value of last one. 986 Eval BODY forms sequentially and return value of last one.
987
988 arguments: (&rest BODY)
941 */ 989 */
942 (args)) 990 (args))
943 { 991 {
944 /* This function can GC */ 992 /* This function can GC */
945 /* Caller must provide a true list in ARGS */ 993 /* Caller must provide a true list in ARGS */
960 /* Fprog1() is the canonical example of a function that must GCPRO a 1008 /* Fprog1() is the canonical example of a function that must GCPRO a
961 Lisp_Object across calls to Feval(). */ 1009 Lisp_Object across calls to Feval(). */
962 1010
963 DEFUN ("prog1", Fprog1, 1, UNEVALLED, 0, /* 1011 DEFUN ("prog1", Fprog1, 1, UNEVALLED, 0, /*
964 Similar to `progn', but the value of the first form is returned. 1012 Similar to `progn', but the value of the first form is returned.
965 \(prog1 FIRST BODY...): All the arguments are evaluated sequentially. 1013
966 The value of FIRST is saved during evaluation of the remaining args, 1014 All the arguments are evaluated sequentially. The value of FIRST is saved
967 whose values are discarded. 1015 during evaluation of the remaining args, whose values are discarded.
1016
1017 arguments: (FIRST &rest BODY)
968 */ 1018 */
969 (args)) 1019 (args))
970 { 1020 {
971 /* This function can GC */
972 Lisp_Object val; 1021 Lisp_Object val;
973 struct gcpro gcpro1; 1022 struct gcpro gcpro1;
974 1023
975 val = Feval (XCAR (args)); 1024 val = IGNORE_MULTIPLE_VALUES (Feval (Fcar (args)));
976 1025
977 GCPRO1 (val); 1026 GCPRO1 (val);
978 1027
979 { 1028 {
980 LIST_LOOP_2 (form, XCDR (args)) 1029 LIST_LOOP_2 (form, XCDR (args))
985 return val; 1034 return val;
986 } 1035 }
987 1036
988 DEFUN ("prog2", Fprog2, 2, UNEVALLED, 0, /* 1037 DEFUN ("prog2", Fprog2, 2, UNEVALLED, 0, /*
989 Similar to `progn', but the value of the second form is returned. 1038 Similar to `progn', but the value of the second form is returned.
990 \(prog2 FIRST SECOND BODY...): All the arguments are evaluated sequentially. 1039
991 The value of SECOND is saved during evaluation of the remaining args, 1040 All the arguments are evaluated sequentially. The value of SECOND is saved
992 whose values are discarded. 1041 during evaluation of the remaining args, whose values are discarded.
1042
1043 arguments: (FIRST SECOND &rest BODY)
993 */ 1044 */
994 (args)) 1045 (args))
995 { 1046 {
996 /* This function can GC */ 1047 /* This function can GC */
997 Lisp_Object val; 1048 Lisp_Object val;
998 struct gcpro gcpro1; 1049 struct gcpro gcpro1;
999 1050
1000 Feval (XCAR (args)); 1051 Feval (XCAR (args));
1001 args = XCDR (args); 1052 args = XCDR (args);
1002 val = Feval (XCAR (args)); 1053
1054 val = IGNORE_MULTIPLE_VALUES (Feval (XCAR (args)));
1055
1003 args = XCDR (args); 1056 args = XCDR (args);
1004 1057
1005 GCPRO1 (val); 1058 GCPRO1 (val);
1006 1059
1007 { 1060 {
1012 UNGCPRO; 1065 UNGCPRO;
1013 return val; 1066 return val;
1014 } 1067 }
1015 1068
1016 DEFUN ("let*", FletX, 1, UNEVALLED, 0, /* 1069 DEFUN ("let*", FletX, 1, UNEVALLED, 0, /*
1017 \(let* VARLIST BODY...): bind variables according to VARLIST then eval BODY. 1070 Bind variables according to VARLIST then eval BODY.
1018 The value of the last form in BODY is returned. 1071 The value of the last form in BODY is returned.
1019 Each element of VARLIST is a symbol (which is bound to nil) 1072 Each element of VARLIST is a symbol (which is bound to nil)
1020 or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM). 1073 or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).
1021 Each VALUEFORM can refer to the symbols already bound by this VARLIST. 1074 Each VALUEFORM can refer to the symbols already bound by this VARLIST.
1075
1076 arguments: (VARLIST &rest BODY)
1022 */ 1077 */
1023 (args)) 1078 (args))
1024 { 1079 {
1025 /* This function can GC */ 1080 /* This function can GC */
1026 Lisp_Object varlist = XCAR (args); 1081 Lisp_Object varlist = XCAR (args);
1040 if (NILP (tem)) 1095 if (NILP (tem))
1041 value = Qnil; 1096 value = Qnil;
1042 else 1097 else
1043 { 1098 {
1044 CHECK_CONS (tem); 1099 CHECK_CONS (tem);
1045 value = Feval (XCAR (tem)); 1100 value = IGNORE_MULTIPLE_VALUES (Feval (XCAR (tem)));
1046 if (!NILP (XCDR (tem))) 1101 if (!NILP (XCDR (tem)))
1047 sferror 1102 sferror
1048 ("`let' bindings can have only one value-form", var); 1103 ("`let' bindings can have only one value-form", var);
1049 } 1104 }
1050 } 1105 }
1052 } 1107 }
1053 return unbind_to_1 (speccount, Fprogn (body)); 1108 return unbind_to_1 (speccount, Fprogn (body));
1054 } 1109 }
1055 1110
1056 DEFUN ("let", Flet, 1, UNEVALLED, 0, /* 1111 DEFUN ("let", Flet, 1, UNEVALLED, 0, /*
1057 \(let VARLIST BODY...): bind variables according to VARLIST then eval BODY. 1112 Bind variables according to VARLIST then eval BODY.
1058 The value of the last form in BODY is returned. 1113 The value of the last form in BODY is returned.
1059 Each element of VARLIST is a symbol (which is bound to nil) 1114 Each element of VARLIST is a symbol (which is bound to nil)
1060 or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM). 1115 or a list (SYMBOL VALUEFORM) (which binds SYMBOL to the value of VALUEFORM).
1061 All the VALUEFORMs are evalled before any symbols are bound. 1116 All the VALUEFORMs are evalled before any symbols are bound.
1117
1118 arguments: (VARLIST &rest BODY)
1062 */ 1119 */
1063 (args)) 1120 (args))
1064 { 1121 {
1065 /* This function can GC */ 1122 /* This function can GC */
1066 Lisp_Object varlist = XCAR (args); 1123 Lisp_Object varlist = XCAR (args);
1096 if (NILP (tem)) 1153 if (NILP (tem))
1097 *value = Qnil; 1154 *value = Qnil;
1098 else 1155 else
1099 { 1156 {
1100 CHECK_CONS (tem); 1157 CHECK_CONS (tem);
1101 *value = Feval (XCAR (tem)); 1158 *value = IGNORE_MULTIPLE_VALUES (Feval (XCAR (tem)));
1102 gcpro1.nvars = idx; 1159 gcpro1.nvars = idx;
1103 1160
1104 if (!NILP (XCDR (tem))) 1161 if (!NILP (XCDR (tem)))
1105 sferror 1162 sferror
1106 ("`let' bindings can have only one value-form", var); 1163 ("`let' bindings can have only one value-form", var);
1121 1178
1122 return unbind_to_1 (speccount, Fprogn (body)); 1179 return unbind_to_1 (speccount, Fprogn (body));
1123 } 1180 }
1124 1181
1125 DEFUN ("while", Fwhile, 1, UNEVALLED, 0, /* 1182 DEFUN ("while", Fwhile, 1, UNEVALLED, 0, /*
1126 \(while TEST BODY...): if TEST yields non-nil, eval BODY... and repeat. 1183 If TEST yields non-nil, eval BODY... and repeat.
1127 The order of execution is thus TEST, BODY, TEST, BODY and so on 1184 The order of execution is thus TEST, BODY, TEST, BODY and so on
1128 until TEST returns nil. 1185 until TEST returns nil.
1186
1187 arguments: (TEST &rest BODY)
1129 */ 1188 */
1130 (args)) 1189 (args))
1131 { 1190 {
1132 /* This function can GC */ 1191 /* This function can GC */
1133 Lisp_Object test = XCAR (args); 1192 Lisp_Object test = XCAR (args);
1134 Lisp_Object body = XCDR (args); 1193 Lisp_Object body = XCDR (args);
1135 1194
1136 while (!NILP (Feval (test))) 1195 while (!NILP (IGNORE_MULTIPLE_VALUES (Feval (test))))
1137 { 1196 {
1138 QUIT; 1197 QUIT;
1139 Fprogn (body); 1198 Fprogn (body);
1140 } 1199 }
1141 1200
1163 Fsignal (Qwrong_number_of_arguments, list2 (Qsetq, make_int (nargs))); 1222 Fsignal (Qwrong_number_of_arguments, list2 (Qsetq, make_int (nargs)));
1164 1223
1165 GC_PROPERTY_LIST_LOOP_3 (symbol, val, args) 1224 GC_PROPERTY_LIST_LOOP_3 (symbol, val, args)
1166 { 1225 {
1167 val = Feval (val); 1226 val = Feval (val);
1227 val = IGNORE_MULTIPLE_VALUES (val);
1168 Fset (symbol, val); 1228 Fset (symbol, val);
1169 retval = val; 1229 retval = val;
1170 } 1230 }
1171 1231
1172 END_GC_PROPERTY_LIST_LOOP (symbol); 1232 END_GC_PROPERTY_LIST_LOOP (symbol);
1174 return retval; 1234 return retval;
1175 } 1235 }
1176 1236
1177 DEFUN ("quote", Fquote, 1, UNEVALLED, 0, /* 1237 DEFUN ("quote", Fquote, 1, UNEVALLED, 0, /*
1178 Return the argument, without evaluating it. `(quote x)' yields `x'. 1238 Return the argument, without evaluating it. `(quote x)' yields `x'.
1239
1240 `quote' differs from `function' in that it is a hint that an expression is
1241 data, not a function. In particular, under some circumstances the byte
1242 compiler will compile an expression quoted with `function', but it will
1243 never do so for an expression quoted with `quote'. These issues are most
1244 important for lambda expressions (see `lambda').
1245
1246 There is an alternative, more readable, reader syntax for `quote': a Lisp
1247 object preceded by `''. Thus, `'x' is equivalent to `(quote x)', in all
1248 contexts. A print function may use either. Internally the expression is
1249 represented as `(quote x)').
1179 */ 1250 */
1180 (args)) 1251 (args))
1181 { 1252 {
1182 return XCAR (args); 1253 return XCAR (args);
1183 } 1254 }
1184 1255
1256 /* Originally, this was just a function -- but `custom' used a garden-
1257 variety version, so why not make it a subr? */
1258 DEFUN ("quote-maybe", Fquote_maybe, 1, 1, 0, /*
1259 Quote EXPR if it is not self quoting.
1260
1261 In contrast with `quote', this is a function, not a special form; its
1262 argument is evaluated before `quote-maybe' is called. It returns either
1263 EXPR (if it is self-quoting) or a list `(quote EXPR)' if it is not
1264 self-quoting. Lists starting with the symbol `lambda' are regarded as
1265 self-quoting.
1266 */
1267 (expr))
1268 {
1269 if ((XTYPE (expr)) == Lisp_Type_Record)
1270 {
1271 switch (XRECORD_LHEADER (expr)->type)
1272 {
1273 case lrecord_type_symbol:
1274 if (NILP (expr) || (EQ (expr, Qt)) || SYMBOL_IS_KEYWORD (expr))
1275 {
1276 return expr;
1277 }
1278 break;
1279 case lrecord_type_cons:
1280 if (EQ (XCAR (expr), Qlambda))
1281 {
1282 return expr;
1283 }
1284 break;
1285
1286 case lrecord_type_vector:
1287 case lrecord_type_string:
1288 case lrecord_type_compiled_function:
1289 case lrecord_type_bit_vector:
1290 case lrecord_type_float:
1291 case lrecord_type_hash_table:
1292 case lrecord_type_char_table:
1293 case lrecord_type_range_table:
1294 case lrecord_type_bignum:
1295 case lrecord_type_ratio:
1296 case lrecord_type_bigfloat:
1297 return expr;
1298 }
1299 return list2 (Qquote, expr);
1300 }
1301
1302 /* Fixnums and characters are self-quoting: */
1303 return expr;
1304 }
1305
1185 DEFUN ("function", Ffunction, 1, UNEVALLED, 0, /* 1306 DEFUN ("function", Ffunction, 1, UNEVALLED, 0, /*
1186 Like `quote', but preferred for objects which are functions. 1307 Return the argument, without evaluating it. `(function x)' yields `x'.
1187 In byte compilation, `function' causes its argument to be compiled. 1308
1188 `quote' cannot do that. 1309 `function' differs from `quote' in that it is a hint that an expression is
1310 a function, not data. In particular, under some circumstances the byte
1311 compiler will compile an expression quoted with `function', but it will
1312 never do so for an expression quoted with `quote'. However, the byte
1313 compiler will not compile an expression buried in a data structure such as
1314 a vector or a list which is not syntactically a function. These issues are
1315 most important for lambda expressions (see `lambda').
1316
1317 There is an alternative, more readable, reader syntax for `function': a Lisp
1318 object preceded by `#''. Thus, #'x is equivalent to (function x), in all
1319 contexts. A print function may use either. Internally the expression is
1320 represented as `(function x)').
1189 */ 1321 */
1190 (args)) 1322 (args))
1191 { 1323 {
1192 return XCAR (args); 1324 return XCAR (args);
1193 } 1325 }
1198 /************************************************************************/ 1330 /************************************************************************/
1199 static Lisp_Object 1331 static Lisp_Object
1200 define_function (Lisp_Object name, Lisp_Object defn) 1332 define_function (Lisp_Object name, Lisp_Object defn)
1201 { 1333 {
1202 Ffset (name, defn); 1334 Ffset (name, defn);
1203 LOADHIST_ATTACH (name); 1335 LOADHIST_ATTACH (Fcons (Qdefun, name));
1204 return name; 1336 return name;
1205 } 1337 }
1206 1338
1207 DEFUN ("defun", Fdefun, 2, UNEVALLED, 0, /* 1339 DEFUN ("defun", Fdefun, 2, UNEVALLED, 0, /*
1208 \(defun NAME ARGLIST [DOCSTRING] BODY...): define NAME as a function. 1340 Define NAME as a function.
1209 The definition is (lambda ARGLIST [DOCSTRING] BODY...). 1341 The definition is (lambda ARGLIST [DOCSTRING] BODY...).
1210 See also the function `interactive'. 1342 See also the function `interactive'.
1343
1344 arguments: (NAME ARGLIST &optional DOCSTRING &rest BODY)
1211 */ 1345 */
1212 (args)) 1346 (args))
1213 { 1347 {
1214 /* This function can GC */ 1348 /* This function can GC */
1215 return define_function (XCAR (args), 1349 return define_function (XCAR (args),
1216 Fcons (Qlambda, XCDR (args))); 1350 Fcons (Qlambda, XCDR (args)));
1217 } 1351 }
1218 1352
1219 DEFUN ("defmacro", Fdefmacro, 2, UNEVALLED, 0, /* 1353 DEFUN ("defmacro", Fdefmacro, 2, UNEVALLED, 0, /*
1220 \(defmacro NAME ARGLIST [DOCSTRING] BODY...): define NAME as a macro. 1354 Define NAME as a macro.
1221 The definition is (macro lambda ARGLIST [DOCSTRING] BODY...). 1355 The definition is (macro lambda ARGLIST [DOCSTRING] BODY...).
1222 When the macro is called, as in (NAME ARGS...), 1356 When the macro is called, as in (NAME ARGS...),
1223 the function (lambda ARGLIST BODY...) is applied to 1357 the function (lambda ARGLIST BODY...) is applied to
1224 the list ARGS... as it appears in the expression, 1358 the list ARGS... as it appears in the expression,
1225 and the result should be a form to be evaluated instead of the original. 1359 and the result should be a form to be evaluated instead of the original.
1360
1361 arguments: (NAME ARGLIST &optional DOCSTRING &rest BODY)
1226 */ 1362 */
1227 (args)) 1363 (args))
1228 { 1364 {
1229 /* This function can GC */ 1365 /* This function can GC */
1230 return define_function (XCAR (args), 1366 return define_function (XCAR (args),
1231 Fcons (Qmacro, Fcons (Qlambda, XCDR (args)))); 1367 Fcons (Qmacro, Fcons (Qlambda, XCDR (args))));
1232 } 1368 }
1233 1369
1234 DEFUN ("defvar", Fdefvar, 1, UNEVALLED, 0, /* 1370 DEFUN ("defvar", Fdefvar, 1, UNEVALLED, 0, /*
1235 \(defvar SYMBOL INITVALUE DOCSTRING): define SYMBOL as a variable. 1371 Define SYMBOL as a variable.
1236 You are not required to define a variable in order to use it, 1372 You are not required to define a variable in order to use it,
1237 but the definition can supply documentation and an initial value 1373 but the definition can supply documentation and an initial value
1238 in a way that tags can recognize. 1374 in a way that tags can recognize.
1239 1375
1240 INITVALUE is evaluated, and used to set SYMBOL, only if SYMBOL's value is 1376 INITVALUE is evaluated, and used to set SYMBOL, only if SYMBOL's value is
1247 If DOCSTRING starts with *, this variable is identified as a user option. 1383 If DOCSTRING starts with *, this variable is identified as a user option.
1248 This means that M-x set-variable recognizes it. 1384 This means that M-x set-variable recognizes it.
1249 If INITVALUE is missing, SYMBOL's value is not set. 1385 If INITVALUE is missing, SYMBOL's value is not set.
1250 1386
1251 In lisp-interaction-mode defvar is treated as defconst. 1387 In lisp-interaction-mode defvar is treated as defconst.
1388
1389 arguments: (SYMBOL &optional INITVALUE DOCSTRING)
1252 */ 1390 */
1253 (args)) 1391 (args))
1254 { 1392 {
1255 /* This function can GC */ 1393 /* This function can GC */
1256 Lisp_Object sym = XCAR (args); 1394 Lisp_Object sym = XCAR (args);
1261 1399
1262 if (NILP (Fdefault_boundp (sym))) 1400 if (NILP (Fdefault_boundp (sym)))
1263 { 1401 {
1264 struct gcpro gcpro1; 1402 struct gcpro gcpro1;
1265 GCPRO1 (val); 1403 GCPRO1 (val);
1266 val = Feval (val); 1404 val = IGNORE_MULTIPLE_VALUES (Feval (val));
1267 Fset_default (sym, val); 1405 Fset_default (sym, val);
1268 UNGCPRO; 1406 UNGCPRO;
1269 } 1407 }
1270 1408
1271 if (!NILP (args = XCDR (args))) 1409 if (!NILP (args = XCDR (args)))
1285 LOADHIST_ATTACH (sym); 1423 LOADHIST_ATTACH (sym);
1286 return sym; 1424 return sym;
1287 } 1425 }
1288 1426
1289 DEFUN ("defconst", Fdefconst, 2, UNEVALLED, 0, /* 1427 DEFUN ("defconst", Fdefconst, 2, UNEVALLED, 0, /*
1290 \(defconst SYMBOL INITVALUE DOCSTRING): define SYMBOL as a constant 1428 Define SYMBOL as a constant variable.
1291 variable.
1292 The intent is that programs do not change this value, but users may. 1429 The intent is that programs do not change this value, but users may.
1293 Always sets the value of SYMBOL to the result of evalling INITVALUE. 1430 Always sets the value of SYMBOL to the result of evalling INITVALUE.
1294 If SYMBOL is buffer-local, its default value is what is set; 1431 If SYMBOL is buffer-local, its default value is what is set;
1295 buffer-local values are not affected. 1432 buffer-local values are not affected.
1296 DOCSTRING is optional. 1433 DOCSTRING is optional.
1300 Note: do not use `defconst' for user options in libraries that are not 1437 Note: do not use `defconst' for user options in libraries that are not
1301 normally loaded, since it is useful for users to be able to specify 1438 normally loaded, since it is useful for users to be able to specify
1302 their own values for such variables before loading the library. 1439 their own values for such variables before loading the library.
1303 Since `defconst' unconditionally assigns the variable, 1440 Since `defconst' unconditionally assigns the variable,
1304 it would override the user's choice. 1441 it would override the user's choice.
1442
1443 arguments: (SYMBOL &optional INITVALUE DOCSTRING)
1305 */ 1444 */
1306 (args)) 1445 (args))
1307 { 1446 {
1308 /* This function can GC */ 1447 /* This function can GC */
1309 Lisp_Object sym = XCAR (args); 1448 Lisp_Object sym = XCAR (args);
1310 Lisp_Object val = Feval (XCAR (args = XCDR (args))); 1449 Lisp_Object val = Feval (XCAR (args = XCDR (args)));
1311 struct gcpro gcpro1; 1450 struct gcpro gcpro1;
1312 1451
1313 GCPRO1 (val); 1452 GCPRO1 (val);
1314 1453
1454 val = IGNORE_MULTIPLE_VALUES (val);
1455
1315 Fset_default (sym, val); 1456 Fset_default (sym, val);
1316 1457
1317 UNGCPRO; 1458 UNGCPRO;
1318 1459
1319 if (!NILP (args = XCDR (args))) 1460 if (!NILP (args = XCDR (args)))
1331 1472
1332 LOADHIST_ATTACH (sym); 1473 LOADHIST_ATTACH (sym);
1333 return sym; 1474 return sym;
1334 } 1475 }
1335 1476
1336 DEFUN ("user-variable-p", Fuser_variable_p, 1, 1, 0, /* 1477 /* XEmacs: user-variable-p is in symbols.c, since it needs to mess around
1337 Return t if VARIABLE is intended to be set and modified by users. 1478 with the symbol variable aliases. */
1338 \(The alternative is a variable used internally in a Lisp program.)
1339 Determined by whether the first character of the documentation
1340 for the variable is `*'.
1341 */
1342 (variable))
1343 {
1344 Lisp_Object documentation = Fget (variable, Qvariable_documentation, Qnil);
1345
1346 return
1347 ((INTP (documentation) && XINT (documentation) < 0) ||
1348
1349 (STRINGP (documentation) &&
1350 (string_byte (documentation, 0) == '*')) ||
1351
1352 /* If (STRING . INTEGER), a negative integer means a user variable. */
1353 (CONSP (documentation)
1354 && STRINGP (XCAR (documentation))
1355 && INTP (XCDR (documentation))
1356 && XINT (XCDR (documentation)) < 0)) ?
1357 Qt : Qnil;
1358 }
1359 1479
1360 DEFUN ("macroexpand-internal", Fmacroexpand_internal, 1, 2, 0, /* 1480 DEFUN ("macroexpand-internal", Fmacroexpand_internal, 1, 2, 0, /*
1361 Return result of expanding macros at top level of FORM. 1481 Return result of expanding macros at top level of FORM.
1362 If FORM is not a macro call, it is returned unchanged. 1482 If FORM is not a macro call, it is returned unchanged.
1363 Otherwise, the macro is expanded and the expansion is considered 1483 Otherwise, the macro is expanded and the expansion is considered
1467 } 1587 }
1468 1588
1469 #endif /* ERROR_CHECK_TRAPPING_PROBLEMS */ 1589 #endif /* ERROR_CHECK_TRAPPING_PROBLEMS */
1470 1590
1471 DEFUN ("catch", Fcatch, 1, UNEVALLED, 0, /* 1591 DEFUN ("catch", Fcatch, 1, UNEVALLED, 0, /*
1472 \(catch TAG BODY...): eval BODY allowing nonlocal exits using `throw'. 1592 Eval BODY allowing nonlocal exits using `throw'.
1473 TAG is evalled to get the tag to use. Then the BODY is executed. 1593 TAG is evalled to get the tag to use. Then the BODY is executed.
1474 Within BODY, (throw TAG) with same (`eq') tag exits BODY and this `catch'. 1594 Within BODY, (throw TAG VAL) with same (`eq') tag exits BODY and this `catch'.
1475 If no throw happens, `catch' returns the value of the last BODY form. 1595 If no throw happens, `catch' returns the value of the last BODY form.
1476 If a throw happens, it specifies the value to return from `catch'. 1596 If a throw happens, it specifies the value to return from `catch'.
1597
1598 arguments: (TAG &rest BODY)
1477 */ 1599 */
1478 (args)) 1600 (args))
1479 { 1601 {
1480 /* This function can GC */ 1602 /* This function can GC */
1481 Lisp_Object tag = Feval (XCAR (args)); 1603 Lisp_Object tag = Feval (XCAR (args));
1633 throw_level = 0; 1755 throw_level = 0;
1634 #endif 1756 #endif
1635 LONGJMP (c->jmp, 1); 1757 LONGJMP (c->jmp, 1);
1636 } 1758 }
1637 1759
1638 static DECLARE_DOESNT_RETURN (throw_or_bomb_out (Lisp_Object, Lisp_Object, int, 1760 DECLARE_DOESNT_RETURN (throw_or_bomb_out (Lisp_Object, Lisp_Object, int,
1639 Lisp_Object, Lisp_Object)); 1761 Lisp_Object, Lisp_Object));
1640 1762
1641 static DOESNT_RETURN 1763 DOESNT_RETURN
1642 throw_or_bomb_out (Lisp_Object tag, Lisp_Object val, int bomb_out_p, 1764 throw_or_bomb_out (Lisp_Object tag, Lisp_Object val, int bomb_out_p,
1643 Lisp_Object sig, Lisp_Object data) 1765 Lisp_Object sig, Lisp_Object data)
1644 { 1766 {
1645 #ifdef DEFEND_AGAINST_THROW_RECURSION 1767 #ifdef DEFEND_AGAINST_THROW_RECURSION
1646 /* die if we recurse more than is reasonable */ 1768 /* die if we recurse more than is reasonable */
1709 that is EQ() to TAG. When it finds it, it will longjmp() 1831 that is EQ() to TAG. When it finds it, it will longjmp()
1710 back to the place that established the catch (in this case, 1832 back to the place that established the catch (in this case,
1711 condition_case_1). See below for more info. 1833 condition_case_1). See below for more info.
1712 */ 1834 */
1713 1835
1714 DEFUN_NORETURN ("throw", Fthrow, 2, 2, 0, /* 1836 DEFUN_NORETURN ("throw", Fthrow, 2, UNEVALLED, 0, /*
1715 Throw to the catch for TAG and return VALUE from it. 1837 Throw to the catch for TAG and return VALUE from it.
1716 Both TAG and VALUE are evalled. Tags are the same iff they are `eq'. 1838
1839 Both TAG and VALUE are evalled, and multiple values in VALUE will be passed
1840 back. Tags are the same if and only if they are `eq'.
1841
1842 arguments: (TAG VALUE)
1717 */ 1843 */
1718 (tag, value)) 1844 (args))
1719 { 1845 {
1846 int nargs;
1847 Lisp_Object tag, value;
1848
1849 GET_LIST_LENGTH (args, nargs);
1850 if (nargs != 2)
1851 {
1852 Fsignal (Qwrong_number_of_arguments, list2 (Qthrow, make_int (nargs)));
1853 }
1854
1855 tag = IGNORE_MULTIPLE_VALUES (Feval (XCAR(args)));
1856
1857 value = Feval (XCAR (XCDR (args)));
1858
1720 throw_or_bomb_out (tag, value, 0, Qnil, Qnil); /* Doesn't return */ 1859 throw_or_bomb_out (tag, value, 0, Qnil, Qnil); /* Doesn't return */
1721 RETURN_NOT_REACHED (Qnil); 1860 RETURN_NOT_REACHED (Qnil);
1722 } 1861 }
1723 1862
1724 DEFUN ("unwind-protect", Funwind_protect, 1, UNEVALLED, 0, /* 1863 DEFUN ("unwind-protect", Funwind_protect, 1, UNEVALLED, 0, /*
1725 Do BODYFORM, protecting with UNWINDFORMS. 1864 Do BODYFORM, protecting with UNWINDFORMS.
1726 Usage looks like (unwind-protect BODYFORM UNWINDFORMS...).
1727 If BODYFORM completes normally, its value is returned 1865 If BODYFORM completes normally, its value is returned
1728 after executing the UNWINDFORMS. 1866 after executing the UNWINDFORMS.
1729 If BODYFORM exits nonlocally, the UNWINDFORMS are executed anyway. 1867 If BODYFORM exits nonlocally, the UNWINDFORMS are executed anyway.
1868
1869 arguments: (BODYFORM &rest UNWINDFORMS)
1730 */ 1870 */
1731 (args)) 1871 (args))
1732 { 1872 {
1733 /* This function can GC */ 1873 /* This function can GC */
1734 int speccount = specpdl_depth(); 1874 int speccount = specpdl_depth();
2063 Lisp_Object handlers = XCDR (XCDR (args)); 2203 Lisp_Object handlers = XCDR (XCDR (args));
2064 return condition_case_3 (bodyform, var, handlers); 2204 return condition_case_3 (bodyform, var, handlers);
2065 } 2205 }
2066 2206
2067 DEFUN ("call-with-condition-handler", Fcall_with_condition_handler, 2, MANY, 0, /* 2207 DEFUN ("call-with-condition-handler", Fcall_with_condition_handler, 2, MANY, 0, /*
2068 Regain control when an error is signalled, without popping the stack. 2208 Call FUNCTION with arguments ARGS, regaining control on error.
2069 Usage looks like (call-with-condition-handler HANDLER FUNCTION &rest ARGS). 2209
2070 This function is similar to `condition-case', but the handler is invoked 2210 This function is similar to `condition-case', but HANDLER is invoked
2071 with the same environment (Lisp stack, bindings, catches, condition-cases) 2211 with the same environment (Lisp stack, bindings, catches, condition-cases)
2072 that was current when `signal' was called, rather than when the handler 2212 that was current when `signal' was called, rather than when the handler
2073 was established. 2213 was established.
2074 2214
2075 HANDLER should be a function of one argument, which is a cons of the args 2215 HANDLER should be a function of one argument, which is a cons of the args
2077 `signal' is called (this differs from `condition-case', which allows 2217 `signal' is called (this differs from `condition-case', which allows
2078 you to specify which errors are trapped). If the handler function 2218 you to specify which errors are trapped). If the handler function
2079 returns, `signal' continues as if the handler were never invoked. 2219 returns, `signal' continues as if the handler were never invoked.
2080 \(It continues to look for handlers established earlier than this one, 2220 \(It continues to look for handlers established earlier than this one,
2081 and invokes the standard error-handler if none is found.) 2221 and invokes the standard error-handler if none is found.)
2222
2223 arguments: (HANDLER FUNCTION &rest ARGS)
2082 */ 2224 */
2083 (int nargs, Lisp_Object *args)) /* Note! Args side-effected! */ 2225 (int nargs, Lisp_Object *args)) /* Note! Args side-effected! */
2084 { 2226 {
2085 /* This function can GC */ 2227 /* This function can GC */
2086 int speccount = specpdl_depth(); 2228 int speccount = specpdl_depth();
2235 just to bomb out immediately. */ 2377 just to bomb out immediately. */
2236 stderr_out ("Error before initialization is complete!\n"); 2378 stderr_out ("Error before initialization is complete!\n");
2237 ABORT (); 2379 ABORT ();
2238 } 2380 }
2239 2381
2382 #ifndef NEW_GC
2240 assert (!gc_in_progress); 2383 assert (!gc_in_progress);
2384 #endif /* not NEW_GC */
2241 2385
2242 /* We abort if in_display and we are not protected, as garbage 2386 /* We abort if in_display and we are not protected, as garbage
2243 collections and non-local exits will invariably be fatal, but in 2387 collections and non-local exits will invariably be fatal, but in
2244 messy, difficult-to-debug ways. See enter_redisplay_critical_section(). 2388 messy, difficult-to-debug ways. See enter_redisplay_critical_section().
2245 */ 2389 */
2328 /* t is used by handlers for all conditions, set up by C code. 2472 /* t is used by handlers for all conditions, set up by C code.
2329 * debugger is not called even if debug_on_error */ 2473 * debugger is not called even if debug_on_error */
2330 else if (EQ (handler_data, Qt)) 2474 else if (EQ (handler_data, Qt))
2331 { 2475 {
2332 UNGCPRO; 2476 UNGCPRO;
2333 return Fthrow (handlers, Fcons (error_symbol, data)); 2477 throw_or_bomb_out (handlers, Fcons (error_symbol, data),
2478 0, Qnil, Qnil);
2334 } 2479 }
2335 /* `error' is used similarly to the way `t' is used, but in 2480 /* `error' is used similarly to the way `t' is used, but in
2336 addition it invokes the debugger if debug_on_error. 2481 addition it invokes the debugger if debug_on_error.
2337 This is normally used for the outer command-loop error 2482 This is normally used for the outer command-loop error
2338 handler. */ 2483 handler. */
2347 UNGCPRO; 2492 UNGCPRO;
2348 if (!UNBOUNDP (tem)) 2493 if (!UNBOUNDP (tem))
2349 return return_from_signal (tem); 2494 return return_from_signal (tem);
2350 2495
2351 tem = Fcons (error_symbol, data); 2496 tem = Fcons (error_symbol, data);
2352 return Fthrow (handlers, tem); 2497 throw_or_bomb_out (handlers, tem, 0, Qnil, Qnil);
2353 } 2498 }
2354 else 2499 else
2355 { 2500 {
2356 /* handler established by real (Lisp) condition-case */ 2501 /* handler established by real (Lisp) condition-case */
2357 Lisp_Object h; 2502 Lisp_Object h;
2371 if (!UNBOUNDP (tem)) 2516 if (!UNBOUNDP (tem))
2372 return return_from_signal (tem); 2517 return return_from_signal (tem);
2373 2518
2374 /* Doesn't return */ 2519 /* Doesn't return */
2375 tem = Fcons (Fcons (error_symbol, data), Fcdr (clause)); 2520 tem = Fcons (Fcons (error_symbol, data), Fcdr (clause));
2376 return Fthrow (handlers, tem); 2521 throw_or_bomb_out (handlers, tem, 0, Qnil, Qnil);
2377 } 2522 }
2378 } 2523 }
2379 } 2524 }
2380 } 2525 }
2381 2526
3073 (cmd, record_flag, keys)) 3218 (cmd, record_flag, keys))
3074 { 3219 {
3075 /* This function can GC */ 3220 /* This function can GC */
3076 Lisp_Object prefixarg; 3221 Lisp_Object prefixarg;
3077 Lisp_Object final = cmd; 3222 Lisp_Object final = cmd;
3078 struct backtrace backtrace; 3223 PROFILE_DECLARE();
3079 struct console *con = XCONSOLE (Vselected_console); 3224 struct console *con = XCONSOLE (Vselected_console);
3080 3225
3081 prefixarg = con->prefix_arg; 3226 prefixarg = con->prefix_arg;
3082 con->prefix_arg = Qnil; 3227 con->prefix_arg = Qnil;
3083 Vcurrent_prefix_arg = prefixarg; 3228 Vcurrent_prefix_arg = prefixarg;
3368 REGISTER int i = 0; 3513 REGISTER int i = 0;
3369 int max_non_rest_args = f->args_in_array - 1; 3514 int max_non_rest_args = f->args_in_array - 1;
3370 int bindargs = min (nargs, max_non_rest_args); 3515 int bindargs = min (nargs, max_non_rest_args);
3371 3516
3372 for (i = 0; i < bindargs; i++) 3517 for (i = 0; i < bindargs; i++)
3518 #ifdef NEW_GC
3519 SPECBIND_FAST_UNSAFE (XCOMPILED_FUNCTION_ARGS_DATA (f->arguments)[i],
3520 args[i]);
3521 #else /* not NEW_GC */
3373 SPECBIND_FAST_UNSAFE (f->args[i], args[i]); 3522 SPECBIND_FAST_UNSAFE (f->args[i], args[i]);
3523 #endif /* not NEW_GC */
3374 for (i = bindargs; i < max_non_rest_args; i++) 3524 for (i = bindargs; i < max_non_rest_args; i++)
3525 #ifdef NEW_GC
3526 SPECBIND_FAST_UNSAFE (XCOMPILED_FUNCTION_ARGS_DATA (f->arguments)[i],
3527 Qnil);
3528 #else /* not NEW_GC */
3375 SPECBIND_FAST_UNSAFE (f->args[i], Qnil); 3529 SPECBIND_FAST_UNSAFE (f->args[i], Qnil);
3530 #endif /* not NEW_GC */
3531 #ifdef NEW_GC
3532 SPECBIND_FAST_UNSAFE
3533 (XCOMPILED_FUNCTION_ARGS_DATA (f->arguments)[max_non_rest_args],
3534 nargs > max_non_rest_args ?
3535 Flist (nargs - max_non_rest_args, &args[max_non_rest_args]) :
3536 Qnil);
3537 #else /* not NEW_GC */
3376 SPECBIND_FAST_UNSAFE 3538 SPECBIND_FAST_UNSAFE
3377 (f->args[max_non_rest_args], 3539 (f->args[max_non_rest_args],
3378 nargs > max_non_rest_args ? 3540 nargs > max_non_rest_args ?
3379 Flist (nargs - max_non_rest_args, &args[max_non_rest_args]) : 3541 Flist (nargs - max_non_rest_args, &args[max_non_rest_args]) :
3380 Qnil); 3542 Qnil);
3543 #endif /* not NEW_GC */
3381 } 3544 }
3382 3545
3383 /* Apply compiled-function object FUN to the NARGS evaluated arguments 3546 /* Apply compiled-function object FUN to the NARGS evaluated arguments
3384 in ARGS, and return the result of evaluation. */ 3547 in ARGS, and return the result of evaluation. */
3385 inline static Lisp_Object 3548 inline static Lisp_Object
3402 if (nargs == f->max_args) /* Optimize for the common case -- no unspecified 3565 if (nargs == f->max_args) /* Optimize for the common case -- no unspecified
3403 optional arguments. */ 3566 optional arguments. */
3404 { 3567 {
3405 #if 1 3568 #if 1
3406 for (i = 0; i < nargs; i++) 3569 for (i = 0; i < nargs; i++)
3570 #ifdef NEW_GC
3571 SPECBIND_FAST_UNSAFE (XCOMPILED_FUNCTION_ARGS_DATA (f->arguments)[i],
3572 args[i]);
3573 #else /* not NEW_GC */
3407 SPECBIND_FAST_UNSAFE (f->args[i], args[i]); 3574 SPECBIND_FAST_UNSAFE (f->args[i], args[i]);
3575 #endif /* not NEW_GC */
3408 #else 3576 #else
3409 /* Here's an alternate way to write the loop that tries to further 3577 /* Here's an alternate way to write the loop that tries to further
3410 optimize funcalls for functions with few arguments by partially 3578 optimize funcalls for functions with few arguments by partially
3411 unrolling the loop. It's not clear whether this is a win since it 3579 unrolling the loop. It's not clear whether this is a win since it
3412 increases the size of the function and the possibility of L1 cache 3580 increases the size of the function and the possibility of L1 cache
3433 else if (nargs < f->min_args) 3601 else if (nargs < f->min_args)
3434 goto wrong_number_of_arguments; 3602 goto wrong_number_of_arguments;
3435 else if (nargs < f->max_args) 3603 else if (nargs < f->max_args)
3436 { 3604 {
3437 for (i = 0; i < nargs; i++) 3605 for (i = 0; i < nargs; i++)
3606 #ifdef NEW_GC
3607 SPECBIND_FAST_UNSAFE (XCOMPILED_FUNCTION_ARGS_DATA (f->arguments)[i],
3608 args[i]);
3609 #else /* not NEW_GC */
3438 SPECBIND_FAST_UNSAFE (f->args[i], args[i]); 3610 SPECBIND_FAST_UNSAFE (f->args[i], args[i]);
3611 #endif /* not NEW_GC */
3439 for (i = nargs; i < f->max_args; i++) 3612 for (i = nargs; i < f->max_args; i++)
3613 #ifdef NEW_GC
3614 SPECBIND_FAST_UNSAFE (XCOMPILED_FUNCTION_ARGS_DATA (f->arguments)[i],
3615 Qnil);
3616 #else /* not NEW_GC */
3440 SPECBIND_FAST_UNSAFE (f->args[i], Qnil); 3617 SPECBIND_FAST_UNSAFE (f->args[i], Qnil);
3618 #endif /* not NEW_GC */
3441 } 3619 }
3442 else if (f->max_args == MANY) 3620 else if (f->max_args == MANY)
3443 handle_compiled_function_with_and_rest (f, nargs, args); 3621 handle_compiled_function_with_and_rest (f, nargs, args);
3444 else 3622 else
3445 { 3623 {
3473 (form)) 3651 (form))
3474 { 3652 {
3475 /* This function can GC */ 3653 /* This function can GC */
3476 Lisp_Object fun, val, original_fun, original_args; 3654 Lisp_Object fun, val, original_fun, original_args;
3477 int nargs; 3655 int nargs;
3478 struct backtrace backtrace; 3656 PROFILE_DECLARE();
3479 3657
3480 #ifdef ERROR_CHECK_TRAPPING_PROBLEMS 3658 #ifdef ERROR_CHECK_TRAPPING_PROBLEMS
3481 check_proper_critical_section_lisp_protection (); 3659 check_proper_critical_section_lisp_protection ();
3482 #endif 3660 #endif
3661
3662 if (!CONSP (form))
3663 {
3664 if (SYMBOLP (form))
3665 {
3666 return Fsymbol_value (form);
3667 }
3668
3669 return form;
3670 }
3483 3671
3484 /* I think this is a pretty safe place to call Lisp code, don't you? */ 3672 /* I think this is a pretty safe place to call Lisp code, don't you? */
3485 while (!in_warnings && !NILP (Vpending_warnings) 3673 while (!in_warnings && !NILP (Vpending_warnings)
3486 /* well, perhaps not so safe after all! */ 3674 /* well, perhaps not so safe after all! */
3487 && !(inhibit_flags & INHIBIT_ANY_CHANGE_AFFECTING_REDISPLAY)) 3675 && !(inhibit_flags & INHIBIT_ANY_CHANGE_AFFECTING_REDISPLAY))
3511 call3 (Qdisplay_warning, class_, messij, level); 3699 call3 (Qdisplay_warning, class_, messij, level);
3512 UNGCPRO; 3700 UNGCPRO;
3513 unbind_to (speccount); 3701 unbind_to (speccount);
3514 } 3702 }
3515 3703
3516 if (!CONSP (form))
3517 {
3518 if (SYMBOLP (form))
3519 return Fsymbol_value (form);
3520 else
3521 return form;
3522 }
3523
3524 QUIT; 3704 QUIT;
3525 if (need_to_garbage_collect) 3705 if (need_to_garbage_collect)
3526 { 3706 {
3527 struct gcpro gcpro1; 3707 struct gcpro gcpro1;
3528 GCPRO1 (form); 3708 GCPRO1 (form);
3709 #ifdef NEW_GC
3710 gc_incremental ();
3711 #else /* not NEW_GC */
3529 garbage_collect_1 (); 3712 garbage_collect_1 ();
3713 #endif /* not NEW_GC */
3530 UNGCPRO; 3714 UNGCPRO;
3531 } 3715 }
3532 3716
3533 if (++lisp_eval_depth > max_lisp_eval_depth) 3717 if (++lisp_eval_depth > max_lisp_eval_depth)
3534 { 3718 {
3558 do_debug_on_call (Qt); 3742 do_debug_on_call (Qt);
3559 3743
3560 /* At this point, only original_fun and original_args 3744 /* At this point, only original_fun and original_args
3561 have values that will be used below. */ 3745 have values that will be used below. */
3562 retry: 3746 retry:
3563 fun = indirect_function (original_fun, 1); 3747 /* Optimise for no indirection. */
3748 fun = original_fun;
3749 if (SYMBOLP (fun) && !EQ (fun, Qunbound)
3750 && (fun = XSYMBOL (fun)->function, SYMBOLP (fun)))
3751 {
3752 fun = indirect_function(original_fun, 1);
3753 }
3564 3754
3565 if (SUBRP (fun)) 3755 if (SUBRP (fun))
3566 { 3756 {
3567 Lisp_Subr *subr = XSUBR (fun); 3757 Lisp_Subr *subr = XSUBR (fun);
3568 int max_args = subr->max_args; 3758 int max_args = subr->max_args;
3588 gcpro1.nvars = 0; 3778 gcpro1.nvars = 0;
3589 3779
3590 { 3780 {
3591 LIST_LOOP_2 (arg, original_args) 3781 LIST_LOOP_2 (arg, original_args)
3592 { 3782 {
3593 *p++ = Feval (arg); 3783 *p++ = IGNORE_MULTIPLE_VALUES (Feval (arg));
3594 gcpro1.nvars++; 3784 gcpro1.nvars++;
3595 } 3785 }
3596 } 3786 }
3597 3787
3598 /* &optional args default to nil. */ 3788 /* &optional args default to nil. */
3619 gcpro1.nvars = 0; 3809 gcpro1.nvars = 0;
3620 3810
3621 { 3811 {
3622 LIST_LOOP_2 (arg, original_args) 3812 LIST_LOOP_2 (arg, original_args)
3623 { 3813 {
3624 *p++ = Feval (arg); 3814 *p++ = IGNORE_MULTIPLE_VALUES (Feval (arg));
3625 gcpro1.nvars++; 3815 gcpro1.nvars++;
3626 } 3816 }
3627 } 3817 }
3628 3818
3629 backtrace.args = args; 3819 backtrace.args = args;
3652 gcpro1.nvars = 0; 3842 gcpro1.nvars = 0;
3653 3843
3654 { 3844 {
3655 LIST_LOOP_2 (arg, original_args) 3845 LIST_LOOP_2 (arg, original_args)
3656 { 3846 {
3657 *p++ = Feval (arg); 3847 *p++ = IGNORE_MULTIPLE_VALUES (Feval (arg));
3658 gcpro1.nvars++; 3848 gcpro1.nvars++;
3659 } 3849 }
3660 } 3850 }
3661 3851
3662 backtrace.args = args; 3852 backtrace.args = args;
3701 gcpro1.nvars = 0; 3891 gcpro1.nvars = 0;
3702 3892
3703 { 3893 {
3704 LIST_LOOP_2 (arg, original_args) 3894 LIST_LOOP_2 (arg, original_args)
3705 { 3895 {
3706 *p++ = Feval (arg); 3896 *p++ = IGNORE_MULTIPLE_VALUES (Feval (arg));
3707 gcpro1.nvars++; 3897 gcpro1.nvars++;
3708 } 3898 }
3709 } 3899 }
3710 3900
3711 UNGCPRO; 3901 UNGCPRO;
3727 else 3917 else
3728 { 3918 {
3729 goto invalid_function; 3919 goto invalid_function;
3730 } 3920 }
3731 } 3921 }
3732 else /* ! (SUBRP (fun) || COMPILED_FUNCTIONP (fun) || CONSP (fun)) */ 3922 else if (UNBOUNDP (fun))
3923 {
3924 val = signal_void_function_error (original_fun);
3925 }
3926 else /* ! (SUBRP (fun) || COMPILED_FUNCTIONP (fun) || CONSP (fun)
3927 UNBOUNDP (fun)) */
3733 { 3928 {
3734 invalid_function: 3929 invalid_function:
3735 val = signal_invalid_function_error (fun); 3930 val = signal_invalid_function_error (fun);
3736 } 3931 }
3737 3932
3756 (Qgarbage_collecting, 2, args, RUN_HOOKS_TO_COMPLETION, 3951 (Qgarbage_collecting, 2, args, RUN_HOOKS_TO_COMPLETION,
3757 INHIBIT_QUIT | NO_INHIBIT_ERRORS); 3952 INHIBIT_QUIT | NO_INHIBIT_ERRORS);
3758 } 3953 }
3759 3954
3760 DEFUN ("funcall", Ffuncall, 1, MANY, 0, /* 3955 DEFUN ("funcall", Ffuncall, 1, MANY, 0, /*
3761 Call first argument as a function, passing the remaining arguments to it. 3956 Call FUNCTION as a function, passing the remaining arguments to it.
3762 Thus, (funcall 'cons 'x 'y) returns (x . y). 3957 Thus, (funcall 'cons 'x 'y) returns (x . y).
3958
3959 arguments: (FUNCTION &rest ARGS)
3763 */ 3960 */
3764 (int nargs, Lisp_Object *args)) 3961 (int nargs, Lisp_Object *args))
3765 { 3962 {
3766 /* This function can GC */ 3963 /* This function can GC */
3767 Lisp_Object fun; 3964 Lisp_Object fun;
3768 Lisp_Object val; 3965 Lisp_Object val;
3769 struct backtrace backtrace; 3966 PROFILE_DECLARE();
3770 int fun_nargs = nargs - 1; 3967 int fun_nargs = nargs - 1;
3771 Lisp_Object *fun_args = args + 1; 3968 Lisp_Object *fun_args = args + 1;
3772 3969
3773 /* QUIT will check for proper redisplay wrapping */ 3970 /* QUIT will check for proper redisplay wrapping */
3774 3971
3776 3973
3777 if (funcall_allocation_flag) 3974 if (funcall_allocation_flag)
3778 { 3975 {
3779 if (need_to_garbage_collect) 3976 if (need_to_garbage_collect)
3780 /* Callers should gcpro lexpr args */ 3977 /* Callers should gcpro lexpr args */
3978 #ifdef NEW_GC
3979 gc_incremental ();
3980 #else /* not NEW_GC */
3781 garbage_collect_1 (); 3981 garbage_collect_1 ();
3982 #endif /* not NEW_GC */
3782 if (need_to_check_c_alloca) 3983 if (need_to_check_c_alloca)
3783 { 3984 {
3784 if (++funcall_alloca_count >= MAX_FUNCALLS_BETWEEN_ALLOCA_CLEANUP) 3985 if (++funcall_alloca_count >= MAX_FUNCALLS_BETWEEN_ALLOCA_CLEANUP)
3785 { 3986 {
3786 xemacs_c_alloca (0); 3987 xemacs_c_alloca (0);
3789 } 3990 }
3790 if (need_to_signal_post_gc) 3991 if (need_to_signal_post_gc)
3791 { 3992 {
3792 need_to_signal_post_gc = 0; 3993 need_to_signal_post_gc = 0;
3793 recompute_funcall_allocation_flag (); 3994 recompute_funcall_allocation_flag ();
3995 #ifdef NEW_GC
3996 run_finalizers ();
3997 #endif /* NEW_GC */
3794 run_post_gc_hook (); 3998 run_post_gc_hook ();
3795 } 3999 }
3796 } 4000 }
3797 4001
3798 if (++lisp_eval_depth > max_lisp_eval_depth) 4002 if (++lisp_eval_depth > max_lisp_eval_depth)
3869 val = SUBR_FUNCTION (subr, MANY) (fun_nargs, fun_args); 4073 val = SUBR_FUNCTION (subr, MANY) (fun_nargs, fun_args);
3870 PROFILE_EXIT_FUNCTION (); 4074 PROFILE_EXIT_FUNCTION ();
3871 } 4075 }
3872 else if (max_args == UNEVALLED) /* Can't funcall a special form */ 4076 else if (max_args == UNEVALLED) /* Can't funcall a special form */
3873 { 4077 {
4078 /* Ugh, ugh, ugh. */
4079 if (EQ (fun, XSYMBOL_FUNCTION (Qthrow)))
4080 {
4081 args[0] = Qobsolete_throw;
4082 goto retry;
4083 }
3874 goto invalid_function; 4084 goto invalid_function;
3875 } 4085 }
3876 else 4086 else
3877 { 4087 {
3878 wrong_number_of_arguments: 4088 wrong_number_of_arguments:
4070 4280
4071 4281
4072 DEFUN ("apply", Fapply, 2, MANY, 0, /* 4282 DEFUN ("apply", Fapply, 2, MANY, 0, /*
4073 Call FUNCTION with the remaining args, using the last arg as a list of args. 4283 Call FUNCTION with the remaining args, using the last arg as a list of args.
4074 Thus, (apply '+ 1 2 '(3 4)) returns 10. 4284 Thus, (apply '+ 1 2 '(3 4)) returns 10.
4285
4286 arguments: (FUNCTION &rest ARGS)
4075 */ 4287 */
4076 (int nargs, Lisp_Object *args)) 4288 (int nargs, Lisp_Object *args))
4077 { 4289 {
4078 /* This function can GC */ 4290 /* This function can GC */
4079 Lisp_Object fun = args[0]; 4291 Lisp_Object fun = args[0];
4149 4361
4150 RETURN_UNGCPRO (Ffuncall (funcall_nargs, funcall_args)); 4362 RETURN_UNGCPRO (Ffuncall (funcall_nargs, funcall_args));
4151 } 4363 }
4152 } 4364 }
4153 4365
4154
4155 /* Apply lambda list FUN to the NARGS evaluated arguments in ARGS and 4366 /* Apply lambda list FUN to the NARGS evaluated arguments in ARGS and
4156 return the result of evaluation. */ 4367 return the result of evaluation. */
4157 4368
4158 static Lisp_Object 4369 static Lisp_Object
4159 funcall_lambda (Lisp_Object fun, int nargs, Lisp_Object args[]) 4370 funcall_lambda (Lisp_Object fun, int nargs, Lisp_Object args[])
4207 invalid_function: 4418 invalid_function:
4208 return signal_invalid_function_error (fun); 4419 return signal_invalid_function_error (fun);
4209 } 4420 }
4210 4421
4211 4422
4423 /* Multiple values.
4424
4425 A multiple value object is returned by #'values if:
4426
4427 -- The number of arguments to #'values is not one, and:
4428 -- Some special form in the call stack is prepared to handle more than
4429 one multiple value.
4430
4431 The return value of #'values-list is analogous to that of #'values.
4432
4433 Henry Baker, in https://eprints.kfupm.edu.sa/31898/1/31898.pdf ("CONS
4434 Should not CONS its Arguments, or, a Lazy Alloc is a Smart Alloc", ACM
4435 Sigplan Notices 27,3 (March 1992),24-34.) says it should be possible to
4436 allocate Common Lisp multiple-value objects on the stack, but this
4437 assumes that variable-length records can be allocated on the stack,
4438 something not true for us. As far as I can tell, it also ignores the
4439 contexts where multiple-values need to be thrown, or maybe it thinks such
4440 objects should be converted to heap allocation at that point.
4441
4442 The specific multiple values saved and returned depend on how many
4443 multiple-values special forms in the stack are interested in; for
4444 example, if #'multiple-value-call is somewhere in the call stack, all
4445 values passed to #'values will be saved and returned. If an expansion of
4446 #'multiple-value-setq with 10 SYMS is the only part of the call stack
4447 interested in multiple values, then a maximum of ten multiple values will
4448 be saved and returned.
4449
4450 (#'throw passes back multiple values in its VALUE argument; this is why
4451 we can't just take the details of the most immediate
4452 #'multiple-value-{whatever} call to work out which values to save, we
4453 need to look at the whole stack, or, equivalently, the dynamic variables
4454 we set to reflect the whole stack.)
4455
4456 The first value passed to #'values will always be saved, since that is
4457 needed to convert a multiple value object into a single value object,
4458 something that is normally necessary independent of how many functions in
4459 the call stack are interested in multiple values.
4460
4461 However many values (for values of "however many" that are not one) are
4462 saved and restored, the multiple value object knows how many arguments it
4463 would contain were none to have been discarded, and will indicate this
4464 on being printed from within GDB.
4465
4466 In lisp-interaction-mode, no multiple values should be discarded (unless
4467 they need to be for the sake of the correctness of the program);
4468 #'eval-interactive-with-multiple-value-list in lisp-mode.el wraps its
4469 #'eval calls with #'multiple-value-list calls to avoid this. This means
4470 that there is a small performance and memory penalty for code evaluated
4471 in *scratch*; use M-: EXPRESSION RET if you really need to avoid
4472 this. Lisp code execution that is not ultimately from hitting C-j in
4473 *scratch*--that is, the vast vast majority of Lisp code execution--does
4474 not have this penalty.
4475
4476 Probably the most important aspect of multiple values is stated with
4477 admirable clarity by CLTL2:
4478
4479 "No matter how many values a form produces, if the form is an argument
4480 form in a function call, then exactly one value (the first one) is
4481 used."
4482
4483 This means that most contexts, most of the time, will never see multiple
4484 values. There are important exceptions; search the web for that text in
4485 quotation marks and read the related chapter. This code handles all of
4486 them, to my knowledge. Aidan Kehoe, Mon Mar 16 00:17:39 GMT 2009. */
4487
4488 static Lisp_Object
4489 make_multiple_value (Lisp_Object first_value, Elemcount count,
4490 Elemcount first_desired, Elemcount upper_limit)
4491 {
4492 Bytecount sizem;
4493 struct multiple_value *mv;
4494 Elemcount i, allocated_count;
4495 Lisp_Object mvobj;
4496
4497 assert (count != 1);
4498
4499 if (1 != upper_limit && (0 == first_desired))
4500 {
4501 /* We always allocate element zero, and that's taken into account when
4502 working out allocated_count: */
4503 first_desired = 1;
4504 }
4505
4506 if (first_desired >= count)
4507 {
4508 /* We can't pass anything back that our caller is interested in. Only
4509 allocate for the first argument. */
4510 allocated_count = 1;
4511 }
4512 else
4513 {
4514 allocated_count = 1 + ((upper_limit > count ? count : upper_limit)
4515 - first_desired);
4516 }
4517
4518 sizem = FLEXIBLE_ARRAY_STRUCT_SIZEOF (multiple_value,
4519 Lisp_Object,
4520 contents, allocated_count);
4521 mvobj = ALLOC_SIZED_LISP_OBJECT (sizem, multiple_value);
4522 mv = XMULTIPLE_VALUE (mvobj);
4523
4524 mv->count = count;
4525 mv->first_desired = first_desired;
4526 mv->allocated_count = allocated_count;
4527 mv->contents[0] = first_value;
4528
4529 for (i = first_desired; i < upper_limit && i < count; ++i)
4530 {
4531 mv->contents[1 + (i - first_desired)] = Qunbound;
4532 }
4533
4534 return mvobj;
4535 }
4536
4537 void
4538 multiple_value_aset (Lisp_Object obj, Elemcount index, Lisp_Object value)
4539 {
4540 struct multiple_value *mv = XMULTIPLE_VALUE (obj);
4541 Elemcount first_desired = mv->first_desired;
4542 Elemcount allocated_count = mv->allocated_count;
4543
4544 if (index != 0 &&
4545 (index < first_desired || index >= (first_desired + allocated_count)))
4546 {
4547 args_out_of_range (make_int (first_desired),
4548 make_int (first_desired + allocated_count));
4549 }
4550
4551 mv->contents[index == 0 ? 0 : 1 + (index - first_desired)] = value;
4552 }
4553
4554 Lisp_Object
4555 multiple_value_aref (Lisp_Object obj, Elemcount index)
4556 {
4557 struct multiple_value *mv = XMULTIPLE_VALUE (obj);
4558 Elemcount first_desired = mv->first_desired;
4559 Elemcount allocated_count = mv->allocated_count;
4560
4561 if (index != 0 &&
4562 (index < first_desired || index >= (first_desired + allocated_count)))
4563 {
4564 args_out_of_range (make_int (first_desired),
4565 make_int (first_desired + allocated_count));
4566 }
4567
4568 return mv->contents[index == 0 ? 0 : 1 + (index - first_desired)];
4569 }
4570
4571 static void
4572 print_multiple_value (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
4573 {
4574 struct multiple_value *mv = XMULTIPLE_VALUE (obj);
4575 Elemcount first_desired = mv->first_desired;
4576 Elemcount allocated_count = mv->allocated_count;
4577 Elemcount count = mv->count, index;
4578
4579 if (print_readably)
4580 {
4581 printing_unreadable_object ("multiple values");
4582 }
4583
4584 if (0 == count)
4585 {
4586 write_c_string (printcharfun, "#<zero-length multiple value>");
4587 }
4588
4589 for (index = 0; index < count;)
4590 {
4591 if (index != 0 &&
4592 (index < first_desired ||
4593 index >= (first_desired + (allocated_count - 1))))
4594 {
4595 write_fmt_string (printcharfun, "#<discarded-multiple-value %d>",
4596 index);
4597 }
4598 else
4599 {
4600 print_internal (multiple_value_aref (obj, index),
4601 printcharfun, escapeflag);
4602 }
4603
4604 ++index;
4605
4606 if (count > 1 && index < count)
4607 {
4608 write_c_string (printcharfun, " ;\n");
4609 }
4610 }
4611 }
4612
4613 static Lisp_Object
4614 mark_multiple_value (Lisp_Object obj)
4615 {
4616 struct multiple_value *mv = XMULTIPLE_VALUE (obj);
4617 Elemcount index, allocated_count = mv->allocated_count;
4618
4619 for (index = 0; index < allocated_count; ++index)
4620 {
4621 mark_object (mv->contents[index]);
4622 }
4623
4624 return Qnil;
4625 }
4626
4627 static Bytecount
4628 size_multiple_value (const void *lheader)
4629 {
4630 return FLEXIBLE_ARRAY_STRUCT_SIZEOF (struct multiple_value,
4631 Lisp_Object, contents,
4632 ((struct multiple_value *) lheader)->
4633 allocated_count);
4634 }
4635
4636 static const struct memory_description multiple_value_description[] = {
4637 { XD_LONG, offsetof (struct multiple_value, count) },
4638 { XD_ELEMCOUNT, offsetof (struct multiple_value, allocated_count) },
4639 { XD_LONG, offsetof (struct multiple_value, first_desired) },
4640 { XD_LISP_OBJECT_ARRAY, offsetof (struct multiple_value, contents),
4641 XD_INDIRECT (1, 0) },
4642 { XD_END }
4643 };
4644
4645 DEFINE_DUMPABLE_SIZABLE_LISP_OBJECT ("multiple-value", multiple_value,
4646 mark_multiple_value,
4647 print_multiple_value, 0,
4648 0, /* No equal method. */
4649 0, /* No hash method. */
4650 multiple_value_description,
4651 size_multiple_value,
4652 struct multiple_value);
4653
4654 /* Given that FIRST and UPPER are the inclusive lower and exclusive upper
4655 bounds for the multiple values we're interested in, modify (or don't) the
4656 special variables used to indicate this to #'values and #'values-list.
4657 Returns the specpdl_depth() value before any modification. */
4658 int
4659 bind_multiple_value_limits (int first, int upper)
4660 {
4661 int result = specpdl_depth();
4662
4663 if (!(upper > first))
4664 {
4665 invalid_argument ("MULTIPLE-VALUE-UPPER-LIMIT must be greater than "
4666 " FIRST-DESIRED-MULTIPLE-VALUE", Qunbound);
4667 }
4668
4669 if (upper > Vmultiple_values_limit)
4670 {
4671 args_out_of_range (make_int (upper), make_int (Vmultiple_values_limit));
4672 }
4673
4674 /* In the event that something back up the stack wants more multiple
4675 values than we do, we need to keep its figures for
4676 first_desired_multiple_value or multiple_value_current_limit both. It
4677 may be that the form will throw past us.
4678
4679 If first_desired_multiple_value is zero, this means it hasn't ever been
4680 bound, and any value we have for first is appropriate to use.
4681
4682 Zeroth element is always saved, no need to note that: */
4683 if (0 == first)
4684 {
4685 first = 1;
4686 }
4687
4688 if (0 == first_desired_multiple_value
4689 || first < first_desired_multiple_value)
4690 {
4691 internal_bind_int (&first_desired_multiple_value, first);
4692 }
4693
4694 if (upper > multiple_value_current_limit)
4695 {
4696 internal_bind_int (&multiple_value_current_limit, upper);
4697 }
4698
4699 return result;
4700 }
4701
4702 Lisp_Object
4703 multiple_value_call (int nargs, Lisp_Object *args)
4704 {
4705 /* The argument order here is horrible: */
4706 int i, speccount = XINT (args[3]);
4707 Lisp_Object result = Qnil, head = Fcons (args[0], Qnil), list_offset;
4708 struct gcpro gcpro1, gcpro2;
4709 Lisp_Object apply_args[2];
4710
4711 GCPRO2 (head, result);
4712 list_offset = head;
4713
4714 assert (!(MULTIPLE_VALUEP (args[0])));
4715 CHECK_FUNCTION (args[0]);
4716
4717 /* Start at 4, to ignore the function, the speccount, and the arguments to
4718 multiple-values-limit (which we don't discard because
4719 #'multiple-value-list-internal needs them): */
4720 for (i = 4; i < nargs; ++i)
4721 {
4722 result = args[i];
4723 if (MULTIPLE_VALUEP (result))
4724 {
4725 Lisp_Object val;
4726 Elemcount i, count = XMULTIPLE_VALUE_COUNT (result);
4727
4728 for (i = 0; i < count; i++)
4729 {
4730 val = multiple_value_aref (result, i);
4731 assert (!UNBOUNDP (val));
4732
4733 XSETCDR (list_offset, Fcons (val, Qnil));
4734 list_offset = XCDR (list_offset);
4735 }
4736 }
4737 else
4738 {
4739 XSETCDR (list_offset, Fcons (result, Qnil));
4740 list_offset = XCDR (list_offset);
4741 }
4742 }
4743
4744 apply_args [0] = XCAR (head);
4745 apply_args [1] = XCDR (head);
4746
4747 unbind_to (speccount);
4748
4749 RETURN_UNGCPRO (Fapply (countof(apply_args), apply_args));
4750 }
4751
4752 DEFUN ("multiple-value-call", Fmultiple_value_call, 1, UNEVALLED, 0, /*
4753 Call FUNCTION with arguments FORMS, using multiple values when returned.
4754
4755 All of the (possibly multiple) values returned by each form in FORMS are
4756 gathered together, and given as arguments to FUNCTION; conceptually, this
4757 function is a version of `apply' that by-passes the multiple values
4758 infrastructure, treating multiple values as intercalated lists.
4759
4760 arguments: (FUNCTION &rest FORMS)
4761 */
4762 (args))
4763 {
4764 int listcount, i = 0, speccount;
4765 Lisp_Object *constructed_args;
4766 struct gcpro gcpro1;
4767
4768 GET_EXTERNAL_LIST_LENGTH (args, listcount);
4769
4770 constructed_args = alloca_array (Lisp_Object, listcount + 3);
4771
4772 /* Fcar so we error on non-cons: */
4773 constructed_args[i] = IGNORE_MULTIPLE_VALUES (Feval (Fcar (args)));
4774
4775 GCPRO1 (*constructed_args);
4776 gcpro1.nvars = ++i;
4777
4778 /* The argument order is horrible here. */
4779 constructed_args[i] = make_int (0);
4780 gcpro1.nvars = ++i;
4781 constructed_args[i] = make_int (Vmultiple_values_limit);
4782 gcpro1.nvars = ++i;
4783
4784 speccount = bind_multiple_value_limits (0, Vmultiple_values_limit);
4785 constructed_args[i] = make_int (speccount);
4786 gcpro1.nvars = ++i;
4787
4788 {
4789 LIST_LOOP_2 (elt, XCDR (args))
4790 {
4791 constructed_args[i] = Feval (elt);
4792 gcpro1.nvars = ++i;
4793 }
4794 }
4795
4796 RETURN_UNGCPRO (multiple_value_call (listcount + 3, constructed_args));
4797 }
4798
4799 Lisp_Object
4800 multiple_value_list_internal (int nargs, Lisp_Object *args)
4801 {
4802 int first = XINT (args[0]), upper = XINT (args[1]),
4803 speccount = XINT(args[2]);
4804 Lisp_Object result = Qnil;
4805
4806 assert (nargs == 4);
4807
4808 result = args[3];
4809
4810 unbind_to (speccount);
4811
4812 if (MULTIPLE_VALUEP (result))
4813 {
4814 Lisp_Object head = Fcons (Qnil, Qnil);
4815 Lisp_Object list_offset = head, val;
4816 Elemcount count = XMULTIPLE_VALUE_COUNT(result);
4817
4818 for (; first < upper && first < count; ++first)
4819 {
4820 val = multiple_value_aref (result, first);
4821 assert (!UNBOUNDP (val));
4822
4823 XSETCDR (list_offset, Fcons (val, Qnil));
4824 list_offset = XCDR (list_offset);
4825 }
4826
4827 return XCDR (head);
4828 }
4829 else
4830 {
4831 if (first == 0)
4832 {
4833 return Fcons (result, Qnil);
4834 }
4835 else
4836 {
4837 return Qnil;
4838 }
4839 }
4840 }
4841
4842 DEFUN ("multiple-value-list-internal", Fmultiple_value_list_internal, 3,
4843 UNEVALLED, 0, /*
4844 Evaluate FORM. Return a list of multiple vals reflecting the other two args.
4845
4846 Don't use this. Use `multiple-value-list', the macro specified by Common
4847 Lisp, instead.
4848
4849 FIRST-DESIRED-MULTIPLE-VALUE is the first element in list of multiple values
4850 to pass back. MULTIPLE-VALUE-UPPER-LIMIT is the exclusive upper limit on
4851 the indexes within the values that may be passed back; this function will
4852 never return a list longer than MULTIPLE-VALUE-UPPER-LIMIT -
4853 FIRST-DESIRED-MULTIPLE-VALUE. It may return a list shorter than that, if
4854 `values' or `values-list' do not supply enough elements.
4855
4856 arguments: (FIRST-DESIRED-MULTIPLE-VALUE MULTIPLE-VALUE-UPPER-LIMIT FORM)
4857 */
4858 (args))
4859 {
4860 Lisp_Object argv[4];
4861 int first, upper, nargs;
4862 struct gcpro gcpro1;
4863
4864 GET_LIST_LENGTH (args, nargs);
4865 if (nargs != 3)
4866 {
4867 Fsignal (Qwrong_number_of_arguments,
4868 list2 (Qmultiple_value_list_internal, make_int (nargs)));
4869 }
4870
4871 argv[0] = IGNORE_MULTIPLE_VALUES (Feval (XCAR (args)));
4872 CHECK_NATNUM (argv[0]);
4873 first = XINT (argv[0]);
4874
4875 GCPRO1 (argv[0]);
4876 gcpro1.nvars = 1;
4877
4878 args = XCDR (args);
4879
4880 argv[1] = IGNORE_MULTIPLE_VALUES (Feval (XCAR (args)));
4881 CHECK_NATNUM (argv[1]);
4882 upper = XINT (argv[1]);
4883 gcpro1.nvars = 2;
4884
4885 /* The unintuitive order of things here is for the sake of the bytecode;
4886 the alternative would be to encode the number of arguments in the
4887 bytecode stream, which complicates things if we have more than 255
4888 arguments. */
4889 argv[2] = make_int (bind_multiple_value_limits (first, upper));
4890 gcpro1.nvars = 3;
4891 args = XCDR (args);
4892
4893 /* GCPROing in this function is not strictly necessary, this Feval is the
4894 only point that may cons up data that is not immediately discarded, and
4895 within it is the only point (in Fmultiple_value_list_internal and
4896 multiple_value_list) that we can garbage collect. But I'm conservative,
4897 and this function is called so rarely (only from interpreted code) that
4898 it doesn't matter for performance. */
4899 argv[3] = Feval (XCAR (args));
4900 gcpro1.nvars = 4;
4901
4902 RETURN_UNGCPRO (multiple_value_list_internal (countof (argv), argv));
4903 }
4904
4905 DEFUN ("multiple-value-prog1", Fmultiple_value_prog1, 1, UNEVALLED, 0, /*
4906 Similar to `prog1', but return any multiple values from the first form.
4907 `prog1' itself will never return multiple values.
4908
4909 arguments: (FIRST &rest BODY)
4910 */
4911 (args))
4912 {
4913 /* This function can GC */
4914 Lisp_Object val;
4915 struct gcpro gcpro1;
4916
4917 val = Feval (XCAR (args));
4918
4919 GCPRO1 (val);
4920
4921 {
4922 LIST_LOOP_2 (form, XCDR (args))
4923 Feval (form);
4924 }
4925
4926 RETURN_UNGCPRO (val);
4927 }
4928
4929 DEFUN ("values", Fvalues, 0, MANY, 0, /*
4930 Return all ARGS as multiple values.
4931
4932 arguments: (&rest ARGS)
4933 */
4934 (int nargs, Lisp_Object *args))
4935 {
4936 Lisp_Object result = Qnil;
4937 int counting = 1;
4938
4939 /* Pathological cases, no need to cons up an object: */
4940 if (1 == nargs || 1 == multiple_value_current_limit)
4941 {
4942 return nargs ? args[0] : Qnil;
4943 }
4944
4945 /* If nargs is zero, this code is correct and desirable. With
4946 #'multiple-value-call, we want zero-length multiple values in the
4947 argument list to be discarded entirely, and we can't do this if we
4948 transform them to nil. */
4949 result = make_multiple_value (nargs ? args[0] : Qnil, nargs,
4950 first_desired_multiple_value,
4951 multiple_value_current_limit);
4952
4953 for (; counting < nargs; ++counting)
4954 {
4955 if (counting >= first_desired_multiple_value &&
4956 counting < multiple_value_current_limit)
4957 {
4958 multiple_value_aset (result, counting, args[counting]);
4959 }
4960 }
4961
4962 return result;
4963 }
4964
4965 DEFUN ("values-list", Fvalues_list, 1, 1, 0, /*
4966 Return all the elements of LIST as multiple values.
4967 */
4968 (list))
4969 {
4970 Lisp_Object result = Qnil;
4971 int counting = 1, listcount;
4972
4973 GET_EXTERNAL_LIST_LENGTH (list, listcount);
4974
4975 /* Pathological cases, no need to cons up an object: */
4976 if (1 == listcount || 1 == multiple_value_current_limit)
4977 {
4978 return Fcar_safe (list);
4979 }
4980
4981 result = make_multiple_value (Fcar_safe (list), listcount,
4982 first_desired_multiple_value,
4983 multiple_value_current_limit);
4984
4985 list = Fcdr_safe (list);
4986
4987 {
4988 EXTERNAL_LIST_LOOP_2 (elt, list)
4989 {
4990 if (counting >= first_desired_multiple_value &&
4991 counting < multiple_value_current_limit)
4992 {
4993 multiple_value_aset (result, counting, elt);
4994 }
4995 ++counting;
4996 }
4997 }
4998
4999 return result;
5000 }
5001
5002 Lisp_Object
5003 values2 (Lisp_Object first, Lisp_Object second)
5004 {
5005 Lisp_Object argv[2];
5006
5007 argv[0] = first;
5008 argv[1] = second;
5009
5010 return Fvalues (countof (argv), argv);
5011 }
5012
5013
4212 /************************************************************************/ 5014 /************************************************************************/
4213 /* Run hook variables in various ways. */ 5015 /* Run hook variables in various ways. */
4214 /************************************************************************/ 5016 /************************************************************************/
4215 5017
4216 DEFUN ("run-hooks", Frun_hooks, 1, MANY, 0, /* 5018 DEFUN ("run-hooks", Frun_hooks, 1, MANY, 0, /*
4222 If the value is a function, it is called with no arguments. 5024 If the value is a function, it is called with no arguments.
4223 If it is a list, the elements are called, in order, with no arguments. 5025 If it is a list, the elements are called, in order, with no arguments.
4224 5026
4225 To make a hook variable buffer-local, use `make-local-hook', 5027 To make a hook variable buffer-local, use `make-local-hook',
4226 not `make-local-variable'. 5028 not `make-local-variable'.
5029
5030 arguments: (FIRST &rest REST)
4227 */ 5031 */
4228 (int nargs, Lisp_Object *args)) 5032 (int nargs, Lisp_Object *args))
4229 { 5033 {
4230 REGISTER int i; 5034 REGISTER int i;
4231 5035
4246 It is best not to depend on the value returned by `run-hook-with-args', 5050 It is best not to depend on the value returned by `run-hook-with-args',
4247 as that may change. 5051 as that may change.
4248 5052
4249 To make a hook variable buffer-local, use `make-local-hook', 5053 To make a hook variable buffer-local, use `make-local-hook',
4250 not `make-local-variable'. 5054 not `make-local-variable'.
5055
5056 arguments: (HOOK &rest ARGS)
4251 */ 5057 */
4252 (int nargs, Lisp_Object *args)) 5058 (int nargs, Lisp_Object *args))
4253 { 5059 {
4254 return run_hook_with_args (nargs, args, RUN_HOOKS_TO_COMPLETION); 5060 return run_hook_with_args (nargs, args, RUN_HOOKS_TO_COMPLETION);
4255 } 5061 }
4262 returns a non-nil value. Then we return that value. 5068 returns a non-nil value. Then we return that value.
4263 If all the functions return nil, we return nil. 5069 If all the functions return nil, we return nil.
4264 5070
4265 To make a hook variable buffer-local, use `make-local-hook', 5071 To make a hook variable buffer-local, use `make-local-hook',
4266 not `make-local-variable'. 5072 not `make-local-variable'.
5073
5074 arguments: (HOOK &rest ARGS)
4267 */ 5075 */
4268 (int nargs, Lisp_Object *args)) 5076 (int nargs, Lisp_Object *args))
4269 { 5077 {
4270 return run_hook_with_args (nargs, args, RUN_HOOKS_UNTIL_SUCCESS); 5078 return run_hook_with_args (nargs, args, RUN_HOOKS_UNTIL_SUCCESS);
4271 } 5079 }
4278 returns nil. Then we return nil. 5086 returns nil. Then we return nil.
4279 If all the functions return non-nil, we return non-nil. 5087 If all the functions return non-nil, we return non-nil.
4280 5088
4281 To make a hook variable buffer-local, use `make-local-hook', 5089 To make a hook variable buffer-local, use `make-local-hook',
4282 not `make-local-variable'. 5090 not `make-local-variable'.
5091
5092 arguments: (HOOK &rest ARGS)
4283 */ 5093 */
4284 (int nargs, Lisp_Object *args)) 5094 (int nargs, Lisp_Object *args))
4285 { 5095 {
4286 return run_hook_with_args (nargs, args, RUN_HOOKS_UNTIL_FAILURE); 5096 return run_hook_with_args (nargs, args, RUN_HOOKS_UNTIL_FAILURE);
4287 } 5097 }
4302 5112
4303 if (!initialized || preparing_for_armageddon) 5113 if (!initialized || preparing_for_armageddon)
4304 /* We need to bail out of here pronto. */ 5114 /* We need to bail out of here pronto. */
4305 return Qnil; 5115 return Qnil;
4306 5116
5117 #ifndef NEW_GC
4307 /* Whenever gc_in_progress is true, preparing_for_armageddon 5118 /* Whenever gc_in_progress is true, preparing_for_armageddon
4308 will also be true unless something is really hosed. */ 5119 will also be true unless something is really hosed. */
4309 assert (!gc_in_progress); 5120 assert (!gc_in_progress);
5121 #endif /* not NEW_GC */
4310 5122
4311 sym = args[0]; 5123 sym = args[0];
4312 val = symbol_value_in_buffer (sym, wrap_buffer (buf)); 5124 val = symbol_value_in_buffer (sym, wrap_buffer (buf));
4313 ret = (cond == RUN_HOOKS_UNTIL_FAILURE ? Qt : Qnil); 5125 ret = (cond == RUN_HOOKS_UNTIL_FAILURE ? Qt : Qnil);
4314 5126
4869 else 5681 else
4870 p->backtrace = Qnil; 5682 p->backtrace = Qnil;
4871 p->error_conditions = error_conditions; 5683 p->error_conditions = error_conditions;
4872 p->data = data; 5684 p->data = data;
4873 5685
4874 Fthrow (p->catchtag, Qnil); 5686 throw_or_bomb_out (p->catchtag, Qnil, 0, Qnil, Qnil);
4875 RETURN_NOT_REACHED (Qnil); 5687 RETURN_NOT_REACHED (Qnil);
4876 } 5688 }
4877 5689
4878 static Lisp_Object 5690 static Lisp_Object
4879 call_trapping_problems_2 (Lisp_Object opaque) 5691 call_trapping_problems_2 (Lisp_Object opaque)
5928 Lisp_Object opaque = XCAR (cons); 6740 Lisp_Object opaque = XCAR (cons);
5929 Lisp_Object lval = XCDR (cons); 6741 Lisp_Object lval = XCDR (cons);
5930 int *addr = (int *) get_opaque_ptr (opaque); 6742 int *addr = (int *) get_opaque_ptr (opaque);
5931 int val; 6743 int val;
5932 6744
6745 /* In the event that a C integer will always fit in an Emacs int, we
6746 haven't ever stored a C integer as an opaque pointer. This #ifdef
6747 eliminates a warning on AMD 64, where EMACS_INT has 63 value bits and C
6748 integers have 32 value bits. */
6749 #if INT_VALBITS < INTBITS
5933 if (INTP (lval)) 6750 if (INTP (lval))
5934 val = XINT (lval); 6751 {
6752 val = XINT (lval);
6753 }
5935 else 6754 else
5936 { 6755 {
5937 val = (int) get_opaque_ptr (lval); 6756 val = (int) get_opaque_ptr (lval);
5938 free_opaque_ptr (lval); 6757 free_opaque_ptr (lval);
5939 } 6758 }
6759 #else /* !(INT_VALBITS < INTBITS) */
6760 val = XINT(lval);
6761 #endif /* INT_VALBITS < INTBITS */
5940 6762
5941 *addr = val; 6763 *addr = val;
5942 free_opaque_ptr (opaque); 6764 free_opaque_ptr (opaque);
5943 free_cons (cons); 6765 free_cons (cons);
5944 return Qnil; 6766 return Qnil;
5951 record_unwind_protect_restoring_int (int *addr, int val) 6773 record_unwind_protect_restoring_int (int *addr, int val)
5952 { 6774 {
5953 Lisp_Object opaque = make_opaque_ptr (addr); 6775 Lisp_Object opaque = make_opaque_ptr (addr);
5954 Lisp_Object lval; 6776 Lisp_Object lval;
5955 6777
6778 /* In the event that a C integer will always fit in an Emacs int, we don't
6779 ever want to store a C integer as an opaque pointer. This #ifdef
6780 eliminates a warning on AMD 64, where EMACS_INT has 63 value bits and C
6781 integers have 32 value bits. */
6782 #if INT_VALBITS <= INTBITS
5956 if (NUMBER_FITS_IN_AN_EMACS_INT (val)) 6783 if (NUMBER_FITS_IN_AN_EMACS_INT (val))
5957 lval = make_int (val); 6784 lval = make_int (val);
5958 else 6785 else
5959 lval = make_opaque_ptr ((void *) val); 6786 lval = make_opaque_ptr ((void *) val);
6787 #else /* !(INT_VALBITS < INTBITS) */
6788 lval = make_int (val);
6789 #endif /* INT_VALBITS <= INTBITS */
6790
5960 return record_unwind_protect (restore_int, noseeum_cons (opaque, lval)); 6791 return record_unwind_protect (restore_int, noseeum_cons (opaque, lval));
5961 } 6792 }
5962 6793
5963 /* Similar to specbind() but for any C variable whose value is an int. 6794 /* Similar to specbind() but for any C variable whose value is an int.
5964 Sets up an unwind-protect to restore the variable pointed to by 6795 Sets up an unwind-protect to restore the variable pointed to by
6437 7268
6438 void 7269 void
6439 syms_of_eval (void) 7270 syms_of_eval (void)
6440 { 7271 {
6441 INIT_LISP_OBJECT (subr); 7272 INIT_LISP_OBJECT (subr);
7273 INIT_LISP_OBJECT (multiple_value);
6442 7274
6443 DEFSYMBOL (Qinhibit_quit); 7275 DEFSYMBOL (Qinhibit_quit);
6444 DEFSYMBOL (Qautoload); 7276 DEFSYMBOL (Qautoload);
6445 DEFSYMBOL (Qdebug_on_error); 7277 DEFSYMBOL (Qdebug_on_error);
6446 DEFSYMBOL (Qstack_trace_on_error); 7278 DEFSYMBOL (Qstack_trace_on_error);
6460 DEFSYMBOL (Qvalues); 7292 DEFSYMBOL (Qvalues);
6461 DEFSYMBOL (Qdisplay_warning); 7293 DEFSYMBOL (Qdisplay_warning);
6462 DEFSYMBOL (Qrun_hooks); 7294 DEFSYMBOL (Qrun_hooks);
6463 DEFSYMBOL (Qfinalize_list); 7295 DEFSYMBOL (Qfinalize_list);
6464 DEFSYMBOL (Qif); 7296 DEFSYMBOL (Qif);
7297 DEFSYMBOL (Qthrow);
7298 DEFSYMBOL (Qobsolete_throw);
7299 DEFSYMBOL (Qmultiple_value_list_internal);
6465 7300
6466 DEFSUBR (For); 7301 DEFSUBR (For);
6467 DEFSUBR (Fand); 7302 DEFSUBR (Fand);
6468 DEFSUBR (Fif); 7303 DEFSUBR (Fif);
6469 DEFSUBR_MACRO (Fwhen); 7304 DEFSUBR_MACRO (Fwhen);
6472 DEFSUBR (Fprogn); 7307 DEFSUBR (Fprogn);
6473 DEFSUBR (Fprog1); 7308 DEFSUBR (Fprog1);
6474 DEFSUBR (Fprog2); 7309 DEFSUBR (Fprog2);
6475 DEFSUBR (Fsetq); 7310 DEFSUBR (Fsetq);
6476 DEFSUBR (Fquote); 7311 DEFSUBR (Fquote);
7312 DEFSUBR (Fquote_maybe);
6477 DEFSUBR (Ffunction); 7313 DEFSUBR (Ffunction);
6478 DEFSUBR (Fdefun); 7314 DEFSUBR (Fdefun);
6479 DEFSUBR (Fdefmacro); 7315 DEFSUBR (Fdefmacro);
6480 DEFSUBR (Fdefvar); 7316 DEFSUBR (Fdefvar);
6481 DEFSUBR (Fdefconst); 7317 DEFSUBR (Fdefconst);
6482 DEFSUBR (Fuser_variable_p);
6483 DEFSUBR (Flet); 7318 DEFSUBR (Flet);
6484 DEFSUBR (FletX); 7319 DEFSUBR (FletX);
6485 DEFSUBR (Fwhile); 7320 DEFSUBR (Fwhile);
6486 DEFSUBR (Fmacroexpand_internal); 7321 DEFSUBR (Fmacroexpand_internal);
6487 DEFSUBR (Fcatch); 7322 DEFSUBR (Fcatch);
6494 DEFSUBR (Fcommandp); 7329 DEFSUBR (Fcommandp);
6495 DEFSUBR (Fcommand_execute); 7330 DEFSUBR (Fcommand_execute);
6496 DEFSUBR (Fautoload); 7331 DEFSUBR (Fautoload);
6497 DEFSUBR (Feval); 7332 DEFSUBR (Feval);
6498 DEFSUBR (Fapply); 7333 DEFSUBR (Fapply);
7334 DEFSUBR (Fmultiple_value_call);
7335 DEFSUBR (Fmultiple_value_list_internal);
7336 DEFSUBR (Fmultiple_value_prog1);
7337 DEFSUBR (Fvalues);
7338 DEFSUBR (Fvalues_list);
6499 DEFSUBR (Ffuncall); 7339 DEFSUBR (Ffuncall);
6500 DEFSUBR (Ffunctionp); 7340 DEFSUBR (Ffunctionp);
6501 DEFSUBR (Ffunction_min_args); 7341 DEFSUBR (Ffunction_min_args);
6502 DEFSUBR (Ffunction_max_args); 7342 DEFSUBR (Ffunction_max_args);
6503 DEFSUBR (Frun_hooks); 7343 DEFSUBR (Frun_hooks);
6519 backtrace_list = 0; 7359 backtrace_list = 0;
6520 Vquit_flag = Qnil; 7360 Vquit_flag = Qnil;
6521 debug_on_next_call = 0; 7361 debug_on_next_call = 0;
6522 lisp_eval_depth = 0; 7362 lisp_eval_depth = 0;
6523 entering_debugger = 0; 7363 entering_debugger = 0;
7364
7365 first_desired_multiple_value = 0;
7366 multiple_value_current_limit = 1;
6524 } 7367 }
6525 7368
6526 void 7369 void
6527 reinit_vars_of_eval (void) 7370 reinit_vars_of_eval (void)
6528 { 7371 {
6614 a `condition-case'. 7457 a `condition-case'.
6615 If the value is a list, an error only means to enter the debugger 7458 If the value is a list, an error only means to enter the debugger
6616 if one of its condition symbols appears in the list. 7459 if one of its condition symbols appears in the list.
6617 This variable is overridden by `debug-ignored-errors'. 7460 This variable is overridden by `debug-ignored-errors'.
6618 See also variables `debug-on-quit' and `debug-on-signal'. 7461 See also variables `debug-on-quit' and `debug-on-signal'.
7462
7463 Process filters are considered to be outside of condition-case forms
7464 (unless contained in the process filter itself). To prevent the
7465 debugger from being called from a process filter, use a list value, or
7466 put the expected error\(s) in `debug-ignored-errors'.
6619 7467
6620 If this variable is set while XEmacs is running noninteractively (using 7468 If this variable is set while XEmacs is running noninteractively (using
6621 `-batch'), and XEmacs was configured with `--debug' (#define XEMACS_DEBUG 7469 `-batch'), and XEmacs was configured with `--debug' (#define XEMACS_DEBUG
6622 in the C code), instead of trying to invoke the Lisp debugger (which 7470 in the C code), instead of trying to invoke the Lisp debugger (which
6623 obviously won't work), XEmacs will break out to a C debugger using 7471 obviously won't work), XEmacs will break out to a C debugger using
6683 If due to `apply' or `funcall' entry, one arg, `lambda'. 7531 If due to `apply' or `funcall' entry, one arg, `lambda'.
6684 If due to `eval' entry, one arg, t. 7532 If due to `eval' entry, one arg, t.
6685 */ ); 7533 */ );
6686 Vdebugger = Qnil; 7534 Vdebugger = Qnil;
6687 7535
7536 DEFVAR_CONST_INT ("multiple-values-limit", &Vmultiple_values_limit /*
7537 The exclusive upper bound on the number of multiple values.
7538
7539 This applies to `values', `values-list', `multiple-value-bind' and related
7540 macros and special forms.
7541 */);
7542 Vmultiple_values_limit = EMACS_INT_MAX > INT_MAX ? INT_MAX : EMACS_INT_MAX;
7543
6688 staticpro (&Vcatch_everything_tag); 7544 staticpro (&Vcatch_everything_tag);
6689 Vcatch_everything_tag = make_opaque (OPAQUE_CLEAR, 0); 7545 Vcatch_everything_tag = make_opaque (OPAQUE_CLEAR, 0);
6690 7546
6691 staticpro (&Vpending_warnings); 7547 staticpro (&Vpending_warnings);
6692 Vpending_warnings = Qnil; 7548 Vpending_warnings = Qnil;