Named and Optional Arguments are Awesome
Several programming languages make named and optional arguments easier to work with. Dart, for example, excels at named arguments, wrapping them in curly braces and allowing defaults. C# permits naming any parameter and assigning defaults to later ones. TypeScript, however, lacks a strong built-in syntax for named arguments, requiring workarounds with anonymous types and destructuring.
Rust, the focus of this post, currently lacks named arguments, making it hard to use them effectively. While some have attempted workarounds, they often prove cumbersome, especially for functions with many parameters. The proposal to ease Default trait implementation in Rust by adding special syntax for implementing it has been discussed, but may not fully solve the named arguments issue.
A closed RFC for structural records, allowing named fields in tuples, could improve the syntax, but Rust doesn't currently have overloads or default values for some parameters, limiting its usefulness. Overall, while some languages handle named and optional arguments better, Rust's current approach has its challenges.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.