[swift-evolution] [Review] Require self for accessing instance members

Kenny Leung kenny_leung at pobox.com
Sat Dec 19 00:18:20 CST 2015


I know I’m responding to myself here, but a couple more points:

1. I’ve programmed in Objective-C for many years, and I don’t feel like I’ve used “self” all that often.

2. If we do enforce self, method cascading would mitigate some of the repetition.

-Kenny


> On Dec 18, 2015, at 9:52 PM, Kenny Leung via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> 	* What is your evaluation of the proposal?
> 
> +1 for it.
> 
>> 	* Is the problem being addressed significant enough to warrant a change to Swift?
> 
> Yes. I feel it makes things more correct.
> 
>> 	* Does this proposal fit well with the feel and direction of Swift?
> 
> Yes. One of Swift’s goals is to be clear in reading, and this makes it it readily explicit when an instance property or function is being referred to when reading over code.
> 
>> 	* If you have you used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
> 
> I prefer a shorter syntax, like Ruby’s @blah. It will serve the same purpose, and save some space and typing. In fact, I would prefer to have all scopes of variables decorated so you could tell them all at a glance:
>    - local variables have no decoration
>    - instance properties with @
>    - arguments with $
>    - statics, globals, etc…
>    - types that I have to worry about mutating because someone else might have a reference to it vs. ones that I don’t have to worry about. (I used to think this was structs vs classes, but after being on this list I’m not so sure…)
> 
>> 	* How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
> 
> I have read about half of the posts on this.
> 
> --------------------
> 
> Considering this makes me think - if self were not required:
> 
> you have a standalone function foo()
> 
> you also have an instance method foo()
> 
> If you have another instance method
> 
> func bar() {
>    //Could you ever call the standalone function foo?
>    foo()
> }
> 
> 
> -Kenny
> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list