Steve Klabnik recently wrote about named arguments, optional arguments, default arguments, function overloading, and why most of that design space has historically made him nervous in Rust.
I agree with Steve.
In fact, I think I agree slightly more s…
structSize {
width: u32,
height: u32,
}
fnresize(size: Size) {}
// No more arguing about argumentsletf: fn(Size) = resize;
But I would say that the original idea of applying wildly different functions depending on a flag shouldn’t be easily achievable, because it’s a bad idea a lot of times.
This one:
fn resize(width: u32, height: u32) {} fn offset(dx: u32, dy: u32) {} let f: fn(u32, u32) = if resizing { resize } else { offset };gets rewritten to something non-equivalent:
struct Size { width: u32, height: u32, } fn resize(size: Size) {} // No more arguing about arguments let f: fn(Size) = resize;But I would say that the original idea of applying wildly different functions depending on a flag shouldn’t be easily achievable, because it’s a bad idea a lot of times.