[swift-evolution] [Pitch] Introducing the "Unwrap or Die" operator to the standard library

Erica Sadun erica at ericasadun.com
Tue Jun 27 15:17:53 CDT 2017


> On Jun 27, 2017, at 1:51 PM, Dave DeLong via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
>> On Jun 27, 2017, at 1:43 PM, Tony Allevato via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> I agree with Jaden and Xiaodi above—making Never a proper bottom type and using ?? would accomplish the same thing, and it's more general because it doesn't imply fatalError.
>> 
>> IMO, I don't think we should be making it *easier* to hide traps in our code. I don't think having to write a full guard/fatalError is all that bad a thing—on the contrary, I want major failure points to stick out when I read code. That being said, if some users want something like this, Never + ?? would get us there with something already planned for the language, rather than introducing a new operator (for which the bar should be set high).
> 
> I disagree that this is making hiding traps easier. It’s asking you to put in two exclamation points instead of only one to force unwrap, along with an explanation of why you think it’s ok to be doing so. That’s much more “in your face” than “array.last!”.
> 
> Dave

This ties in pretty closely with my goals for the "roles" proposal. I want Swift to evolve towards clarifying developer intent both for code inspection and compilation support.

I honestly wouldn't mind having both solutions available.

-- E
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170627/e4bc9d43/attachment.html>


More information about the swift-evolution mailing list