[swift-evolution] Please remove obscure "!" requirements for implicitly unwrapped optionals

Per Melin p at greendale.se
Sat Dec 5 08:41:44 CST 2015


On Sat, Dec 5, 2015 at 2:35 AM, Chris Lattner <clattner at apple.com> wrote:

> On Dec 4, 2015, at 5:00 PM, Per Melin <p at greendale.se> wrote:
>
> What surprised me was the IIUOs. I did not expect Swift to happily help me
> shoot myself in the foot quite so easily as this.
>
> func isNegative(i: Int?) -> Bool {
>     return i < 0
> }
>
> (No, I have never actually written code like this. I can't tell how likely
> it is that I would make this mistake.)
>
>
> This is a separate problem.  One of the things we plan to discuss (once
> things settle down a bit) is how to narrow the implicit conversion from T
> to T? in cases like this.  This implicit promotion, as well as the T <-> T!
> promotions are problematic in a number of ways, and we need a holistic
> solution to them.
>

I noticed that the promotion is recursive.

    let n: Int??? = 0
    true ? 4711 : n // => Optional(Optional(Optional(4711)))

Implicit promotions aside, what is the strong case for even having (T?, T?)
variants of the non-equatable comparable operators? I can see the
convenience when sorting optionals, but I must be missing something else?

Once everyone gets the bikeshedding over syntax out of their system,
hopefully the discussion can focus on more fundamental issues.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151205/b93fd62c/attachment.html>


More information about the swift-evolution mailing list