Question: Making a function using the diff operator

This is a very basic question and apologize for not being able to figure it out myself.     I would like to define a function that I can evaluate with a complicated argument.    For example for a simple function, the following works well

f:=x->x^2+x^3;

This allows me to plot f(x) or f(exp(-r)), etc.    

However the following syntax does not work in the same way.

g:=x->diff(f(x),x);

I can plot g(x) correctly, but g(exp(-r))  cannot be plotted or evaluated.    The error message is 

Error, (in g) invalid input: diff received exp(-r), which is not valid for its 2nd argument
Thanks in advance for your suggestions.

Please Wait...