Re: Swift enums and NSNotificationCenter
Re: Swift enums and NSNotificationCenter
- Subject: Re: Swift enums and NSNotificationCenter
- From: Jens Alfke <email@hidden>
- Date: Wed, 05 Aug 2015 17:14:09 -0700
> On Aug 5, 2015, at 5:00 PM, Rick Mann <email@hidden> wrote:
>
>> On Aug 5, 2015, at 16:57 , Charles Srstka <email@hidden <mailto:email@hidden>> wrote:
>>
>> I get that error any time I try to subclass *any* enum. I don’t think enums are supposed to be subclassable.
>
> Guess I'll submit a bug. Seems perfectly reasonable to do.
It’s part of the language design that only classes support inheritance, not structs or enums.
Basically, subclassing pass-by-value types is problematic. For example, what happens when you assign a SubclassStruct value to a variable of type BaseStruct, or pass it to a function parameter of type BaseStruct? Do the extra instance variables get chopped off when it’s copied? What happens if you call a BaseStruct method that was overridden in SubclassStruct?
C++ lets you do this, but it can lead to really nasty problems, so style guides like Effective C++ recommend avoiding it.
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden