question about function definition



On 9/5/07, Richard Fateman <fateman at cs.berkeley.edu> wrote:
> Your suggestion looks good to me.  the original question suggests a
> misunderstanding of programming language conventions.
> in %i15, i is a parameter to the function template and logically speaking is
> "bound"  and then used in the function body.

I don't think you're being fair here.  The Maxima definition form

       f[ A ]( B ) := ...

does *not* behave like funny syntax for normal Maxima function
definition f(A,B). (Or for that matter like function definition in
most other languages).  Neither Maxima nor any other common language
will allow A to be anything but a simple identifier, whereas Maxima
allows things like

      f[1](x) := ...
and
      f[i*j](x) := ...

As far as I can tell, the only way to specify the semantics of f[A](B)
is as two different cases: 1) If A is a simple identifier, then it is
taken as a bound parameter.  2) If it is not, it behaves like an
unevaluated constant.  Constant definitions override bindings. Some
languages (e.g. Prolog) allow patterns as formal parameters, but
otherwise this is not at all like traditional language semantics.

Also, though a[x](y):=xxx acts in some ways like a[x]:lambda([y],xxx),
it doesn't really.  But I don't have time to go into details.

          -s