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

Brent Royal-Gordon brent at architechies.com
Thu May 19 20:00:22 CDT 2016


> I'm posting this on behalf of Dmitri Gribenko, and Max Moiseev, and
> myself.
> 
> We would like to accept the proposal with one modification: rather than
> add an argument label, we'd like to drop the String initializer
> altogether, making `"\(expression)"` the standard way to get a string
> representation of `expression`.

Given how complicated the StringInterpolationConvertible protocol is, I'm not sure it's a good idea to invoke all of that machinery merely to convert an expression to a string. I mean, you end up with code like:

	String(stringInterpolation:
		String(stringInterpolationSegment: ""),
		String(stringInterpolationSegment: expression),
		String(stringInterpolationSegment: "")
	)

That seems like a lot of code to generate for such a simple task.

(And you can have those empty segments over my dead body—they're very important to a lot of interpolation use cases, because they allow you to distinguish between the literal and interpolated segments. If you want to design a different mechanism that's more efficient and equally capable, well, I'm happy to talk about improving StringInterpolationConvertible any time you are, but it'll definitely be opening a can of worms.)

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list