[swift-evolution] [Discussion] Here we go again: Extension Functions
brent at architechies.com
Mon Feb 29 17:38:15 CST 2016
> - I fear that this can be awfully confusing because there’s no indication on call site that the closure has a different `self`.
Personally, I wouldn't mind having the feature structured in the following fashion:
* You can use `self` as the internal name of any parameter to any function. (Though perhaps not in a method, which already has an implicit parameter with the internal name `self`.)
* If you do, that parameter is the receiver of all receiverless method calls.
* A closure with `self: T` in its parameter list is simply a hint to SourceKit that its code completion should name the parameter `self`.
That way, any closure which rebound self would be explicitly marked at the top with `self in`, and if you wanted to access the outer `self`, you could always simply give the parameter a different name.
This would add a small syntactic burden to uses of `with` and other DSLs, but it might be worth it to make the behavior explicit.
More information about the swift-evolution