Jump to content

Page:AITR-474.djvu/30

From Wikisource
This page has been proofread, but needs to be validated.

20

LAMBDA
We use this primarily in the form:
((LAMBDA (q1 ... qn) 
         (setq var1 q1)
         ...
         (setq varn qn))
 value1 ... valuen)

which we may think of as saving values on a temporary stack and then popping them into the variables:

<code for value1>    ;leaves result in reg1
PUSH reg1
...
<code for valuen> 
PUSH reg1
POP varn 
...
POP var1

This is in fact approximately how the MacLISP compiler will treat this construct. This is used to effect the simultaneous assignment of several values to several registers. It would be possible to do without the MacLISP LAMBDA in this case, by using extra intermediate variables, but it was decided that this task was less interesting than other issues within RABBIT, and that assignments of this kind would occur sufficiently often that it was desirable to get the MacLISP compiler to produce the best possible code in this case.

The form ((LAMBDA .. ) ..) is also used in some situation where the user wrote such a form in the SCHEME code, and the arguments and LAMBDA-body are all "trivial", in a sense to be defined later.
CONS
CONS is used, among other things, to "push" new values onto the current environment. While SCHEME variables can sometimes be represented as temporary MacLISP variables using LAMBDA, in general they must be kept