I feel like this increases the surface area of learning Swift quite heavily, as it's likely to become a (ab)used feature for aesthetic reasons. Maybe I'm just not used to it, but it seems to make following code difficult with a special-case syntax.
Does it actually need a new keyword call
rather than just allowing unnamed functions?
struct Adder {
var base: Int
func(_ x: Int) -> Int {
return base + x
}
}
or using self
/ Self
:
struct Adder {
var base: Int
func self(_ x: Int) -> Int { // instance method
return base + x
}
func Self(_ x: Int) -> Int { // class method
return base + x
}
}