[swift-users] Why can't structs inherit from other structs?
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...
More information about the swift-users