[swift-users] Why can't structs inherit from other structs?

Tino Heth 2th at gmx.de
Tue Aug 2 22:44:23 CDT 2016

> I thought the problem with struct polymorphism (specifically the stack size issue) *was* the fundamental reason we can’t have “substructs”.
As I said:
I guess this is the reason we don't have "substructs" now — but inheritance can be useful without polymorphism:
Imagine an application that managers data of customers and employees.
It would be reasonable to model those data-containers as structs, and as both structs share many properties, a "person"-type would be quite convenient, even if it is not possible to create collections which contain customers as well as employees*.


* yes, an embedded "address"-struct would be an alternative — but copy & paste or writing everything in assembler is an alternative as well ;-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160803/1472fc7e/attachment.html>

More information about the swift-users mailing list