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

Maximilian Hünenberger m.huenenberger at me.com
Sun Mar 27 09:21:11 CDT 2016


I like the idea of protected (against extensions).
However this raises the question whether extensions are also extensions of scope.


Can "private(scope)" properties/functions be accessed from extensions?


In your case:
Is "protected" exactly like local? So it doesn't hide properties from extensions within the file?
By making "private" scope based it is less private than "protected" which doesn't feel right to me. (Assuming extensions extend scope)

In my opinion "protected" should protect against other scopes/classes. Leaving "private" file based.


Kind regards
- Maximilian

> Am 26.03.2016 um 08:14 schrieb Cheyo Ximenez via swift-evolution <swift-evolution at swift.org>:
> 
> I agree with Ross. Swift already redefined the common access modifiers meanings. 
> Why not use the word 'protected' to mean 'local'?
> 
> public
> internal
> private
> protected // Java got it wrong. :) This is "protected" against extensions.  
> 
>> On Mar 25, 2016, at 6:57 PM, Ross O'Brien via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> The specific meaning of 'public' and 'private' in programming languages refers to type-based symbol visibility. I'm thinking of C++, C#, Java and Objective C; their 'public' is Swift's 'internal'. They have no equivalent to Swift's 'public'. Swift has no equivalent to their 'private'.
>> 
>> Possibly my familiarity with other languages isn't broad enough, but this is why I haven't understood the idea that Swift's use of 'private' is "right" or "obvious". You learn Swift's meanings of these terms by coding in Swift, you don't learn these meanings anywhere else first.
>> 
>> To use a hopefully recognised example: an American who wants 'chips' wants what a Brit calls crisps; a Brit who wants chips wants what an American calls french fries. Which meaning of 'chips' is more intuitive? Answer: the one you grew up with.
>> 
>>> On Sat, Mar 26, 2016 at 1:10 AM, Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org> wrote:
>>> > all of these names (public, internal, private, local) have specific meaning in the context of computer languages.
>>> 
>>> Yes, `local` has a meaning, but that meaning is generally *not* that it's an access level. It usually has something to do with declaring variables inside a function.
>>> 
>>> For instance, Perl uses it to back up and restore a global variable. ML uses it to create a scope (roughly). Lua and Julia use it to declare lexical variables which are visible in enclosed scopes, which SE-0025's new access level is specifically *not* supposed to allow.
>>> 
>>> I don't know of any language where `local` is used as an access level. If you're aware of an analogous use in another language, I'd be interested to see it. But the examples I've found if anything *undermine* the suggestion that `local` would be a good keyword choice.
>>> 
>>> --
>>> Brent Royal-Gordon
>>> Architechies
>>> 
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution at swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>> 
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160327/7b87d2a7/attachment.html>


More information about the swift-evolution mailing list