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

Ricardo Parada rparada at mac.com
Fri Dec 18 22:18:43 CST 2015


* What is your evaluation of the proposal?

Against.

I think cost of the proposed solution is greater than the benefit for a type of bug I have never encountered.


* Is the problem being addressed significant enough to warrant a change to Swift?

I think there are other ways to mitigate this kind of problem:

I would prefer syntax coloring to differentiate between local variables and properties.  I understand this may not work for the color blind and could easily be overlooked. 

A compiler warning when a local variable shadows a property could also help.  The programmer would have to prefix the variable with either self or local in order to squelch the warning, i.e. self.title for the property or local.title for the local variable that shadows the property.


* Does this proposal fit well with the feel and direction of Swift?

Swift is known for helping the programmer avoid making mistakes.  It is also known for being readable, concise and expressive.  This proposal is conflicting in that it may help the programmer avoid making this type of mistake but at the expense of making the language more verbose.

One of the many things I like about Swift is how much more concise and readable it is when compared to other languages.  I would like to keep it that way.


* If you have you used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?

I used Objective-C for 10 years since it was developed at NeXT.  I watched how Objective-C became more powerful but more verbose over the years.  I can see how how some developers switching to Swift have mentioned not wanting to go back.  

I have also used Java for about 15 years ever since WebObjects moved to Java.  I find Java sometimes verbose and repetitive.  I wished it had inferred typing.  In Java, a local variable may shadow an instance variable.  I do not recall ever seeing a bug that was a result of a name conflict between a local variable and an instance variable.  Even though I can use  this.foo in Java to reference an instance variable I don’t ever use it because I despise it.  It makes the code more verbose and more difficult to digest.  

I look forward to using Swift on the server side, but I want the language syntax to remain concise and expressive to prefer it over Java.


* How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

I’ve read the proposal and the comments in favor and against.  I have also read a lot of the comments in the email thread.  I also pictured how my code would change if the proposal were incorporated into the language and I did not like it.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151218/416d4806/attachment.html>


More information about the swift-evolution mailing list