# Named arguments increase readability a lot

**URL:** <https://internals.rust-lang.org/t/named-arguments-increase-readability-a-lot/12467>\
**Category:** language design\
**Created:** [May 31, 2020, 1:10pm UTC](https://internals.rust-lang.org/t/named-arguments-increase-readability-a-lot/12467 "2020-05-31T13:10:40Z")\
**Posts on this page:** 1\
**Showing post:** 55

<div class="post-metadata">

**Author:** ![CAD97](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/cad97/32/3460_2.png) [@CAD97](https://internals.rust-lang.org/u/CAD97)\
**Post date:** [June 7, 2020, 5:51pm UTC](https://internals.rust-lang.org/t/named-arguments-increase-readability-a-lot/12467/55 "2020-06-07T17:51:28Z")

</div>

> [@JanDiederich](#):
>
> Apply the "Named, non-optional, fixed order arguments" to whole new crates only. With this strategy newly written crates are using named arguments, but old crates don't get a confusing mix of old and new.

Big detail you've ignored here: how do you facilitate using a "named arguments edition" crate from a "no named arguments edition" crate?

(I believe one of the existing edition requirements is that it should be possible to write code that compiles without warnings on two adjacent editions, so a wholesale switch based on edition wouldn't be allowed per that guideline. But for the sake of the above question, I assume that's a solved problem via using rustfix to update and a system like Swift/ObjC to provide both the current "no named arguments" and a "named arguments edition" view of std.)

The easy example here is, again, `HashMap`. Currently, we have the construction functions `HashMap::new()`, `HashMap::with_capacity(usize)`, `HashMap::with_hasher(impl BuildHasher)`, and `HashMap::with_capacity_and_hasher(usize, impl BuildHasher)`.

With named arguments, I'd poentially expose these as `HashMap::new()`, `HashMap::with(capacity:usize)`, `HashMap::with(hasher:impl BuildHasher)`, and `HashMap::with(capacity:usize, hasher:impl BuildHasher)`.

If I write that API on edition20XX with named arguments, the crate still needs to be usable from edition2015 and edition2018.

You could just require me to provide the `with_capacity_and_hasher` name, but that's basically requiring everyone to write backcompat unique names that (trending towards) nobody will use, because for some reason the compiler doesn't use name mangling to handle that case? (From the POV of 20XX where nobody _really_ uses old editions anymore.)

This sounds perfectly fine if you don't care about current editions using future editions' crates (they should just upgrade!), but Rust _does_ care about that.

---

_[View the full topic](https://internals.rust-lang.org/t/named-arguments-increase-readability-a-lot/12467)._
