Agree with several people here that named parameters are a good solution, they add minimal overhead at the call site and function declaration and look very natural.
Another option for languages that want function arguments to have fixed size is bitmasks. I wonder if it could be a useful language feature to infer the flag names from the function declaration. Something like
def my_function(arg1, arg2, [FLAG1, FLAG2]) {
if (FLAG1) {
do thing
}
...
}
my_function(val1, val2, FLAG1 | FLAG2)
Agree with several people here that named parameters are a good solution, they add minimal overhead at the call site and function declaration and look very natural.
Another option for languages that want function arguments to have fixed size is bitmasks. I wonder if it could be a useful language feature to infer the flag names from the function declaration. Something like
def my_function(arg1, arg2, [FLAG1, FLAG2]) { if (FLAG1) { do thing } ... } my_function(val1, val2, FLAG1 | FLAG2)