[swift-evolution] struct subtyping

James Campbell james at supmenow.com
Thu Mar 24 12:36:53 CDT 2016


I was treating this as a Mixin.

So the property from Object is Mixed into Tree and User but it isn't a
Subclass so any comparison between the two isn't possible.

But on reflection you bring up a very valid point.

*___________________________________*

*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 5:34 PM, Tino Heth <2th at gmx.de> wrote:

> 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 :)
>
>
> Is unique meant so that User-Objects can't be used as "Object"-Object
> parameters?
> I'm asking because this might be the biggest source of confusion with
> struct inheritance:
> As the two "child-structs" don't add new data to their parent, they would
> (technically) be compatible — but this is fragile, so it might be
> preferable to "hide" polymorphism by default, and maybe add an annotation
> to explicitly allow that a sub-struct can be used as its parent type.
> @compatible(Float) struct SpecialFloat: Float...
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160324/41d75eea/attachment.html>


More information about the swift-evolution mailing list