[swift-evolution] Proposal: Initialization should not be required in precondition(false) case.

Jordan Rose jordan_rose at apple.com
Fri Feb 12 11:59:31 CST 2016

> On Feb 12, 2016, at 9:45 , Amir Michail via swift-evolution <swift-evolution at swift.org> wrote:
>> On Feb 12, 2016, at 12:41 PM, Ross O'Brien <narrativium+swift at gmail.com <mailto:narrativium+swift at gmail.com>> wrote:
>> I have a suggestion.
>> Suppose we think of 'switch' as being like a non-optional type. The compiler does its thing and tries to ensure that the switched expression will match something, and enforces a default if it cannot verify a matching state.
>> Could we force the switch? i.e. suffix the 'switch' keyword with an exclamation mark, to say: the programmer insists that one of these cases will match; there's no need for a default case, but if nothing matches then crash.
> This doesn’t solve the more general problem — namely, that of required deep knowledge of the standard libraries.
> A more general solution would be to provide a way for API writers to issue (heuristic) warnings for suboptimal usage of their APIs.

This is a good observation. I think it deserves its own design and its own thread, though.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160212/74d8ec57/attachment.html>

More information about the swift-evolution mailing list