mbeckem / tiro

A simple scripting language.
MIT License
7 stars 0 forks source link

Optional and variadic function arguments #16

Open mbeckem opened 3 years ago

mbeckem commented 3 years ago

Currently user defined functions can only specify a fixed number of parameters:

fn foo(a, b, c) { ... }

We should at least support optional function parameters and possibly also variadic functions.

Example syntax for optional parameters:

fn dump(value, pretty = false) { ... }

"?" syntax like in TypeScript (e.g. pretty?) is not a good idea here, i think. The only fitting default value would be null (i do not want an undefined construct exposed to the language).