> f(x):=subst(t=x,diff(sin(t),t));
I wouldn't recommend doing things this way. First of all, it carries
out the differentiation each time f is called (consider a 3d plot
involving f!). Secondly, if the variable 't' happens to be bound to a
value when f is called (remember dynamic scope), you will get an error:
t: 3;
f(0) => error
You could patch up the free variable problem by surrounding the body
with block([t],...), by using 'at' instead of 'subst', or by quoting the
expressions diff('(sin(t)),'t), but none of these solutions is very
pretty.
I would instead recommend first evaluting the inside expression and then
substituting it at function-definition time, e.g.
expr: diff(sin(t),t);
Now look at the result and make sure it's what you want.
f(t):= ''expr $
This has precisely the same effect as
f(t):= cos(t) $
As Richard Fateman has pointed out before, this is in fact the main use
of the '' operator, which should *not* in general be used as a
substitute for ev().
-s