Hi Edwin,

> need some help. when is evList2() called in minipicolisp?
> i can't decipher when it is called.
> comments are mine.
> if (isNum(foo = car(ex)))
>       return ex; /* return numbers as is */

Right. This is the case where the evaluated list starts with a number,
e.g. (1 2 3 4), or also (123 a b c).

> if (isCell(foo)) {

'foo' is the CAR of the list, and it is a list here. We might have a
call like ((get 'x 'y) 1 2 3), so 'foo' is (get 'x 'y) which - when
evaluated - is supposed to return a function.

>       if (isNum(foo = evList(foo)))
>          return evSubr(foo, ex); /* if a list evaluates to a number,
> call a C subroutine */

Yes. Evaluation of (get 'x 'y) resulted in a number, so a C function is

>       return evList2(foo, ex); /* then... ? */

'foo' is not a number, so these are the remaining possibilities: It must
be either a symbol or a list. It might be a symbol if we have e.g. (x 1
2 3) where the value of 'x' is 'y', which in turn is defined as a
function (or something else suitable to a recursive invocation of the
whole 'evList' machinery). Otherwise, it is a list which is taken as a
function (i.e. (<params> . <body>).

'evList2' is put into a separate function for a single reason: The value
must be pushed on the stack to be safe from garbage collection (the
'Push' marcro at the start of 'evList2').

This problem we have only in the C version, because the compiler
allocates space in the stack frame for 'c1' on every call to 'evList',
which is a waste of stack space in most cases, as "normal" function
calls don't pass through here.

- Alex
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to