Skip to content

Functions

Functions appear in expressions and take positional and/or named arguments, producing a value as a result of their computation.

Function signatures have the following notation:

f(arg1:<type>, arg2=<type>, [arg3=type]) -> <type>
  • arg:<type>: positional argument
  • arg=<type>: named argument
  • [arg=type]: optional (named) argument
  • -> <type>: function return type

TQL features the uniform function call syntax (UFCS), which allows you to interchangeably call a function with at least one argument either as free function or method. For example, length(str) and str.length() resolve to the identical function call. The latter syntax is particularly suitable for function chaining, e.g., x.f().g().h() reads left-to-right as “start with x, apply f(), then g() and then h(),” compared to h(g(f(x))), which reads “inside out.”

Throughout our documentation, we use the free function style in the synopsis but often resort to the method style when it is more idiomatic.

Last updated: