I have wanted this, usually when forwarding one set of arguments to another API where the “prepositiony” labels have run out (that is, we’re already past the first two or three arguments and now the clearest thing to write is a nouny label). I love it in Rust for field initialization, but tera’s example shows why we can’t just do it: it’d be ambiguous with having no label. This ambiguity would of course be even less common than the problem, but it can still come up, especially in a language that encourages you to think of different full names as different methods.
I’m sure I’ve seen people play with various more explicit syntaxes for this (e.g. :message) but none yet has really been convincing enough to say “yes, that would be a definite improvement while still being readable”).
Note so aesthetically pleasant but solves the above example when jibber without labels is introduced. And if another jibber with other labels is introduced compiler would start complaining forcing me to put argument names.
Agree, I think we're lacking a palatable solution rather than in disagreement that there is room for improvement.
@Jessy does make an intriguing point about stripping labels; personally, I find the explicit coercion to be still a bit verbose but one can do as follows:
let foo = ...
let bar = ...
let flibber = jibber
flibber(foo, bar) // Look ma, no labels!
Yet, it is different in case of a mutating method:
struct S {
mutating func jibber(foo: Int, bar: Int) {}
mutating func bibber() {
jibber(foo: 1, bar: 2)
(jibber)(foo: 1, bar: 2) // 🛑 Cannot reference 'mutating' method as function value
}
}