This pitch is good, but should at least come with a caveat about this spelling. Outside of a function, it would be a protocol extension.
fileprivate extension Abstraction {
var impl: ResultType { // β¦
}
Without nested protocol extensions , switching to the function form will be necessary, trading good spelling for good scoping. So I don't think this pitch should be implemented without being paired with nested extensions.
This is a tiny syntactic sugar pitch.
Swift's ability to group code by use of extension is probably one of the best features of Swift and something Apple themselves use a lot , combined with Swift's ability to nest types these two language features make up the backbone of what we love about Swift.
Today extensions are limited to global scope, I cannot extend a nested type within an extension of the enclosing parent type. This makes code hard to read, I would argue.
Simple case study (sorry forβ¦