[swift-evolution] Remove prefixes from all Apple frameworks
Adrian Zubarev
adrian.zubarev at devandartist.com
Thu Mar 30 16:07:13 CDT 2017
The issue is, this has nothing to do with swift evolution. You could file a bug report for the Apple frameworks, but I doubt something this huge will make it through.
--
Adrian Zubarev
Sent with Airmail
Am 30. März 2017 um 23:03:52, Louis D'hauwe via swift-evolution (swift-evolution at swift.org) schrieb:
Apple frameworks contain prefixes, carried over from Objective-C.
These exist to prevent class and method name collisions.
Mattt Thompson has a great article about this, containing the following brilliant excerpt:
"Namespacing is the preeminent bugbear of Objective-C. A cosmetic quirk with global implications, the language’s lack of identifier containers remains a source of prodigious quantities of caremad for armchair language critics." (http://nshipster.com/namespacing/)
Since Swift can handle with these naming conflicts, wouldn't it make sense to drop all framework prefixes in a Swift environment?
A classic example is UIKit, where all classes are prefixed with "UI".
Code example:
import UIKit
class FooViewController: UIViewController {
}
Dropping the prefix would simply lead to the following:
import UIKit
class FooViewController: ViewController {
}
Since conflicts need to be handled by specifying the module name, the following could be used if "ViewController" was also used by either some, other than UIKit, imported framework or by a user defined class:
import UIKit
class FooViewController: UIKit.ViewController {
}
"UIKit.ViewController" is of course quite longer than the current "UIViewController".
An improvement could be to allow frameworks to specify an abbreviated form.
UIKit could define "UI" as its abbreviation, making the following code valid:
import UI
class FooViewController: UI.ViewController {
}
This all seems to me like a natural continuation of SE-0086.
I do realise this would be a major change, breaking pretty much every Swift iOS, macOS, tvOS and watchOS project.
But in the long term, I think it's worth it.
– Louis D'hauwe
_______________________________________________
swift-evolution mailing list
swift-evolution at swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170330/b4f50eb4/attachment.html>
More information about the swift-evolution
mailing list