firstname.lastname@example.org <email@example.com> wrote:
| Thank you for your reply !
| So according to your post , if we define a function like this : (defun
| f (x1 x2 x3 ... xn) somecode) , and then run (f t1 t2 ... tn) , first
| the interpreter evaluates t1 t2 ... and tn ,then it turn to "somecode"
| and try to evaluate it , once it encounters say xi , it uses the value
| from ti and DO NOT EVALUATE IT AGAIN , that's right?
Correct. In the language of subroutine call protocols, this is
known as "call-by-value", and Common Lisp, Scheme, and most other
widely-used languages these days (including C, C++, and Java)
are call-by-value languages. In call-by-value, the "actual"
arguments to a function call [your "t1", "t2", etc.] are evaluated
exactly once, in the caller's environment, and only the resulting
values of those evaluations are passed to the called routine. Nothing
of the form or shape [e.g., names, arithmetic expressions] of those
arguments is passed to the callee, only the evaluated values.
In the called routine, the variables named by the "formal"
arguments [your "x1", "x2", etc.] are bound, as if by LET,
to the values passed from the caller. Later assignments
to those variable in the callee (with SETF, etc.) of different
values to the formal argument variables may change their values
at that time, but such changes have no effect on the caller's
environment. Call-by-value is entirely one-way [except for the
callee's return value, of course].
There *are* other styles of subroutine call protocols, including
"call-by-reference" [e.g., Fortran], and "call-by-name" [e.g.,
Algol-60]. The semantics of call-by-name are especially weird,
but that's another story...
 Common Lisp macros are another story entirely.
 Details of the processing of &OPTIONAL, &KEY, and &REST
arguments are a further complication, but even there,
*if* any specific argument is included by the caller,
the subroutine call protocol still obeys call-by-value
semantics w.r.t that argument.
Rob Warnock <firstname.lastname@example.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607