[swift-evolution] Pitch: Remove default initialization of optional bindings

Nathan Gray n8gray at n8gray.org
Thu Nov 9 18:32:49 CST 2017


On the other side, I'd say requiring explicit initialization to nil
increases the amount of busywork for the programmer for no good reason.  I
use it all the time and I would be pretty annoyed if it went away.  I would
be pretty shocked if most Swift users don't know that exists.

On Mon, Nov 6, 2017 at 2:33 PM, Slava Pestov via swift-evolution <
swift-evolution at swift.org> wrote:

> Hi all,
>
> Right now, the following two declarations are equivalent:
>
> struct S {
>   var x: Int?
> }
>
> struct S {
>   var x: Int? = nil
> }
>
> That is, mutable bindings of sugared optional type (but not Optional<T>!)
> always have a default value of ‘nil’. This feature increases the surface
> area of the language for no good reason, and I would like to deprecate it
> in -swift-version 5 with a short proposal. Does anyone feel strongly about
> giving it up? I suspect most Swift users don’t even know it exists.
>
> Slava
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>



-- 
Functional Programmer, iOS Developer, Surfs Poorly
http://twitter.com/n8gray
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171109/b3796e48/attachment.html>


More information about the swift-evolution mailing list