Default Arguments and Label-based Overloading

This post is in response to Aria Beingessner’s “Defaults Affect Inference in Rust: Expressions Instead Of Types”, which describes how adding default arguments to Rust could help with some Rust stdlib problems around generics. At the same time, the Rust internals forum has a thread on “Named Arguments” something that’s been discussed for Rust off and on for years (at varying levels of seriousness).

Here I’m going to discuss how those two features interact, and why considering them separately is potentially a bad idea. It’s a lot more braindump-y than my usual style, so be warned. The post is written with a Rust audience in mind, but makes frequent reference to Swift, Python, and C# as examples of real-world languages that have some version of these features. It also overlaps quite a bit with Aria’s post.

Swift Regrets: Wrap-up

Thus ends five months of Swift regrets (and delights), things that I had been collecting during my last year at Apple…and things that came up during the ensuing discussion on Twitter. I wanted to talk about these things because every project learns from those that came before it, and that should include both the good parts and the bad parts. I have a memory of my former colleague Joe Groff saying that we should normalize and encourage talking about mistakes and missteps in our field, and so this is a contribution.

Swift History: Assignment Methods

Part of the Swift Regrets series.

Older Posts

  1. 2021-12-28 Swift Regret: inout Syntax
  2. 2021-12-26 Swift Delight: Optional Conveniences
  3. 2021-12-23 Swift Regret: try?
  4. 2021-12-21 Swift Delight: try
  5. 2021-12-17 Swift Regret: Operator Function Lookup Rules
  6. 2021-12-15 Swift Regret: "Double" rather than "Float64"
  7. 2021-12-10 Swift Delight: Implicit Member Syntax
  8. 2021-12-08 Swift Regret: Weak Vars in Structs
  9. 2021-12-03 Swift Regret: Lazy Vars in Structs
  10. 2021-11-30 Swift Delight: No Unused Results
  11. 2021-11-24 Swift Regret: Open Protocols
  12. 2021-11-21 Swift Regret: Retroactive Conformances
  13. 2021-11-18 Swift Delight: Library Evolution
  14. 2021-11-10 Swift Mangling Regret: Private Discriminators
  15. 2021-11-05 Swift Mangling Regret: The "Old" Mangling
  16. 2021-11-03 Swift Mangling Regret: Library Evolution
  17. 2021-10-29 Swift Delight: #available
  18. 2021-10-22 Swift Regret: Implicitly-Hashable Payloadless Enums
  19. 2021-10-20 Swift Regret: Top-Level Decls in Script Mode
  20. 2021-10-15 Swift Delight: Names for Generic Parameters
  21. 2021-10-13 Swift Regret: Generic Parameters Aren't Members
  22. 2021-10-08 Swift Regret: OpaquePointer
  23. 2021-10-06 Swift Regret: Unannotated C Enums
  24. 2021-10-01 Swift Delight: Value Semantics Collections
  25. 2021-09-29 Swift Delight: guard
  26. 2021-09-24 Swift Regret: Inferred Property Types
  27. 2021-09-22 Swift Regret: Implicit Optional Initialization
  28. 2021-09-17 Swift Regret: Subscript Trailing Closures
  29. 2021-09-15 Swift Regret: Subscript Argument Label Rules
  30. 2021-09-10 Swift Regrets
  31. 2021-09-10 Swift Regret: Unapplied Instance Methods
  32. 2021-09-08 Swift Regret: Bound Methods
  33. 2021-08-29 Swift Regret: Type-based Overloading
  34. 2021-08-25 Swift Regret: AnyObject Dispatch
  35. 2021-08-20 Swift Regret: Labeled Tuple Elements
  36. 2021-08-18 Swift Regret: Tuples and Argument Lists
  37. 2021-08-13 Swift Regret: Sequence
  38. 2021-08-11 Swift Regret: mutating Protocol Methods vs. Classes
  39. 2021-08-06 Swift Regret: NSUInteger
  40. 2021-08-04 Swift Regret: Protocol Syntax
  41. 2020-10-20 The Swift Runtime: Enums
  42. 2020-10-06 The Swift Runtime: Class Metadata Initialization
  43. 2020-09-29 The Swift Runtime: Class Metadata
  44. 2020-09-21 The Swift Runtime: Uniquing Caches
  45. 2020-09-14 The Swift Runtime: Type Metadata
  46. 2020-09-07 The Swift Runtime: Type Layout
  47. 2020-08-31 The Swift Runtime: Heap Objects
  48. 2020-08-26 Objective-Rust
  49. 2020-07-07 Suffusion: Playing with Filesystems
  50. 2020-05-24 ROSE-8 on Mac OS 9
  51. 2020-04-01 Swift on Mac OS 9
  52. 2019-11-01 Leaving Apple
  53. 2018-04-03 "FIXME" Doesn't Always Mean "Fix Me"
  54. 2018-02-26 Many-to-Many Protocols
  55. 2017-09-07 The New Kingdom of Nouns

Possibly Related Tags