[swift-dev] Possibility to makes classes partial as C# language

Kévin Machado machadokevin.dev at gmail.com
Thu Dec 10 03:07:38 CST 2015

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.


  // Common logic for bank model
  partial class Bank {

    var amount: Int

    init() {
        amount = 0

    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



We also could add more feature with the extension paradigm. Adding
properties, attributes and more directly on the *extension scope*.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20151210/519305fc/attachment.html>

More information about the swift-dev mailing list