Sanitize is not fool proof (yet) .Sanitize2 seems to work as advertized.
Subject: Sanitize is not fool proof (yet) .Sanitize2 seems to work as advertized.
From: Michel Van den Bergh
Date: Wed, 03 Jan 2007 10:26:26 +0100
Richard Fateman wrote:
>>Am I right that gensym substitution for x can be done safely if x does
>>not appear in a non evaluated
>>argument to some function?
>>
>>The following seems safe
>>
>>f(x):=(define(otherfun(z),x))
>>
>>since define evaluates its second argument.
>>
>>
>>
>
>What would you do with f(cos,x):= cos(x)^2 ?
>Do you want to call the cosine function?
>
>
>
>
>
Hmm I see. cos is a noun (properties(cos)). So this means it is implicitly
quoted.
(1) By the rule: don't touch unevaluated material *at all* the
sanitized version of this
function would be
f(cos,uniq):=cos(uniq)^2
(2) By the rule: don't touch unevaluated material *inside the function
body* the
sanitized version would be
f(uniq1,uniq2):=cos(uniq2)^2
In this case both versions seem to be equivalent. However they behave
differently for
f(x):=ev('x)
since now x is evaluated. I am not sure if it possible to detect this
syntactically.
(I think every ev removes one round of quoting, but what if the user has
redefined ev?).
If not I prefer rule (2) even in this case but this changes current
behaviour. Rule (1)
keeps current behaviour.
Michel