@Preben Alsholm I cite from the Search command Help page: "If f is a procedure or name of procedure the problem variables are the names of Required Positional Parameters (see ?parameter_classes ) which can be returned by op(1, eval(f)) command. If you want to use another type of procedure parameters or you use "The End of Parameters Marker, $", you should use option variables to explicitly give the list of the problem variable names."
So your second example
is correct according to the Help page, but your first example
isn't correct according to the Help page because y isn't the name of Required Positional Parameter of sin procedure.
I agree that "the function x->x^2 is exactly the same as the function y -> y^2" but only when there aren't constraints.
If there are the constraints, for example x>0, then notation (x->x^2, x>0) is naturally looked as function and constraint, but (y->y^2, x>0) is looked as function of variable y and inequality with another variable x.
The one of the standard optimization notations for constrained optimization tasks in scientific papers is as the following:
f: x E Rn->R
So the Search can almost exactly reproduce this notation.