Commit a02ca7a2 authored by Paul Eggert's avatar Paul Eggert

Simplify prog1 implementation

Inspired by a suggestion from Chris Gregory in:
On my platform, this generates exactly the same machine insns.
* src/eval.c (prog_ignore): Rename from unwind_body, since
it’s more general than that.  All callers changed.
(Fprog1): Simplify by using prog_ignore.
(Fwhile): Clarify by using prog_ignore.
parent e6161f64
......@@ -809,7 +809,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
Lisp_Object handler = POP;
/* Support for a function here is new in 24.4. */
record_unwind_protect (FUNCTIONP (handler) ? bcall0 : unwind_body,
record_unwind_protect (FUNCTIONP (handler) ? bcall0 : prog_ignore,
......@@ -453,11 +453,10 @@ usage: (progn BODY...) */)
return val;
/* Evaluate BODY sequentially, discarding its value. Suitable for
record_unwind_protect. */
/* Evaluate BODY sequentially, discarding its value. */
unwind_body (Lisp_Object body)
prog_ignore (Lisp_Object body)
Fprogn (body);
......@@ -469,16 +468,8 @@ whose values are discarded.
usage: (prog1 FIRST BODY...) */)
(Lisp_Object args)
Lisp_Object val;
Lisp_Object args_left;
args_left = args;
val = args;
val = eval_sub (XCAR (args_left));
while (CONSP (args_left = XCDR (args_left)))
eval_sub (XCAR (args_left));
Lisp_Object val = eval_sub (XCAR (args));
prog_ignore (XCDR (args));
return val;
......@@ -988,7 +979,7 @@ usage: (while TEST BODY...) */)
while (!NILP (eval_sub (test)))
Fprogn (body);
prog_ignore (body);
return Qnil;
......@@ -1191,7 +1182,7 @@ usage: (unwind-protect BODYFORM UNWINDFORMS...) */)
Lisp_Object val;
ptrdiff_t count = SPECPDL_INDEX ();
record_unwind_protect (unwind_body, XCDR (args));
record_unwind_protect (prog_ignore, XCDR (args));
val = eval_sub (XCAR (args));
return unbind_to (count, val);
......@@ -3867,7 +3867,7 @@ extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object);
extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object);
extern void init_eval (void);
extern void syms_of_eval (void);
extern void unwind_body (Lisp_Object);
extern void prog_ignore (Lisp_Object);
extern ptrdiff_t record_in_backtrace (Lisp_Object, Lisp_Object *, ptrdiff_t);
extern void mark_specpdl (union specbinding *first, union specbinding *ptr);
extern void get_backtrace (Lisp_Object array);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment