> On Jun 28, 2017, at 6:03 AM, Erica Sadun via swift-evolution 
> <swift-evolution@swift.org> wrote:
> 
> In general, does everyone prefer `?? () -> Never` or `!! () -> Never`? I can 
> argue both ways, with the goal in reading code as "unwrap or die".
> 


Personally, I strongly prefer `foo !! "explanation"` over `foo ?? 
fatalError()`. I don’t think adding another operator for what is a very common 
need is a concern, and is easier to read at a glance than the ??/fatalError 
combo.  There is a bit of cognitive dissonance between ??, a normally-fluffy 
nonthreatening defaulting operator, and fatalError, a scary beware operator. 
`!!` OTOH matches `!` in clearly flagging the unwrap as unsafe and that your 
program will exit. I also think it would be easier to explain `!!` to beginners 
as part of a wider story explaining optionals in general, unwraps, what `nil` 
means and what `!` means etc. Whereas `foo ?? Never` requires a lot of heavy 
lifting to understand how/why it works – we might all understand it, but that 
understanding is built on a lot of foundational understanding.

I also think a `Never` type would be very useful. Just that for this particular 
case, `!!` is still worth adding too.


_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to