Sanitize is not fool proof (yet) .Sanitize2 seems to work as advertized.



>
> Quoted arguments, in my opinion, are almost never a good idea.  They
> make for "convenience" in the short run at the cost of complications
> in the long run.
To avoid confusion I would like to stress again that the issue with my
example is not related to quotation.

h(s,t):=s[t]$
h(r,1);
    r_1
h(t,1);
t evaluates to 1
Improper name or value in functional position.
#0: h(s=t,t=1)
 -- an error.  To debug this try debugmode(true);

> I agree with Michel that getting clean general semantics is the right
> solution, however, I am not sure it is as straightforward as something
> like "sanitize".
Something like Richard's sanitize (suitably extended) which would replace parameters
and local block variables (and probably the dummy variables in lambda expression as well) by ?gensym()'s
would go a long way to emulating lexical scope I think.

It would be stop gap measure but it seems easy to implement (it should probably be done in lisp to make
it fool proof). Basically one has to traverse the syntax tree of a function (which is already available
as a list in lisp) and use a symbol table to do the correct subsitutions.  

For the record sanitize(h) gives (with display2d off)

h(?g32637,?g32638):=?g32637[?g32638]

h(t,1);
   t[1]

Do you see any issues with this (I am not very experienced in maxima so I might be missing something)?

Michel