• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Swift enums and NSNotificationCenter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Swift enums and NSNotificationCenter


  • Subject: Re: Swift enums and NSNotificationCenter
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 06 Aug 2015 17:55:09 +0000

On Aug 6, 2015, at 09:20 , Jens Alfke <email@hidden> wrote:
>
> You can't do that, because instances of the subclassed enum won’t be valid instances of the super-enum.

I’m not sure that subclassing is what’s being asked for here.

It seems like it would be useful to be able to define a new enum that has the same cases as an existing enum plus some more cases. These two enums would be separate types, so there’s no confusion. The only special relationship is that (perhaps) it would be legal to assign a variable of the original enum to a variable of the derived enum, since the cases would correspond, but this would be resolved at compile time, not run time.

On Aug 6, 2015, at 10:38 , Rick Mann <email@hidden> wrote:
>
> But we need some kind of extensible way of defining a set of valid selectors

Possibly, but carrying selectors forward into Swift’s future seems like a bad idea. Selectors are an ambiguous way to refer to methods, and that has some advantages as well as some disadvantages.

Swift has better mechanisms for most things that selectors are used for, such as closures and partial method application, not to mention enums with associated values. The only real “poor fit” I’ve found so far is that you can test selectors for equality, but there’s no == (or ===) operator for closures. As it happened, the micro-redesign I had to do to solve that produced a much better solution overall.

_______________________________________________

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


  • Follow-Ups:
    • Re: Swift enums and NSNotificationCenter
      • From: Rick Mann <email@hidden>
References: 
 >Swift enums and NSNotificationCenter (From: Rick Mann <email@hidden>)
 >Re: Swift enums and NSNotificationCenter (From: Charles Srstka <email@hidden>)
 >Re: Swift enums and NSNotificationCenter (From: Rick Mann <email@hidden>)
 >Re: Swift enums and NSNotificationCenter (From: Charles Srstka <email@hidden>)
 >Re: Swift enums and NSNotificationCenter (From: Rick Mann <email@hidden>)
 >Re: Swift enums and NSNotificationCenter (From: Jens Alfke <email@hidden>)
 >Re: Swift enums and NSNotificationCenter (From: Rick Mann <email@hidden>)
 >Re: Swift enums and NSNotificationCenter (From: Uli Kusterer <email@hidden>)
 >Re: Swift enums and NSNotificationCenter (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: Swift enums and NSNotificationCenter
  • Next by Date: Re: Swift enums and NSNotificationCenter
  • Previous by thread: Re: Swift enums and NSNotificationCenter
  • Next by thread: Re: Swift enums and NSNotificationCenter
  • Index(es):
    • Date
    • Thread