top | item 42097089

(no title)

owl57 | 1 year ago

I believe that if most foo's users should just call it with [], the Pythonic way is to make the argument optional.

discuss

order

samatman|1 year ago

Well yes, but if it's someone else's library, realistically you're not going to change it.

Zig is a static language without variadic parameters, so you can't make it optional in that sense. You could make the options a `?T` and pass `null` instead, but it isn't idiomatic, because passing `.{}` to a parameter expecting a `T` will fill in all the default values for you.

xigoi|1 year ago

This doesn’t answer the question why Zig doesn’t have default argument values.