[swift-evolution] SE-0025: Scoped Access Level, next steps

Jordan Rose jordan_rose at apple.com
Mon Mar 28 16:26:10 CDT 2016


> On Mar 28, 2016, at 14:23, David Waite <david at alkaline-solutions.com> wrote:
> 
> 
>> On Mar 28, 2016, at 2:30 PM, Jordan Rose via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> P.S. Extensions do make things a little more complicated, but again, there's almost no precedent here, and pretty much everyone agrees that this new scope-private access level shouldn't give access to extensions. That also means there's an option to keep yourself from accidentally accessing scope-private members in a member type: put the member type in an extension.
> 
> The only example that comes to mind is Ruby, where I can add new methods to an existing class, and those new methods indeed have access to existing ‘private’ methods:
> 
> class A
>   private def foo()
>     puts “foo called”
>   end
> end
> 
> A.new.foo() # error
> 
> class A
>   def bar() # add new bar method
>     foo()
>   end
> end
> 
> A.new.bar() # prints “foo called”

Yeah, I tried to sweep that under the rug by noting that Ruby's definition of "private" didn't match up with either Java-private or current-Swift-private anyway, but it's true that someone coming from Ruby might expect this to work.

Jordan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160328/ca50d6c2/attachment-0001.html>


More information about the swift-evolution mailing list