Parameters and arguments: passing information to a function
A function can do the same job with different information. Its parameters are the names in its definition. Its arguments are the values you supply when calling it.
Think of a recipe that says “use this many apples.” The blank in the recipe is like a parameter. Choosing four apples is like supplying an argument.
# language: en
function total(price, amount):
return price * amount
say total(3, 4)
price and amount are parameters. The arguments 3 and 4 give them values for this call. The answer is 12.
Order and number matter
Pliro matches arguments to parameters by position. The first goes into the first slot. A parameter’s name does not automatically pull a same-named variable from somewhere else.
The number of arguments is sometimes called arity. This function needs two. Supplying one or three is an error. Built-ins document their permitted counts in their reference pages.
Pliro evaluates ordinary call arguments from left to right. Giving a function a list or map shares that collection; it does not automatically make a deep copy. The mutation article explains why that matters.
Try total(5, 2), then explain the two parameter values before calculating the answer.
