# Call a function

## Position-based syntax for calling a function

Analytica uses the standard position-based syntax for using, or calling, a function. You simply list the actual parameters in the standard sequence after the function name, separated by commas, and between parentheses. For example:

Capm(5%, 8%, StockBeta)

This evaluates function Capm(Rf, Rm, Beta) with Rf set to 5%, Rm set to 8%, and Beta set to Stockbeta.

## Name-based syntax for calling a function

Analytica also supports a more flexible name-based calling syntax. As you might guess, you identify each parameter by name:

Capm(beta: StockBeta, rf: 5%, rm: 8%)

In this case, you give the name of each parameter, followed by colon “:”, and an expression whose value is passed to that parameter. As with position-based syntax, the parameters are separated by commas and between parentheses. But with name-based syntax, the parameters can appear in any sequence. It must include all required parameters. This method is much easier to read when the function has many parameters. It is especially useful when many parameters are optional.

You can mix positional and named parameters, but you must put the positional parameters first:

Fu1(1, 2, D: 4, C:3)

You may not give a positional parameter after a named parameter:

Fu1(1, D: 4, 2, 3) → Syntax error

This name-based calling syntax is analogous to Analytica’s name-based subscripting for arrays: To select a cell or slice of a multi-dimensional array, you specify each index by name, along with the selection value -- so you can specify them in any sequence, which makes subscript expressions much easier to write and more robust. See x[i=v]: Subscript construct.

Tip
Name-based calling syntax works for all user-defined functions. It also works for most of the builtin functions, except for a few with only one or two parameters.