[Push] runpush operation

Lee Spector lspector at hampshire.edu
Sat Nov 1 21:32:13 EST 2003


Rud,

I think you've understood it correctly from looking at the Lisp code. DO
and DO* should each only do one evaluation. But RUNPUSH (the top level call
to the interpreter) does two things aside from (before) a normal
evaluation: 1) it pushes the code it is given onto the code stack, and 2)
it pushes any other provided arguments onto the appropriate stacks.

#1 was specified to make the expression of recursive programs a bit easier.

#2 can, as you note, be implemented by evaluating the list of arguments, or
even by pushing the list onto the code stack and then doing a DO.

Perhaps it would be more "pure" in some sense to do neither of these
things, as then there'd be no distinction between RUNPUSH and internal
calls to the interpreter. But these conventions are handy and they create a
(recursion-friendly) context for top-level calls.

 -Lee




At 4:33 PM -0600 11/1/03, Rud Merriam wrote:
>I am not understanding something about either the DO / DO* operators or
>runpush. In the expression
>
>        (runpush '(integer.dup integer.+) '(5))
>
>I evaluate it as:
>
>        code.push("(integer.dup integer.+)") code.push("(5)") <while code
>!empty>  code.do
>
>The result is the first DO pushes the 5 on the integer stack and the second
>DO does the dup and + operators. That leaves the code stack empty.
>
>I just looked at the LISP at the URL you posted in your Push2 message last
>month. My LISP is very rusty but I think I got it. Runpush pushes its first
>argument on the code stack and the second argument values on their
>appropriate stacks.
>
>If that is correct then it is equivalent to:
>
>        code.push("(integer.dup integer.+)") code.push("(5)") code.do
>code.do
>
>Rud Merriam
>K5RUD
>
>
>_______________________________________________
>Push mailing list
>Push at lists.hampshire.edu
>http://lists.hampshire.edu/mailman/listinfo/push

--
Lee Spector
Dean, School of Cognitive Science
Associate Professor of Computer Science    lspector at hampshire.edu
Cognitive Science, Hampshire College       http://hampshire.edu/lspector/
Amherst, MA 01002                          413-559-5352, Fax: 413-559-5438




More information about the Push mailing list