Dear colleagues, In swift we are able to add extension of classes that allows us to add methods but we cannot add attributes, properties. C# language allows developers to make its *classes *partial*. It is possible to split the definition of class, struct or interface over two or more source files*.
Could we make swift able to do this stuff ? *Are you interested about this kind of feature ?* Proposed solution Add partial keyword to alert the compiler that this class is splited over one or more source files. *Example* // Common logic for bank model partial class Bank { var amount: Int init() { amount = 0 super.init() } func withdraw(amount amount: Int) { self.amount -= amount } } // Business logic for customer within bank model partial class Bank { unowned let owner: Customer init(customer: Customer) { self.owner = customer } func notifyCustomer() { // some code } } <https://github.com/djnivek/swift-evolution/blob/56929274a31ff58295841a74a1eb2ace9db3e428/proposals/0008-makes-swift-class-struct-definitions-partial.md#alternative-solution>Alternative solution We also could add more feature with the extension paradigm. Adding properties, attributes and more directly on the *extension scope*.
_______________________________________________ swift-dev mailing list swift-dev@swift.org https://lists.swift.org/mailman/listinfo/swift-dev