Optional explicit `self` parameter declaration in methods

I'm not really a fan of this pitch. The syntax looks clunky and ugly and I don't find the motivating examples very convincing.

Can you elaborate on this? To me,

func change(value: mutating Int) { ... }

doesn't look any worse than

func change(value: inout Int) { ... }

. In fact, I'd argue that the former is better because it's more clear about how it's related to the mutating function modifier (something that has caused confusion before).

As for __consuming/__owned, wouldn't consuming/consumed or owning/owned work just fine?

Wouldn't it be more clear if these two separate concepts had two separate keywords?

func (const self).doSomething(with parameter: const Int) const { ... } // the meaning of const isn't very clear in each of its positions.

const could denote constant values (including self), and something like consteval could denote constant-evaluable functions.


If we really do need this, I think func self.method(x: Int) { ... } would be the best spelling.

2 Likes