[swift-users] Why can't Swift instance methods call class methods without qualification?
jens at mooseyard.com
Fri Jul 1 13:01:19 CDT 2016
> On Jul 1, 2016, at 10:28 AM, Nicholas Outram via swift-users <swift-users at 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!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-users