• 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: should computed properties be able to throw exceptions?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Swift: should computed properties be able to throw exceptions?


  • Subject: Re: Swift: should computed properties be able to throw exceptions?
  • From: Quincey Morris <email@hidden>
  • Date: Sat, 22 Aug 2015 01:13:25 +0000

On Aug 21, 2015, at 17:27 , Rick Mann <email@hidden> wrote:
>
> Just out of curiosity, should Swift allow property methods to throw exceptions? Seems like a reasonable thing to me, but I don't know what the ramifications are.

It seems to sit naturally in pure Swift syntax, so I wouldn’t be surprised if it shows up as a language feature before long. However, the drawback is that it’s not compatible with Obj-C-style methods. That’s because Obj-C properties have no mechanism for handling the transfer of control implied by Swift throw/try.

I’d recommend you try to avoid calling the Swift side “exceptions”. It’s error handling, and although it’s not completely unlike exception handling in other (non-Obj-C) languages, it’s treacherous to confuse the two when dealing with Obj-C.

_______________________________________________

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: should computed properties be able to throw exceptions?
      • From: Rick Mann <email@hidden>
References: 
 >Swift: should computed properties be able to throw exceptions? (From: Rick Mann <email@hidden>)

  • Prev by Date: Swift: should computed properties be able to throw exceptions?
  • Next by Date: Can't add computed property to NSURLSessionDownloadTask?
  • Previous by thread: Swift: should computed properties be able to throw exceptions?
  • Next by thread: Re: Swift: should computed properties be able to throw exceptions?
  • Index(es):
    • Date
    • Thread