[swift-evolution] Proposal: Initialization should not be required in precondition(false) case.
Thorsten Seitz
tseitz42 at icloud.com
Thu Feb 18 23:46:00 CST 2016
Not everyone knows about precondition() in the first place, so when he finds it he will probably find preconditionFailure(), too. On top of that the autocomplete will show it to him each time he starts to type precondition. Third it is a common pattern to provide a failure function, where one does not have to supply a false argument, e.g. In unit test assertions.
-Thorsten
> Am 18.02.2016 um 23:21 schrieb Amir Michail <a.michail at me.com>:
>
>
>> On Feb 18, 2016, at 4:52 PM, Thorsten Seitz <tseitz42 at icloud.com> wrote:
>>
>>
>>>> Am 12.02.2016 um 18:26 schrieb Amir Michail via swift-evolution <swift-evolution at swift.org>:
>>>>
>>>> How far would you require the compiler to go? precondition(2 < 1)?
>>>> precondition(someFunctionThatAlwaysReturnsFalse())?
>>>> precondition(isFermatsLastTheoremTrue())?
>>>
>>> Just “false”. Why would you write anything else?
>>
>> Why would you write anything else than preconditionFailure()??
>
> Everyone knows about “false” but not everyone knows about preconditionFailure().
>
>>
>> -Thorsten
>
More information about the swift-evolution
mailing list