you are viewing a single comment's thread
view the rest of the comments
[–] 4 points 6 months ago

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)
  • source