Distinction between positional and named arguments

Hi sijo,

Thanks for your warm welcome in the forum and taking the time to share your thoughts! I did not necessarily mean to propose a new wording, I am mainly trying to wrap my head around how things work in Typst. For example, I was not aware that Typst strictly refers to “parameters” when talking about the function definition.

I’m not so sure about your statement that “the fact that arguments are named if and only if they have a default value is a bit incidental” – re-reading the Typst documentation there seems to be a clear link:

The parameter list can contain mandatory positional parameters, named parameters with default values and argument sinks.

Otherwise, how else could you specify what is positional or named in the function definition?

The other thing I was struggling with is how a function is called. If whether a parameter is positional or named is determined in the function definition and not by the way a function is called, I was expecting that named arguments would be matched to the corresponding function parameter and that any unnamed arguments would be matched by position (as is the case in R and other programming languages). However, this is not true in Typst:


#let f(a, x: [Typst]) = [#a #x]

// works
#f([Hi], x: [there])

// does not work
// #f([Hi], [there])

// does not work
// #f(a: [Hi], x: [there])