[Pre-RFC] named arguments

So, having slept on this, I think that adding named args to function calls is probably the wrong thing to do. It is not the Rust way to add this kind of feature, we should instead be looking for orthogonal features that can provide similar benefits, and if necessary adding small amounts of syntactic sugar to make them more ergonomic.

We should start by looking at programming patterns that approximate what we want. Here that means passing structs. I think adding default fields to structs is a good start - that is useful in its own rights and gives us a nice way to approximate default function arguments.

Then, should we add sugar to make function calls more ergonomic? Anonymous structs are an obvious path here - they were found to not pull their weight in the past, but perhaps that should be re-visited in this context. Perhaps also (as suggested above) we could add sugar in function defs to elide the _: in some cases.

I’d be interested to hear other suggestions in similar directions for ways we can address the use cases here without adding a very specific feature to the language.

4 Likes