Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-04 Thread Xiaodi Wu via swift-evolution
On Tue, Oct 4, 2016 at 7:16 PM, Kevin Ballard wrote: > On Tue, Oct 4, 2016, at 12:01 PM, Xiaodi Wu wrote: > > On Tue, Oct 4, 2016 at 1:49 PM, Kevin Ballard wrote: > > > On Tue, Oct 4, 2016, at 11:34 AM, Xiaodi Wu wrote: > > On Tue, Oct 4, 2016 at 1:06 PM, Kevin

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-04 Thread Kevin Ballard via swift-evolution
On Tue, Oct 4, 2016, at 12:01 PM, Xiaodi Wu wrote: > On Tue, Oct 4, 2016 at 1:49 PM, Kevin Ballard wrote: >> __ >> On Tue, Oct 4, 2016, at 11:34 AM, Xiaodi Wu wrote: >>> On Tue, Oct 4, 2016 at 1:06 PM, Kevin Ballard via swift-evolution >>> wrote: __

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-04 Thread Xiaodi Wu via swift-evolution
On Tue, Oct 4, 2016 at 1:49 PM, Kevin Ballard wrote: > On Tue, Oct 4, 2016, at 11:34 AM, Xiaodi Wu wrote: > > On Tue, Oct 4, 2016 at 1:06 PM, Kevin Ballard via swift-evolution < > swift-evolution@swift.org> wrote: > > > > On Tue, Oct 4, 2016, at 10:44 AM, Mark Lacey wrote: > > > On

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-04 Thread Kevin Ballard via swift-evolution
On Tue, Oct 4, 2016, at 11:34 AM, Xiaodi Wu wrote: > On Tue, Oct 4, 2016 at 1:06 PM, Kevin Ballard via swift-evolution evolut...@swift.org> wrote: >> __ >> >> On Tue, Oct 4, 2016, at 10:44 AM, Mark Lacey wrote: >>> On Oct 4, 2016, at 10:29 AM, Kevin Ballard via swift-evolution >>>

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-04 Thread Xiaodi Wu via swift-evolution
On Tue, Oct 4, 2016 at 1:06 PM, Kevin Ballard via swift-evolution < swift-evolution@swift.org> wrote: > On Tue, Oct 4, 2016, at 10:44 AM, Mark Lacey wrote: > > > On Oct 4, 2016, at 10:29 AM, Kevin Ballard via swift-evolution < > swift-evolution@swift.org> wrote: > > On Tue, Oct 4, 2016, at 10:28

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-04 Thread Robert Widmann via swift-evolution
It's an interesting idea that needs to be written down in a separate proposal and is tangentially related to the problem we are trying to solve here and now. It is trivial to define this operator and was suggested by Charlie as new API to be added to Optional the last time improving Optionals

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-04 Thread Joe Groff via swift-evolution
> On Oct 4, 2016, at 11:06 AM, Kevin Ballard via swift-evolution > wrote: > > On Tue, Oct 4, 2016, at 10:44 AM, Mark Lacey wrote: >> >>> On Oct 4, 2016, at 10:29 AM, Kevin Ballard via swift-evolution >>>

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-04 Thread Mark Lacey via swift-evolution
> On Oct 4, 2016, at 10:29 AM, Kevin Ballard via swift-evolution > wrote: > > On Tue, Oct 4, 2016, at 10:28 AM, Nate Cook wrote: >>> On Oct 3, 2016, at 5:49 PM, Kevin Ballard via swift-evolution >>> >

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-04 Thread Kevin Ballard via swift-evolution
On Tue, Oct 4, 2016, at 10:28 AM, Nate Cook wrote: >> On Oct 3, 2016, at 5:49 PM, Kevin Ballard via swift-evolution > evolut...@swift.org> wrote: >> >> On Mon, Oct 3, 2016, at 03:18 PM, Jordan Rose wrote: ... >>> We had this at one point, but we took it out because people would >>>

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-04 Thread Nate Cook via swift-evolution
> On Oct 3, 2016, at 5:49 PM, Kevin Ballard via swift-evolution > wrote: > > On Mon, Oct 3, 2016, at 03:18 PM, Jordan Rose wrote: >>> >>> ... >>> >> We had this at one point, but we took it out because people would forget to >> test the nil case. I think `?? ""` or

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-04 Thread Harlan Haskins via swift-evolution
I would say it's surprising if you don't expect the value to be optional. Swift is such that you can write very long programs without knowing yourself the static type of every variable. It just takes one Optional property of a non-optional struct passed into a string interpolation segment to

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-04 Thread Jeremy Pereira via swift-evolution
> On 3 Oct 2016, at 22:41, Kevin Ballard via swift-evolution > wrote: > > On Mon, Oct 3, 2016, at 10:52 AM, Harlan Haskins via swift-evolution wrote: >> Swift developers frequently use string interpolation as a convenient, >> concise syntax for interweaving variable

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Charlie Monroe via swift-evolution
> On Oct 4, 2016, at 3:57 AM, Robert Widmann via swift-evolution > wrote: > >> >> On Oct 3, 2016, at 9:54 PM, Kevin Ballard > > wrote: >> >> On Mon, Oct 3, 2016, at 06:49 PM, Robert Widmann wrote: >>> On Oct 3, 2016, at

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Robert Widmann via swift-evolution
Forgive me for mixing terminology from before stating “If you want the old behavior” and the like. What I meant is “If you want to silence the warning”. I should point out that it is just that: a warning. We specifically mention that we didn’t spring for a hard error because that would make

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Robert Widmann via swift-evolution
> On Oct 3, 2016, at 9:54 PM, Kevin Ballard wrote: > > On Mon, Oct 3, 2016, at 06:49 PM, Robert Widmann wrote: >> >>> On Oct 3, 2016, at 8:49 PM, Kevin Ballard via swift-evolution >>> > wrote: >>> >>> I assume you

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Kevin Ballard via swift-evolution
On Mon, Oct 3, 2016, at 06:49 PM, Robert Widmann wrote: > >> On Oct 3, 2016, at 8:49 PM, Kevin Ballard via swift-evolution > evolut...@swift.org> wrote: >> >> I assume you meant that as a reply to me? >> >> The problem is twofold: >> >> 1. Printing the value without adornment, or "nil" for nil, is

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Robert Widmann via swift-evolution
> On Oct 3, 2016, at 8:49 PM, Kevin Ballard via swift-evolution > wrote: > > I assume you meant that as a reply to me? > > The problem is twofold: > > 1. Printing the value without adornment, or "nil" for nil, is a very common > thing to want to do and we

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Kevin Ballard via swift-evolution
I assume you meant that as a reply to me? The problem is twofold: 1. Printing the value without adornment, or "nil" for nil, is a very common thing to want to do and we shouldn't have to write code like `\(x.map(String.init(describing:)) ?? "nil")` to accomplish it. 2. Due to the changes

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Robert Widmann via swift-evolution
Under our proposal you can return to the old semantics of printing nil with an explicit optional cast - one which we will offer to insert for you. Otherwise if you actually intend for a default value that value would have type Int, not String. Under the current regime if you want to print

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Charlie Monroe via swift-evolution
I've already suggested this quite some time back and was told that this doesn't need to go through evolution. It's filed here: https://bugs.swift.org/browse/SR-1882 Unfortunately, I haven't had time to look into it myself and I'm unlikely to have the

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Kevin Ballard via swift-evolution
On Mon, Oct 3, 2016, at 03:18 PM, Jordan Rose wrote: > >> On Oct 3, 2016, at 14:41, Kevin Ballard via swift-evolution > evolut...@swift.org> wrote: >> >> On Mon, Oct 3, 2016, at 10:52 AM, Harlan Haskins via swift- >> evolution wrote: >>> Swift developers frequently use string interpolation as a

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Jordan Rose via swift-evolution
> On Oct 3, 2016, at 14:41, Kevin Ballard via swift-evolution > wrote: > > On Mon, Oct 3, 2016, at 10:52 AM, Harlan Haskins via swift-evolution wrote: >> Swift developers frequently use string interpolation as a convenient, >> concise syntax for interweaving

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Kevin Ballard via swift-evolution
On Mon, Oct 3, 2016, at 10:52 AM, Harlan Haskins via swift-evolution wrote: > Swift developers frequently use string interpolation as a convenient, > concise syntax for interweaving variable values with strings. The > interpolation machinery, however, has surprising behavior in one > specific

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Mark Lacey via swift-evolution
> On Oct 3, 2016, at 2:12 PM, Harlan Haskins wrote: > > If you don't think this needs a proposal Well, that’s not up to me, so let’s wait until someone else chimes in. :) Mark > , then Robert has an implementation almost done. We could submit a PR later > today. >

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Robert Widmann via swift-evolution
Definitely right about that, the implementation took all of 10 minutes after extending the OptionalToAnyCoercionWalker. If you’ve got any comments, please let me know

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Harlan Haskins via swift-evolution
If you don't think this needs a proposal, then Robert has an implementation almost done. We could submit a PR later today. - Harlan > On Oct 3, 2016, at 4:06 PM, Mark Lacey via swift-evolution > wrote: > > >>> On Oct 3, 2016, at 11:26 AM, Joe Groff via

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Mark Lacey via swift-evolution
> On Oct 3, 2016, at 11:26 AM, Joe Groff via swift-evolution > wrote: > > >> On Oct 3, 2016, at 11:02 AM, Robert Widmann > > wrote: >> >> Because the initializer here doesn’t take Any, it takes . > > I

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Joe Groff via swift-evolution
> On Oct 3, 2016, at 11:02 AM, Robert Widmann wrote: > > Because the initializer here doesn’t take Any, it takes . I think there's a case to be made to generalize the 'Any' warning to Optional implicitly being deduced as a type variable binding in any unconstrained

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Keith Smiley via swift-evolution
+1 to this warning. We've been hit by this bug a bunch of times. Especially when optionality of properties have been in flux. Just yesterday: https://twitter.com/zefhous/status/782783999663943680 -- Keith Smiley On 10/03, Harlan Haskins via swift-evolution wrote: > Hey all, > > Julio

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Robert Widmann via swift-evolution
Because the initializer here doesn’t take Any, it takes . ~Robert Widmann > On Oct 3, 2016, at 2:00 PM, Harlan Haskins via swift-evolution > wrote: > > Unfortunately, Optional-to-Any does not currently hit this case because IIRC > it doesn't promote to Any in an

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Harlan Haskins via swift-evolution
Unfortunately, Optional-to-Any does not currently hit this case because IIRC it doesn't promote to Any in an interpolation segment. I tested this with a ToT build yesterday. - Harlan > On Oct 3, 2016, at 1:57 PM, Joe Groff wrote: > > We now emit a warning whenever an

Re: [swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Joe Groff via swift-evolution
We now emit a warning whenever an optional is used as an Any. I disagree that this should be an error, but it seems reasonable to warn (if we don't already thanks to the 'Any' warning). -Joe > On Oct 3, 2016, at 10:52 AM, Harlan Haskins via swift-evolution > wrote:

[swift-evolution] [Proposal draft] Disallow Optionals in String Interpolation Segments

2016-10-03 Thread Harlan Haskins via swift-evolution
Hey all, Julio Carrettoni, Robert Widmann, and I have been working on a proposal to mitigate something that's burned us all since Swift 1. We'd love some feedback! It's available here: https://gist.github.com/harlanhaskins/63b7343e7fe4e5f4c6cfbe9413a98fdd I've posted the current draft below.