[swift-evolution] Make class and struct members private by default / Type-Based access

Ted F.A. van Gaalen tedvgiosdev at gmail.com
Thu Apr 6 06:25:13 CDT 2017


Hi David

jikes! You’re right, total blunder. I should do my homework better :o) 
I have been using Java before, be it with the assumption that it had private scope
for class members, because of the line of PLs I was using before I started using Java
I went on programming assuming that it had, which never led to scope conflicts because
of programming consequently within this assumption, so, I never noticed this. :o) 
 
This is because in most PLs in my history    Fortran -> Cobol-> PL/1 -> Pascal -> Modula ->
C -> C++ consistent lexical scope is present (since ca. 1960 with Algol)   
After that C# (nice language too, which has it)  and ObjC (which hasn’t) and Smalltalk for many years
which has (needs) no scope modifiers at all (in a class all methods are not private
but variables are.) 

Sorry for the incorrect assumptions. 
Nevertheless I hold on to my point of view that there should be lexical scope only in Swift,
(as Swift being a procedural/OOP language) 
however rigidly enforcing this in Swift 4 would be probably too much of a change now.

I do not understand what is so hard on private-by-default? (that is, if used
this way right from the beginning of writing an application, 
(provided a program language is set up that way)

TedvG
www.tedvg.com
> On 4. Apr 2017, at 22:17, David Waite <david at alkaline-solutions.com> wrote:
> 
> 
>> On Apr 4, 2017, at 7:07 AM, Ted F.A. van Gaalen via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> Hi Xiaodi,
>> 
>> that currently all members of a class or struct are exposed by default by having
>> a default scope of  ‘internal’  and are therefore accessible in the entire module
>> is imho very bad unstructured programming practice. 
>> 
>> In no other OOP language it is implemented
>> that way.. 
> 
> I think you may be forgetting Java (and Ruby, and Python, and Go, and Objective-C, and…)
> 
> In my experience , the hard-private-by-default comes from C++ and heavily influenced languages like C# and Rust.
> 
> -DW

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170406/13d90718/attachment.html>


More information about the swift-evolution mailing list