On Jun 16, 2015, at 00:34 , Roland King <r...@rols.org> wrote:
> 
> I think Protocol Extensions are the power feature to Swift this year

Yes, though I’ve been trying to convert a fair-sized app, and I ran into a 
conceptual difficulty when a protocol has a Self constraint.

In essence, a Self constraint prevents a protocol from being used like a base 
class. This shows up quickly when (say) you try to construct a Set<MyProtocol> 
which is going to contain various types that are unified only by MyProtocol. 
The underlying Set class has to Hashable, which means its also Equatable, which 
has a Self requirement to ensure that two objects being compared by == are of 
the same type.

You’d see this problem with the example in that video if you tried to make the 
SegueIdentifier protocol Hashable or Equatable.

Other really good features: value-type programming, and the ‘guard’ statement, 
which is much better in use than you’d expect.

The other major problem I ran into — unrelated, but I’m mentioning it in case 
someone wants to jump in and tell me the easy way — is that I’m trying to use 
frameworks in order to break the project into modules so that I can use the 
access controls (private and internal) to keep implementation details of 
related groups of files out of the grasp of unrelated code. This is in a 
cross-platform (OS X, iOS) project with shared code. Since the different 
platforms need different frameworks, and the frameworks/modules have to have 
different names to tell them apart, I can’t share source code files across 
platforms because of the “import” statements. Maybe I’m missing something 
obvious here.

> And now I know what Kyle looks like too!

What’s the video?



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to