[swift-evolution] (Pitch) Conformance Regions
Charles Srstka
cocoadev at charlessoft.com
Sun Apr 2 17:28:05 CDT 2017
Huge +1 in general, but with one exception:
> On Mar 30, 2017, at 12:07 PM, Ross O'Brien via swift-evolution <swift-evolution at swift.org> wrote:
>
> struct Foo
> {
> conformance Bar // or conformance Foo : Bar, but since the region is inside Foo that's redundant
> {
> var integer : Int // visible because Foo : Bar, at Bar's access level
>
> var counter : Int = 0 // only visible inside the conformance scope, because not declared in Bar
>
> func increment() // visible because Foo : Bar, at Bar's access level
> {
> counter += 1
> }
> }
> }
Making ‘counter’ private here without being annotated as such is just going to cause confusion. If a member is to be private to the conformance, it should have the ‘private’ keyword in front of it to make that clear. If we want to enforce that the only non-private members in the conformance should be members that actually go toward implementing the conformance, then we should just have the above generate a compiler error, with the fix-it being to add ‘private’ to the declaration.
Massive +1 otherwise.
Charles
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170402/068e651a/attachment.html>
More information about the swift-evolution
mailing list