Parameters

Templates and functions are parameterised. The syntax for parameters is defined by the grammar for Parameters:

Parameters ::= [ Parameter (',' Parameter)* ]
Parameter  ::= Type [ '&' ] ID ArrayDecl*

In contrast to global and local declarations, the parameter list should not be terminated by a semicolon.

Call by Reference and Call by Value

Parameters can be declared to have either call-by-value or call-by-reference semantics. The syntax is taken from C++, where the identifier of a call-by-reference parameter is prefixed with an ampersand in the parameter declaration. Call-by-value parameters are not prefixed with an ampersand.

Array parameters are the exception to this rule, as they are always call-by-reference and must not be prefixed with an ampersand. This is for compatibility with C.

Examples