[swift-evolution] [Review] SE-0089: Renaming String.init<T>(_: T)

Kevin Ballard kevin at sb.org
Fri May 20 19:28:25 CDT 2016


On Fri, May 20, 2016, at 05:14 PM, Dave Abrahams via swift-evolution wrote:
> 
> on Fri May 20 2016, Kevin Ballard <swift-evolution at swift.org> wrote:
> 
> > On Tue, May 17, 2016, at 08:32 PM, Chris Lattner via swift-evolution wrote:
> >> 	* What is your evaluation of the proposal?
> >
> > I'm a little nervous about this change, because converting things to
> > strings is a fairly basic operation and it should be immediately
> > obvious how to do that. That said, the described issues are pretty
> > bad, and I know I've had to carefully triple-check sometimes to make
> > sure I was calling the right initializer. So I'm +1 on the idea.
> >
> > That said, I don't like the name String(printing:). As others have
> > pointed out, it sounds like this is related to print(), but this
> > initializer does not actually print anything, it just converts any
> > value into a string. I also don't like String(describing:) because
> > it's too long. This initializer should be easier to call than
> > String(reflecting:). Also, in my experience this initializer is
> > particularly useful with code of the form `someOpt.map(String.init)`,
> > and saying `someOpt.map(String.init(describing:))` is annoyingly long.
> >
> > Given this, I'd like to suggest the simpler `String(from:)`. It's
> > short and generic, and it makes sense as it creates a String from any
> > value.
> 
> Not too bad.  I could live with it.

😀

> > I'm also not a fan of Dave's suggestion of removing this initializer
> > entirely in favor of "\(foo)".  This feels weird, and it also can't be
> > turned into a first-class function value.
> 
>   { "\($0)" }
> 
> ?

Good point. I think what I intended to express was you cannot refer to this operation by name anymore. Maybe not a big deal, but it feels weird.

-Kevin Ballard


More information about the swift-evolution mailing list