## 9.2 Function names

The rules for function naming and function-argument naming are the same as for other variables; see the section on variables for more information on valid identifiers. For example,

real foo(real mu, real sigma);

declares a function named foo with two argument variables of types real and real. The arguments are named mu and sigma, but that is not part of the declaration.

Multiple user-defined functions may have the same name if they have different sequences of argument types. This is known as function overloading.

For example, the following two functions are both defined with the name add_up

real add_up(real a, real b){
return a + b;
}

real add_up(real a, real b, real c){
return a + b + c;
}

The return types of overloaded functions do not need to be the same. One could define an additional add_up function as follows

int add_up(int a, int b){
return a + b;
}

That being said, functions may not use the same name if their signature only differs by the return type.

For example, the following is not permitted

// illegal
real baz(int x);
int baz(int x);

Function names used in the Stan standard library may be overloaded by user-defined functions. Exceptions to this are the reduce_sum family of functions and ODE integrators, which cannot be overloaded.