> On Jun 29, 2017, at 7:35 PM, Yuta Koshizawa <[email protected]> wrote:
>
> "In -Ounchecked builds, the optimizer may assume that this function is never
> called. Failure to satisfy that assumption is a serious programming error.”
>
> Yes, and so the following `!!` can perform identically to `!` in -Ounchecked
> builds when it is inlined.
Yes, I guess I wasn’t clear. I mean that there’s no problem.
> public static func !!(optional: Optional, errorMessage:
> @autoclosure () -> String) -> Wrapped {
> precondition(optional != nil, errorMessage())
> return optional!
> }
>
> --
> Yuta
>
>
> 2017-06-29 6:42 GMT+09:00 Jaden Geller <[email protected]
> <mailto:[email protected]>>:
>
> > On Jun 28, 2017, at 7:47 AM, Erica Sadun via swift-evolution
> > <[email protected] <mailto:[email protected]>> wrote:
> >
> >
> >> On Jun 28, 2017, at 3:52 AM, Yuta Koshizawa via swift-evolution
> >> <[email protected] <mailto:[email protected]>> 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
> > [email protected] <mailto:[email protected]>
> > https://lists.swift.org/mailman/listinfo/swift-evolution
> > <https://lists.swift.org/mailman/listinfo/swift-evolution>
>
>
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution