Hacker News new | ask | show | jobs
by throwawaymaths 581 days ago
Default argument variables create variadic functions.

Arity N when you supply a value

Arity N-1 when you use the default

2 comments

How does this create variadic functions? The arity is the same, since the function signature defines the exact amount of arguments. The compiler just passes the omitted ones for you.
Okay, but why could a static language not have variadic functions?
That's their design choice.

I can think of a few reasons

- makes function calling simpler

- faster compilation

- less symbol mangling

- makes grepping for function implementation easier

If for some reason you think you absolutely can't live without variadic functions, maybe don't use zig.