As a side effect of SE-0110 tuple unsplating was removed from the language.
While this claims to make tooling like the type checker faster, it deals quite a blow to expressivity.
Filterting dictionaries is just an example and maybe not the best. However I hope the point gets across. Let's compare to other languages.
Examples of pattern matching in closure parameters:
let eighteenOrMore = ["Tom" : 33, "Rebecca" : 17, "Siri" : 5].filter { arg in
let (_, age) = arg // Awkward :| No tuple unsplatting
return age >= 18
}
// OR
// Still No tuple unsplatting
let eighteenOrMore = ["Tom" : 33, "Rebecca" : 17, "Siri" : 5].filter { $0.1 >= 18 }
// OR
// Somewhat better
let eighteenOrMore = ["Tom" : 33, "Rebecca" : 17, "Siri" : 5].filter {(arg: (name: String, age: Int)) in arg.age >= 18 }mapOf("Tom" to 33, "Rebecca" to 17, "Siri" to 5).filter({ (_, age) -> age >= 18 }){name: age for name, age in {'Tom': 33, 'Rebecca': 17, 'Siri': 5}.iteritems() if age >= 18 }{"Tom" => 33, "Rebecca" => 17, "Siri" => 5}.select{ |_, age| value >= 18 }filter (\(_,age) -> age>= 18) [("Tom", 33), ("Rebecca", 17), ("Siri", 5)](filter (fn [[_ age]] (>= age 18)) {"Tom" 33 "Rebecca" 17 "Siri" 5})List(("Tom" , 33), ("Rebecca", 17), ("Siri", 5)).filter{ case (_, age) => age >= 18}[("Tom", 33), ("Rebecca", 17), ("Siri", 5)].into_iter().filter(|&&(_, age)| age >= 18);Object.entries({Tom: 33, Rebecca: 17, Siri: 5}).filter(([_, age]) => value >= 18)[T || {_, Age} = T <- [{"Tom", 33}, {"Rebecca", 17}, {"Siri", 5}], Age > 18].(remove-if-not #'(lambda (x) (>= (cadr x) 18)) '(("Tom" 30) ("Rebecca" 17) ("Siri" 5)))
And as stated on Slack, I much prefer consistency over magic. So instead of going backwards and revoke SE-110, I'd much prefer going forward and make a new proposal to have a way for deconstructing tuples directly. For example I'd love to see a SE proposal to allow this kind of syntax, rather than reverting SE-110 (and bringing back ambiguous function calls if we revert it):
Which in fact is almost possible today, using:
So such a proposal would simple ad the ability to use anonymous arguments for deconstructing tuples.
This way, with that feature (and in addition of the extension on Dictionary I suggested above) we'd have (1) improved type checker performance (because we removed the ambiguity thanks to SE-110), (2) still nice syntax and call sites (thanks to proper variants of filter/forEach/map/flatMap/… functions on
Dictionary) and (3) still a way to deconstruct a tuple (but explicitly to keep consistency and avoid type-checker nightmare) easily if needs be (which again I don't believe will be used that much once we improvedDictionary'sfilter/forEach/map/flatMapsignatures, but at least if we do need that deconstruction for the 1% of remaining cases, we can)