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

Rick Mann rmann at latencyzero.com
Mon Aug 1 19:28:35 CDT 2016


It sure seems natural.

Is there some reason the language can't allow a sub-struct to add member variables, such that the whole is treated like a contiguous set of members?

In my case, I have a rect-like value type, but I'd rather it inherit from CGRect, rather than contain a CGRect. That makes it much more natural to use.

Is allowing that just too complicated, or does it create type safety issues?

-- 
Rick Mann
rmann at latencyzero.com




More information about the swift-users mailing list