> On Feb 28, 2017, at 11:56 AM, Daryle Walker <dary...@mac.com> wrote:
> 
> The problem here is an interface mismatch where Swift has function 
> throw-ability status out-of-band from that function’s parameter list, while 
> Objective-C doesn’t.

Only at the syntax level. Under the hood it works basically the same way as 
Objective-C, with the error as a hidden ‘out’ parameter. (It pretty much has 
to, for interoperability purposes.)

So an init() method that throws is a different method with a different 
signature than one that doesn’t; the two aren’t type-compatible. And I don’t 
think the two can coexist in one scope, because they’d be ambiguous at the call 
site. So adding a throwing initializer to NSDocument would require removing the 
non-throwing one, which can’t be done for backward-compatibility reasons.

I’m sure there are some hacky special-case workarounds that could be done to 
make this work, if this were a really important aspect of the AppKit API. But I 
don’t think it is. It may be annoying that the common code shared between your 
initializers can’t throw, but there are simple workarounds.

—Jens
_______________________________________________

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