Why are still no named arguments passed?

I've some function with a large amount of parameters - some of them optional.

My suggestion - allow named parameters like this:

f(arg0: "hello", arg4:[0, 4], /*arg5*/ 5)

The just of it is using the same syntax for object literals plus the extension that a following argument can be passed directly occupying the next parameter spot.

I'm also interested what are the steps to rise this proposal to the right place so it could eventually get accepted?

I've looked at this non-intuitive solution here. And also at this proposal here.

Why nothing has budged yet?

I'd guess that's because passing around options objects is a good-enough solution already.

Well for one the other syntax is ugly. Furthermore you can't mix ordered arguments with it.

I don't know what's not to like about this, which seems to do both positional and named arguments and default values for all of them:

function f(a,b,c,{d='3',e='4',f='5',g='6'}={}) {
  return a + b + c + d + e + f + g
}
f('0','1','2',{f:'hi'}) => "01234hi6"
f('0','1','2') => "0123456"
1 Like

You have to specify the named arguments by their identifiers and the ordered by their order - you can't do for example:

f('0','1','2',{f:'hi', '7'})

to specify the g argument.

Additionally the curly braces are ugly.

I don't see a reason not to include my proposed shorthand except by true stubbornness.