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

2017-11-09 Thread Nathan Gray via swift-evolution
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, 20

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

2017-11-08 Thread Mike Kluev via swift-evolution
on Mon, 06 Nov 2017 14:33:44 -0800 Slava Pestov 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!) > always have a defau

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

2017-11-08 Thread Sebestyén Gábor via swift-evolution
Although I’m fine with the current behavior I’d go for the explicit init form. Swift promotes explicit value bindings avoiding surprises which I learnt to like. In Java private Optional var; field declaration without RHS simply gets inited with a null value and not the expected “none”. Really an

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

2017-11-08 Thread Slava Pestov via swift-evolution
> On Nov 7, 2017, at 11:22 PM, Howard Lovatt via swift-evolution > wrote: > > Not a big deal either way, but I prefer the 2nd (nil) form and therefore > would like to see the 1st form go. It would make Swift more consistent, > consider: > > let o: Int? // Looks like nil is assigned. > if so

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

2017-11-07 Thread Howard Lovatt via swift-evolution
Not a big deal either way, but I prefer the 2nd (nil) form and therefore would like to see the 1st form go. It would make Swift more consistent, consider: let o: Int? // Looks like nil is assigned. if someTest { o = 1 // Why isn't this an error? (OK I know why - but it looks odd.) } else {

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

2017-11-07 Thread Adrian Zubarev via swift-evolution
Same here, but I wouldn’t care much if it were gone. Am 7. November 2017 um 21:40:56, David Hart via swift-evolution (swift-evolution@swift.org) schrieb: Yeah, I use the first form constantly. > On 6 Nov 2017, at 23:33, Slava Pestov via swift-evolution > wrote: > > Hi all, > > Right now,

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

2017-11-07 Thread David Hart via swift-evolution
Yeah, I use the first form constantly. > On 6 Nov 2017, at 23:33, Slava Pestov via swift-evolution > 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 su

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

2017-11-06 Thread T.J. Usiyan via swift-evolution
I used the existence of the first one in my explanation of explain optionals. "There is a reasonable default value for an optional type. 'nothing'." TJ On Mon, Nov 6, 2017 at 6:52 PM, Slava Pestov via swift-evolution < swift-evolution@swift.org> wrote: > > > On Nov 6, 2017, at 4:29 PM, Kelvin Ma

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

2017-11-06 Thread Slava Pestov via swift-evolution
> On Nov 6, 2017, at 4:29 PM, Kelvin Ma wrote: > > hot take: i use the second one a lot but only because i always forget the > first one exists. So I type the = nil just to “be sure”. Yeah, that’s one of my arguments against having the feature, along with the simple fact that if the language

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

2017-11-06 Thread Jacob Williams via swift-evolution
> On Nov 6, 2017, at 5:29 PM, Kelvin Ma via swift-evolution > wrote: > > hot take: i use the second one a lot but only because i always forget the > first one exists. So I type the = nil just to “be sure”. > Same here! I just changed a bunch of code since I’d forgotten they were the same >

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

2017-11-06 Thread Kelvin Ma via swift-evolution
hot take: i use the second one a lot but only because i always forget the first one exists. So I type the = nil just to “be sure”. On Mon, Nov 6, 2017 at 4:33 PM, Slava Pestov via swift-evolution < swift-evolution@swift.org> wrote: > Hi all, > > Right now, the following two declarations are equiv

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

2017-11-06 Thread Slava Pestov via swift-evolution
It sounds like several people rely on this behavior and are actually aware that it exists, so I won’t pursue the issue further. Thanks for the feedback! > On Nov 6, 2017, at 3:07 PM, Alejandro Martinez wrote: > > I won’t complain a lot if it’s decided to be removed but I would prefer it to >

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

2017-11-06 Thread Alejandro Martinez via swift-evolution
I won’t complain a lot if it’s decided to be removed but I would prefer it to stay. I use it constantly. Sent from my iPad > On 6 Nov 2017, at 22:41, Jon Shier via swift-evolution > wrote: > >I use this on all of my mutable optional properties, when I have to use > them. It’s just that l

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

2017-11-06 Thread Jon Shier via swift-evolution
I use this on all of my mutable optional properties, when I have to use them. It’s just that little extra bit of code I don’t need to write, and it feels a lot like parameter defaults in use. By surface area, I assume you mean the fact that it’s an implicit behavior people may need to re

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

2017-11-06 Thread Matthew Johnson via swift-evolution
> On Nov 6, 2017, at 4:33 PM, Slava Pestov via swift-evolution > 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 Optiona

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

2017-11-06 Thread Adrian Zubarev via swift-evolution
Just a quick question for clarification. What will happen to these? Do we have to provide the default value ourselves? class ViewController : UIViewController {     @IBOutlet weak var view1: UIView?     @IBOutlet weak var view2: UIView! } Am 6. November 2017 um 23:33:51, Slava Pestov via swif

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

2017-11-06 Thread Slava Pestov via swift-evolution
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!) always have a default value of ‘nil’. This feature increases the surface area of the language fo