The rest look like they aren't worth complicating the language over. Consider:
map(\.name)
Isn't really more concise than map { $0.name }
There's one more character and the conventions for whitespace are different. Both require that you know special Swift syntax sugar features, but at least the second one is more generally useful. All we get here is a virtually identical way to do the same thing but with alternate arbitrarily different syntax.And what's better... this?
struct Dice {
var lowerBound: Int
var upperBound: Int
func callAsFunction() -> Int {
(lowerBound...upperBound).randomElement()!
}
}
let d6 = Dice(lowerBound: 1, upperBound: 6)
let roll1 = d6()
or this? struct Dice {
var lowerBound: Int
var upperBound: Int
func roll() -> Int {
(lowerBound...upperBound).randomElement()!
}
}
let d6 = Dice(lowerBound: 1, upperBound: 6)
let roll1 = d6.roll()
callAsFunction() makes it a little harder to relate the calling code to the implementing code -- you've got to internalize the new syntax-sugar rule -- and the calling code gets a little less clear in some cases.Default arguments to subscript functions is probably OK. It's better if all kinds of function have the same capabilities.