SE-0217 - The "Unwrap or Die" operator

I'm against the overall design of this proposal but I wouldn't say it's completely useless. In fact this proposal depends on the acceptance of SE-0215. If the mentioned proposal will be accepted then we know that we can add temporary solutions that can be removed later when Never becomes the bottom type. In that sense the current proposal already mentioned an alternative solution which with Never as the bottom type will eventually become valid.

I wouldn't want to see a new !! operator but I can accept an overload of the current ?? such as:

func ?? <T>(optional: T?, noreturn: @autoclosure () -> Never) -> T {
   switch optional {
   case .some(let value):
      return value
   case .none:
      noreturn()
   }
}

That said, I think we should reconsider the proposal and try to simplify it instead of bloating the standard library with new operators that would eventually fade with Never as the bottom type.

10 Likes