# Is there any point to using a variable as a function parameter?

Normally one only sees patterns as function parameters:

fun1[x_]:=x^2


Is there any point to using a variable in a function definition:

fun2[y]:=x^2


I suppose to make this work I have to define y as a pattern:

y=x_


Is there any useful application where this occurs?

• fun2 will only give a result for argument y, and will remain unevaluated otherwise. The point of using a pattern is that it's a "dummy" (satisfying the appropriate conditions) that can be replaced. – J. M. is in limbo May 16 '16 at 18:22
• @J.M. I know why patterns are used. I am asking if there is an application for using a non-pattern parameter. – Tyler Durden May 16 '16 at 18:23
• To make the first sentence in my previous comment more explicit: it can happen that you want your function to evaluate only for literal arguments. Special cases, or what have you. – J. M. is in limbo May 16 '16 at 18:25
• You can use a variable in a function definition as an index. Here is a Wolfram Language Tutorial example. – Karsten 7. May 16 '16 at 18:55