[swift-evolution] mandatory "?" suffix for identifiers associated with optional types

Kevin Ballard kevin at sb.org
Mon Dec 7 02:19:32 CST 2015


On Fri, Dec 4, 2015, at 09:30 AM, Amir Michail wrote:
>> On Dec 4, 2015, at 12:27 PM, Adrian Kashivskyy
>> <adrian.kashivskyy at me.com> wrote: I believe nil being less than
>> anything else is an expected behavior which has been introduced by
>> design.
>>
>
> It still leads to bugs that are hard to find though.
>
> In any case, I proposed using this code for such a comparison: let f
> = x? < 5

There's lots and lots of ways to write bugs in Swift. That's part and
parcel with being a programming language. I disagree that this is a
bug that's hard to find. Do you commonly write code where you don't
understand the types you're working with? If you don't know the types
you're working with, this isn't the only way to accidentally write a
bug that still compiles. Personally, I find the ability to compare
optionals to be very valuable, almost as valuable as the ability to
use == with optionals (which I doubt anyone will argue is a
misfeature). And I don't think I've ever accidentally compared an
optional with < without realizing it. I know, everybody is different,
but deliberate uglification of the language to solve a subjective
issue encountered by some people at the expense of readable code by
everyone else does not seem to me to be a reasonable tradeoff.
Especially since the proposed syntax here is extremely confusing; the
postfix-? already means something else (in fact, it means 3 different
things depending on context).

-Kevin Ballard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151207/549fe179/attachment.html>


More information about the swift-evolution mailing list