[swift-evolution] [Proposal] Add property for negation to Bool

Антон Миронов antonvmironov at gmail.com
Mon Jun 6 14:27:41 CDT 2016


I appreciate your support but looks like this proposal is going nowhere. This proposal affects fundamental habits that are very hard to argue with.
Never the less I will keep using this property in my code because my team is okay with it.

Thanks,
Anton Mironov

> 6 черв. 2016 р. о 21:42 Thorsten Seitz <tseitz42 at icloud.com> написав(ла):
> 
> That's just the way it was done in Smalltalk. Very readable IMHO as I'm not a fan of `!` either for the reasons you cited.
> 
>  -Thorsten 
> 
> Am 21.05.2016 um 16:50 schrieb Антон Миронов via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>>:
> 
>> I found negation operator (!) the least detectable among the code. So I’ve decided to add property “not” to BooleanType (Swift 2.2) or Boolean on 3.0 with extension:
>> 
>> extension BooleanType {
>> 	var not: Bool { return !self.boolValue }
>> }
>> 
>> This is code with negation operator:
>> 	return !self.lanes[position.y][currentLaneRange].contains(.Gap)
>> 
>> As I sad before negation operation is hard to spot. Moreover at first it looks like I’m trying to negate self for some reason.
>> 
>> This is code with “not” property:
>> 	return self.lanes[position.y][currentLaneRange].contains(.Gap).not
>> 
>> Now it is easy to spot the statement I am actually getting negation of.
>> On my experience negation operator can occasionally be missed while reading code. This happens less often with “not” property. So I’m proposing to add this property to standard library and prefer it in most cases.
>> 
>> Thanks,
>> Anton Mironov
>> 
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160606/1b0692ab/attachment.html>


More information about the swift-evolution mailing list