Sunday, July 6, 2014

Swift Instance Methods Can Shadow Functions

Dan Wineman (via Twitter):

Swift allows you to call instance methods from other instance methods with no scope prefix, indistinguishably from function calls. This leads to the dangerous situation of function calls being shadowed when identically-named instance methods are added to a base class.

This seems like a really bad idea. In other areas, Swift adds more protections for this sort of thing.

1 Comment RSS · Twitter

I think this and a few other dangers are due to not having a fully fleshed out namespace. It's often hard to figure out what's really going on. Real namespaces and their enforcement would be quite nice.

Leave a Comment