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

Amir Michail a.michail at me.com
Fri Feb 12 11:40:38 CST 2016


> On Feb 12, 2016, at 12:32 PM, Chris Lattner <clattner at apple.com> wrote:
> 
> On Feb 12, 2016, at 9:27 AM, Amir Michail <a.michail at me.com> wrote:
>>>> 
>>>> What’s wrong with having the compiler explicitly check for “false”?
>>> 
>>> Weird special cases make the compiler less predictable.
>> 
>> True, but not having them requires deeper knowledge of the standard libraries.
>> 
>> In practice, just checking for “false” would solve this problem.
> 
> That is not what you’re actually proposing.  You are proposing that the compiler encode special knowledge of the precondition *library function* into the compiler, and teach it about a single special case.  We don’t like the compiler to have special cases like this for a large number of reasons, in particular, if we did this, someone would file a bug asking for *their* equivalent reimplementation of precondition to have the same magic blessed behavior. 
> 

What about having the compiler issue a warning pointing you to preconditionFailure whenever it sees precondition(false)?

> This is a slippery slope that leads to a lot of complexity downstream, it is better to keep the compiler simple and predictable.  Also, as other people have pointed out, this has already been solved for you: just use preconditionFailure.
> 
> -Chris



More information about the swift-evolution mailing list