This seems to retread the same ground as "Unwrap or die" pitch and rejected proposal SE-0217 circa 2018, and spin-off discussions that followed about ??
and Never
expressions like throws and fatalError
on the r.h.s.
Digging up my relevant 2¢ on this from one such spin-off thread: Make Never the bottom type - #34 by jpmhouston" (with new clarification/relevance in square brackets):
It makes sense to me that this operator is always [optional-]
value ?? value
. By permitting [throws on the r.h.s.] – statements really – with semantics that more aligns with a force unwrap, I think it would chip away at my mental models.[If
?? throw
becomes legal Swift] then I for one will be instead defining my own!!
operator as in SE-0217 so that I can use it in place of??
in those instances:
[rewriting the example to fit in the topic of this thread]
let x = y !! throw(MyError.missingThing)
Or when I'm feeling cheeky:
let x = y !! MyError.missingThing
(edit: and imagine "try" inserted somewhere appropriately above, thanks @christopherweems. I always forget "try" when there's no compiler to remind me)