This is an old version, view current version.

9.6 Parameters are Constant

Within function definition bodies, the parameters may be used like any other variable. But the parameters are constant in the sense that they can’t be assigned to (i.e., can’t appear on the left side of an assignment (=) statement)<. In other words, their value remains constant throughout the function body. Attempting to assign a value to a function parameter value will raise a compile-time error.14

Local variables may be declared at the top of the function block and scope as usual.


  1. Despite being declared constant and appearing to have a pass-by-value syntax in Stan, the implementation of the language passes function arguments by constant reference in C++.