[swift-evolution] [Review] SE-0005 Better Translation of Objective-C APIs Into Swift
michel.fortin at michelf.ca
Fri Feb 5 10:54:48 CST 2016
Le 5 févr. 2016 à 7:14, David Hart via swift-evolution <swift-evolution at swift.org> a écrit :
> I agree with most of the proposal except for "Strip the "NS" prefix from Foundation APIs”. I strongly disagree with this change for the same reasons as Nate:
> - This change will make Foundation types look Swift native enough to confuse some users between the stdlib’s value semantics and Foundation’s reference semantics.
> - The change will complicate the creation of a Swift native foundation that uses the power of Swift to provide true value semantics to types that need them (URL, Data, CountedSet, etc…)
But there are also many classes that make perfect sense in Swift as a class: URLSession, Formatter, UndoManager, UserDefaults, XMLParser, Stream, NotificationCenter, RunLoop, etc. What we could do is decide now which Foundation classes should stay classes and which should become structs. Remove the NS prefix from the former, keep it for the later.
Eventually, classes such as NSCountedSet and NSIndexSet will have a proper struct wrapper that will claim the non-prefixed name. But there is no urgency in making those wrappers ready for Swift 3 because the class remains available.
Anyway, that's what I'd propose. There aren't that many classes in Foundation; cases like this can be sorted out manually.
More information about the swift-evolution