[swift-evolution] struct subtyping

James Campbell james at supmenow.com
Thu Mar 24 10:52:53 CDT 2016


Would love a way of extending an existing struct as a new type but it not
being related to the struct it extends.

Sort of like a mixin but for structs, so I could have:

struct Object {
let identifier: String
}

struct User: Object {

}

struct Tree: Object {
}

The last two structs get the identifier property "mixed" in but are unique
types :)

*___________________________________*

*James⎥Head Of CEO*

*james at supmenow.com <james at supmenow.com>⎥supmenow.com <http://supmenow.com>*

*Sup*

*Runway East *

*10 Finsbury Square*

*London*

* EC2A 1AF *

On Thu, Mar 24, 2016 at 2:16 PM, Tino Heth via swift-evolution <
swift-evolution at swift.org> wrote:

>
> > Could we accomplish something similar to `newtype` by making the
> `typealias` declaration more powerful?
> It's the first thing I tried, but afair someone from the Core Team opposed
> extending typealias - and I had to agree that an "alias" should be just a
> synonym.
> _______________________________________________
> 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/20160324/79b6b1bb/attachment.html>


More information about the swift-evolution mailing list