[swift-evolution] Proposal: Re-instate mandatory self for accessing instance properties and functions (David Hart)

Jordan Rose jordan_rose at apple.com
Mon Dec 7 12:38:37 CST 2015


Without commenting on the rest of the proposal, Swift is not about verbosity. From the API Design Guidelines <https://swift.org/documentation/api-design-guidelines.html#fundamentals> on Swift.org:

• Clarity at the point of use is your most important goal. Code is read far more than it is written.

• Clarity is more important than brevity. Although Swift code can be compact, it is a non-goal to enable the smallest possible code with the fewest characters. Brevity in Swift code, where it occurs, is a side-effect of the strong type system and features that naturally reduce boilerplate.

I'd say the same should apply to the language itself.

Jordan

> On Dec 6, 2015, at 15:52, Yichen Cao via swift-evolution <swift-evolution at swift.org> wrote:
> 
> But swift is all about verbosity (with method naming and such brought from obj-c), having self is much clearer. 
> 
> Yichen
> 
> On Dec 7, 2015, at 06:55, Nick Shelley <nickmshelley at gmail.com <mailto:nickmshelley at gmail.com>> wrote:
> 
>> I like that self is only required in closures because it serves as a good reminder that there are memory and safety implications with using self in a closure, such as creating retain cycles or having the closure run after self has been deallocated.
>> 
>> I can't seem to find an official Apple Swift style guide, but github's (https://github.com/github/swift-style-guide <https://github.com/github/swift-style-guide>) suggests only using self in closures with the rationale: "This makes the capturing semantics of self stand out more in closures, and avoids verbosity elsewhere."
>> 
>> On Sat, Dec 5, 2015 at 3:16 AM, Yichen Cao <ycao at me.com <mailto:ycao at me.com>> wrote:
>> Teaching wise, its much less confusing for self to be required so students don't mix up instance properties and local vars. Especially when self is required in closures, it confuses students. If self is mandatory for all instance properties, it would be so much clearer and much easier to read.
>> 
>> Yichen
>> 
>>> On Dec 5, 2015, at 18:11, swift-evolution-request at swift.org <mailto:swift-evolution-request at swift.org> wrote:
>>> 
>>> Re: Proposal: Re-instate mandatory self for	accessing
>>>      instance properties and functions (David Hart)
>> 
>> 
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
>> 
>> 
>  _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151207/7a7e6a0a/attachment.html>


More information about the swift-evolution mailing list