[swift-evolution] Remove (!) logical negation operator

Jordan Rose jordan_rose at apple.com
Tue Dec 15 14:33:12 CST 2015


Today &&, ||, (prefix) !, !=, and !== are not magic; they are just like every other operator. Adding user-overridable keyword operators would be a non-trivial change to the language.

(Everyone—nearly—keeps forgetting about != and !==. Replacing these with not(a == b) is not really a good answer.)

Jordan

> On Dec 15, 2015, at 12:13 , Rudolf Adamkovic via swift-evolution <swift-evolution at swift.org> wrote:
> 
> +1 for clean-up:
> 
> • "and" instead of && 
> • "or" instead of ||
> • "not" instead of !
> • if expressions instead of ?!
> 
> Easier to read, easier to type, easier to understand for beginners.
> 
> As a bonus, it doesn't look like optionals (less !s and ?s).
> 
> R+
> 
> Sent from my iPhone
> 
> On 15 Dec 2015, at 20:49, Sune Foldager via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> 
>> 
>>> On 15 Dec 2015, at 17:05, Tommy van der Vorst via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> 
>>> I *do* see negative effects of removing it: ! is part of virtually all programming languages currently in use, any decent programmer is accustomed to it and read it like 'not' in their head anyway. Removing would definitely confuse newcomers to the language. 
>> 
>> I completely agree. While it *is* a bit weird to use the same symbol for forced unwrap and its more traditional use as boolean negation, removing the one virtually all other languages have is not the answer. If we do that, why not also ~ for binary negation, || and && and even + and -.
>> 
>> It’s always a balance between verbosity, “natural language”-ness and terseness. It’s not always easier to read code that’s very verbose, and I’m sure we don’t want Swift to be like AppleScript.
>> 
>> -Sune
>> 
>> 
>> _______________________________________________
>> 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>
>  _______________________________________________
> 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/20151215/c53fa640/attachment.html>


More information about the swift-evolution mailing list