Subject: Q about arguments scoping in function definition
From: Stavros Macrakis
Date: Mon, 8 Oct 2007 09:53:15 -0400
In the Maxima language, the f in f(x) is evaluated as follows:
1) If it is a lambda expression, apply it.
2) If it is a symbol, then
a) if it is a built-in function, apply it
a) if it has a ":=" value, substitute that and go back to (1)
b) if it has a ":" value or binding, substitute that and go back to (1)
3) Consider f to be a formal function, and just simplify the expression f(x).
Function references are not resolved at definition time, but at evaluation time.
This is all consistent with "traditional" Lisp semantics (pre-Scheme,
pre-Common Lisp).
If you want to use a functional argument, use apply to avoid this problem, e.g.
t(n, f, x) := apply(f, [n+x]);
-s