[swift-evolution] [Review] Require self for accessing instance members
Nikolaj Schumacher
me at nschum.de
Wed Dec 16 15:44:08 CST 2015
-1 (in it’s current form)
I’m concerned about decreasing the signal/noise ratio.
The current way is similar to type inference. We can’t immediately see the type, but tool support makes it easy to retrieve the information if needed. And most of the time, i.e. when just scanning the code, there is simply less information to work through.
With less syntax, the code structure becomes clearer than when every second word is “self”.
As such, I don’t think the proposal in its current form fits well with Swift, which is very good at keeping code “to the point”.
I wonder if leaving out “self”, but keeping the dot would be a better alternative. There is precedent in Swift (c.f. enums), the dot is easier to ignore when skimming the code and it’s still immediately obvious when you want to know.
Ruby does something similar (using @) and it feels muss less heavy than “self.” in Objective-C while having most of the benefits. Any other single character would work, too, of course.
Example:
class Person {
var name: String = "David"
func foo() {
print("Hello \(.name)")
}
func bar() {
.foo()
}
}
I think the problem is significant enough that it might warrant *a* change to Swift, but not the proposed one. The costs are higher than the benefits compared to my current solution (which is very clear syntax highlighting).
I do question if the problem occurs frequently enough (or at all) when it comes to methods.
Nik
> On 16 Dec 2015, at 19:55, Douglas Gregor <dgregor at apple.com> wrote:
>
> Hello Swift community,
>
> The review of “Require self for accessing instance members” begins now and runs through Sunday, December 20th. The proposal is available here:
>
> https://github.com/apple/swift-evolution/blob/master/proposals/0009-require-self-for-accessing-instance-members.md <https://github.com/apple/swift-evolution/blob/master/proposals/0009-require-self-for-accessing-instance-members.md>
>
> Reviews are an important part of the Swift evolution process. All reviews should be sent to the swift-evolution mailing list at
>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
>
> or, if you would like to keep your feedback private, directly to the review manager.
>
> What goes into a review?
>
> The goal of the review process is to improve the proposal under review through constructive criticism and, eventually, determine the direction of Swift. When writing your review, here are some questions you might want to answer in your review:
>
> * What is your evaluation of the proposal?
> * Is the problem being addressed significant enough to warrant a change to Swift?
> * Does this proposal fit well with the feel and direction of Swift?
> * If you have you used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
> * How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
>
> More information about the Swift evolution process is available at
>
> https://github.com/apple/swift-evolution/blob/master/process.md <https://github.com/apple/swift-evolution/blob/master/process.md>
>
> Cheers,
> Doug Gregor
> Review Manager
>
> _______________________________________________
> swift-evolution-announce mailing list
> swift-evolution-announce at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution-announce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151216/3f61869d/attachment.html>
More information about the swift-evolution
mailing list