• 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: Bindings in Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bindings in Swift


  • Subject: Re: Bindings in Swift
  • From: Quincey Morris <email@hidden>
  • Date: Sun, 10 Aug 2014 15:00:28 -0700

On Aug 10, 2014, at 14:39 , Roland King <email@hidden> wrote:

> I haven't yet understood why there are two different syntaxes for class/function generics, with the <X,Y,Z> syntax but protocols are unadorned but have associated types. Naively I would have expected both to look the same, with parameters in angle brackets

Well, the semantics *are* different. Each “parameterized” class is a different type, but all “parameterized” protocols (of the same name, I mean) are the same type. A while back I did start to consider what a "generic protocol” might mean, instead of a type-associated one, but my head immediately started to hurt.

> I think it's time to resurrect the Swift book and read the second 1/2 of it more slowly than I did the first time.

I wouldn’t hold out much hope. The book just skates over the surface. In particular, it seems to me that what it says about associated types in protocols is either pure nonsense, or is missing a couple of key facts.

[Specifically, I suspect that a ‘typealias’ in a protocol must either get bound to a specific auxiliary type in an inheritor of the protocol, otherwise it defaults to being bound to the inheritor’s type (i.e. ‘Self’). However, it looks to me that the specific binding is generally by inference, and so is indistinguishable syntactically from the default binding. The book describes one thing, but links to an example that shows the other.

There’s also something going on with the silly-looking generic specifier ‘<S: T where T == T>’ that appears in some of Swift’s internal class declarations, but it seems to be meaningful in relation to protocols in some non-obvious way.]

_______________________________________________

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: Bindings in Swift
      • From: Greg Parker <email@hidden>
References: 
 >Re: Bindings in Swift (From: Quincey Morris <email@hidden>)
 >Re: Bindings in Swift (From: Roland King <email@hidden>)
 >Re: Bindings in Swift (From: Quincey Morris <email@hidden>)
 >Re: Bindings in Swift (From: Roland King <email@hidden>)
 >Re: Bindings in Swift (From: Quincey Morris <email@hidden>)
 >Re: Bindings in Swift (From: Kyle Sluder <email@hidden>)
 >Re: Bindings in Swift (From: Roland King <email@hidden>)

  • Prev by Date: Re: Bindings in Swift
  • Next by Date: Re: True Type Fonts
  • Previous by thread: Re: Bindings in Swift
  • Next by thread: Re: Bindings in Swift
  • Index(es):
    • Date
    • Thread