New function argument system

fn main() {
    println!("{}", sum(1, 1)); // 2
    println!("{}", sum(a: 1, b: 1)); // 2
    println!("{}", sum(b: 1)); // 1
    println!("{}", sum(a: 1)); // 1
}


fn sum(args: JustFuncArg) -> isize{
    args.a + args.b
}

struct JustFuncArg {
    a: isize,
    b: isize,
}

impl Default for JustFuncArg {
    fn default() -> Self {
        JustFuncArg {
            a: 0,
            b: 0,
        }
    }
}

Have you searched for prior art and discussion about this ("named arguments" would be a good search term)?

Other than that, I'm going to refrain commenting about the proposal itself as it would be good if you described how this is supposed to work and the motivation [1] instead of guessing how it is working and then discussing based on my interpretation of what your proposal is[2]. It really is best to be explicit so that everyone can start discussing the proposal instead of having dozens of messages to start off with to first discover that not everyone is even talking about the same thing.


  1. I know why I might want this, but I don't think you want me assuming that about your motivations. ↩︎

  2. I recommend starting out with the RFC template and filling out each section with at least something to start. ↩︎

6 Likes