Here’s some Rust code: In programming language jargon, we call x and y parameters and 5 and 6 arguments . Rust does not have many fancy features related to…
Default/optional arguments: can be confusing when the default value is initialized.
Yeah, which especially becomes an issue in languages with poor mutability controls. Probably the most benign variant of argument defaults would be restricting them to being const, or at the very least immutable including internal mutability. Instead we have situations like in Python where it’s necessary for linters to warn people that setting [] or some other mutable data structure as a default is a bad idea (e.g. B006).
There’s also the issue that API designers may not want their parameter names to be part of the API
Yeah, this is also something of a mixed bag, where
there are some cases where having the parameter name as part of the API is desirable,
e.g. if some parameter position both before and after a change is a T, but it’s used for different purposes,
though it is unclear whether that can’t always be better covered by using the type system better;
while in most cases being locked out of doing some trivial renaming for whatever purpose (like s/blacklist/blocklist/) because it would break clients is just a PITA.
I wrote in another comment that I was partial to named arguments out of habit, but the more I think on it, I wonder if it’s not mostly a tool to work around missing type information and bad APIs, which, uh, may not be the most desirable thing to add to Rust.
Yeah, which especially becomes an issue in languages with poor mutability controls. Probably the most benign variant of argument defaults would be restricting them to being
const, or at the very least immutable including internal mutability. Instead we have situations like in Python where it’s necessary for linters to warn people that setting[]or some other mutable data structure as a default is a bad idea (e.g. B006).Yeah, this is also something of a mixed bag, where
T, but it’s used for different purposes,s/blacklist/blocklist/) because it would break clients is just a PITA.I wrote in another comment that I was partial to named arguments out of habit, but the more I think on it, I wonder if it’s not mostly a tool to work around missing type information and bad APIs, which, uh, may not be the most desirable thing to add to Rust.