Feature request: Named parameter

I would like to start a new thread on this feature request from Bee: Feature request: Named parameter

In the last post, Marc says “well it HAS them. it’s just not using the syntax you’d like it to have.”.

But the current implementation with “Multi-part Method Names” has many differences against “named parameters”:

  1. They are only available when the method is defined with multi-part names, so we can’t use them with methods we don’t write ourself, such as SDK methods.
  2. The first parameter can’t be named.
  3. The order of the parameters can’t be changed.

So, it I define the following method:

class method DoSomething (Param1 : Int32 := 1, Param2 : Int32 := 2, Param3 : Int32 := 3);

I should be able to call it with the following syntaxes:

DoSomething (1, 2, 3);
DoSomething Param1 (1) Param2 (2) Param3 (3);
DoSomething (1) Param3 (3);  // Param2 has default value
DoSomething (1) Param2 (2);  // Param3 has default value
DoSomething Param3 (3) Param1 (1) Param2 (2);  // changes parameters order

Named parameters have three benefits:

  1. To be able to skip a parameter in the middle of the list (if default values specified).
  2. To be able to name all the parameters. Useful if many parameters of the same type to avoid an error in parameter placement.
  3. To be able to get rid of parameter order.

We already have


so I dont think we need two competing syntaxes for providing named parameters.

As stated in my text, there are differences between named parameters and how multi-part method names are currently implemented.

I’m not asking for a new syntax, but to use the same syntax with more possibilities, look at the examples at the end of the post.

Right, and as stated in my reply, I dont believe we need to (whether slightly different or not) ways to handle this. We won’t change this, sorry.