Feature request: Named parameter

I’ve been using Swift for a while. There’s one Swift language feature that I really want it to be on Pascal language. It’s named parameter. It really helps when you have a function that has many parameters with default value. I hope someday Oxygene will provide that feature.

Thank you.

Oxygene (and RemObjects C#) has had those since before Chris Lattner started having his first dream of Swift. :wink:

Check out the “Multi-part Method Names” section on https://docs.elementscompiler.com/Oxygene/Members/Methods/.

I’m sorry, but I don’t think “multi-part method names” is really similar to “named parameter” I’m talking about. Named parameter in Oxygene should be like this:

// method declaration
method m(i: integer := 0; s: string := ''; d: double);
begin
  // fill code here
end;

// method calling
m(s := 'text', 0.1);  // supply the s and d param
m(0.2);               // only supply the required d param

// supply all the params without proper order is fine,
// as long as the parameter name is given
m(d := 0.3, s := 'text', i := 3)

// supply param with similar variable name is fine,
// because the compiler knows what each means
var s := 'another text';
var d := 0.4;
m(s := s, d := d); 

In Swift, you can read about it here.

Yeah, well. they’re not :wink:

i know how named parameters work in Swift. we ship a Swift compiler. of course i know how named parameters work in Swift. but Swift isn’t Oxygene, and Oxygene uses a different syntax, has been since, again, years before Swift was even dreamt of. We’re not gonna change that on a whim…

Well, I thought Oxygene is the modern object Pascal dialect. IMO, named parameters is good for modern object Pascal language. It makes Oxygene safer, more expressive and elegant. That’s why I think it should be adopted into Oxygene. But, if you think Oxygene doesn’t need that, what can I say? :blush:

well it HAS them. it’s just not using the syntax you’d like it to have.