# Difference between function definitions [duplicate]

Possible Duplicate:
Functions vs. patterns

I thought about describing the context in which I faced this problem, but I figured it is general enough and clear enough to pose it as it is.

What is the difference between the two following definitions:

f[x_]:=Sin[x]
g=Sin[#]&


Under what circumstances will the two behave differently? Is any of them preferable as a general practice?

-

## marked as duplicate by Leonid Shifrin, Yves Klett, Mr.Wizard♦Dec 4 '12 at 11:42

@LeonidShifrin well, there are the much better answers! –  Yves Klett Dec 4 '12 at 11:30
@YvesKlett At the time that one was asked, we had a lot of energy since we were only out there for a week :) –  Leonid Shifrin Dec 4 '12 at 11:31
@LeonidShifrin question on best practice: since my answer is now quite redundant and I am voting to close, should I delete the answer? –  Yves Klett Dec 4 '12 at 11:36
@YvesKlett Since the question is likely going to be closed,I think that does not matter much. –  Leonid Shifrin Dec 4 '12 at 11:37
@LeonidShifrin True that. Googling with site:mathematica.stackexchange.com added to the search terms is often better. –  Sjoerd C. de Vries Dec 4 '12 at 12:52

A pure function like g will be faster performance-wise, because it gets rid of all the overhead (e.g. pattern matching) involved in the definition of f.