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

Xiaodi Wu xiaodi.wu at gmail.com
Sun May 22 16:12:48 CDT 2016


Fun as this conversation is, replacing "!" with "not" and other related
changes ("&&" replaced with "and", etc.) represent a commonly proposed and
rejected change
<https://github.com/apple/swift-evolution/blob/master/commonly_proposed.md>,
and the rationale is given here
<https://lists.swift.org/pipermail/swift-evolution/2015-December/000032.html>
.


On Sun, May 22, 2016 at 1:15 PM, Dave Abrahams via swift-evolution <
swift-evolution at swift.org> wrote:

>
> on Sat May 21 2016, Антон Миронов <swift-evolution at swift.org> wrote:
>
> > 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
>
> I think having the “not” up at the front of the boolean condition is
> useful.  Think about why this joke works:
>
>     “I'm a big fan of reference semantics...           NOT!”
>
> --
> -Dave
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160522/ee20c2a7/attachment.html>


More information about the swift-evolution mailing list