> On Jul 1, 2016, at 11:01 AM, Jens Alfke via swift-users 
> <swift-users@swift.org> wrote:
> 
> 
>> On Jul 1, 2016, at 10:28 AM, Nicholas Outram via swift-users 
>> <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:
>> 
>> class methods may mutate "mutable static variables” (singletons), which are 
>> dangerous in multi-threaded code.
> 
> This is the same argument zh ao made. But instance methods may also mutate 
> static variables, so the fact that you’re calling a class method doesn’t make 
> the call any more dangerous.
> 
> Moreover, mutating instance variables can be just as dangerous for 
> multithreaded code (and is a more frequent source of bugs IMHO).
> 
> Really, the only significant difference is that a class method can’t modify 
> instance variables, so from that perspective it’s actually a bit safer than 
> an instance method call!

Though that isn’t strictly true for singleton patterns and other reasons why 
class variables might include references to instances.

I believe there’s real value in being explicit about referencing class members. 
 It helps both the reader of the code and it makes writing code with typical 
IDE conveniences like code completion less cluttered and more informative. 
Unfamiliar class methods won’t be included in lists of suggestions where they 
might look like they operate on the current instance.

Kate Stone k8st...@apple.com <mailto:k8st...@apple.com>
 Xcode Low Level Tools

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to