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 regret: inout syntax— Jordan Rose (@UINT_MIN) December 28, 2021
Swift has a notion of inout parameters, which are formally copy-in/copy-out (or perhaps move-in/move-out), and optimized to by-ref when possible. This is written `inout Foo` in the parameter type…and `&foo` at the call site.
Part of the Swift Regrets series.
- 2021-12-26 Swift Delight: Optional Conveniences
- 2021-12-23 Swift Regret: try?
- 2021-12-21 Swift Delight: try
- 2021-12-17 Swift Regret: Operator Function Lookup Rules
- 2021-12-15 Swift Regret: "Double" rather than "Float64"
- 2021-12-10 Swift Delight: Implicit Member Syntax
- 2021-12-08 Swift Regret: Weak Vars in Structs
- 2021-12-03 Swift Regret: Lazy Vars in Structs