> On Jul 1, 2016, at 10:25 , Nicholas Outram <nicholas.out...@me.com> wrote: > > class methods may mutate "mutable static variables” (singletons), which are > dangerous in multi-threaded code. Having the class prefix is a reminder and > therefore requires additional synchronisation if it is to be invoked safely > from multiple threads.
As Jens was saying, an instance method can also mutate static variables, so they're just as "dangerous" as static methods. Being forced to prefix a static method call doesn't change that. Even the argument that an instance method could have the same name as a static method doesn't seem to hold water. In fact, it seems like a terrible idea to allow, but I just tested it, and it is allowed. The problem is, you can never be sure what was intended in the method two(), below: class Foo { class func one() { print("class one()") } func one() { print("instance one()") } func two() { one() } } I think instead, this should generate a warning that there are two methods with the same name, and that as written, the instance method is being called. If there were no instance method one(), it would be unambiguous. -- Rick Mann rm...@latencyzero.com _______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users