5 ms·
I don't understand why pretty much no language does that these days. I think the argument is that your IDE should do this, and it does in some cases, but still.
by baby 6y ago
I don't understand why pretty much no language does that these days. I think the argument is that your IDE should do this, and it does in some cases, but still...
- chmod775 6y agoYou can get a much more powerful alternative for "free" if you support de-structuring assignments (in arguments). JavaScript Example: function test({a,b,c}) { console.log(c,b,a) }; test({ a: 1, b: 2, c: 3 }); If you have this there's really no need for named arguments anymore. If you add features to your de-structuring, your "named arguments" will have them too (things missing for JS specifically: optional objects, TS support to specify types for the destructured objects inline instead of repeating the entire thing).
- TekMol 6y agoIt is not more powerful. You cannot do this for example: function hello($name='Joe',$title='dear') { echo "Hello $title $name"; } hello('Sue'); Try here: https://3v4l.org/6MZHh https://3v4l.org/6MZHh With your object properties approach, you always have to use the variable "names".
- bmn__ 6y agoMixing implicit positional and named parameters is a misfeature. The named parameters should have a distinct syntax like other systems do, e.g. :$ twigil.
- ptx 6y agoPython, Kotlin and C# all support named arguments, and they're pretty popular languages. And also... there's Visual Basic.
- Okawari 6y agoI guess you can add dart and maybe ruby and elixir if you accept that they treated as a map/keyword list on the receiving end of the function. Edit: Ruby apparently made them first class citizens back in 2014. Ive been oblivious to this for years... wow.
- Can_Not 6y agoCrystal supports named arguments.