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

Jaden Geller jaden.geller at gmail.com
Wed Jun 28 16:42:41 CDT 2017

> On Jun 28, 2017, at 7:47 AM, Erica Sadun via swift-evolution <swift-evolution at swift.org> wrote:
>> On Jun 28, 2017, at 3:52 AM, Yuta Koshizawa via swift-evolution <swift-evolution at swift.org> wrote:
>> Hi, I think it is an orthogonal issue if we need a new operator. It is
>> also possible to introduce an infix `!` for it.
>> I am sure that we do not need to avoid `precondition` as long as we
>> use it appropriately. It is useful to realize consistent behavior with
>> `Array`'s `subscript`, forced unwrapping `!`, `&+` and so on. In this
>> context, `precondition` does not mean a general word "precondition"
>> but the `precondition` function in the Swift standard library, which
>> is removed when -Ounchecked.
> How would the line run then? Would it simply act as a forced unwrapped under -Ounchecked? 

From the docs:

"In -Ounchecked builds, the optimizer may assume that this function is never called. Failure to satisfy that assumption is a serious programming error.”

Aka, v. bad things happen if the precondition does not hold.

> -- E
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

More information about the swift-evolution mailing list