> To use a germane example, if unreachable code were always an error, a 
> programmer trying to
> debug a problem wouldn't be able to short-circuit a function by just adding a 
> return;

True, but

> they'd also have to comment out the rest of the function.

No, as you can do

  if (true) {
    return -1
  }

See clarifying reply on definition of "unreachable".

Returning to Charlie's reply:
> Similarly returning earlier. The warning is convenient as it warns you to 
> review that part
> before releasing the code to the public.

Since swift implements a warning for the if(true) or if(false) cases, we still 
get that, and without the cost of accepting code with a serious chance of being 
accidentally wrong.  I don't think anyone ever wrote if(true) or if(false) 
expecting some behavior other than what they wrote.

-- 
Peter Dillinger, Ph.D.
Software Engineering Manager, Coverity Analysis, Software Integrity Group | 
Synopsys
www.synopsys.com/software

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to