[swift-evolution] [Draft] Fix ExpressibleByStringInterpolation

Brent Royal-Gordon brent at architechies.com
Thu Mar 9 20:18:06 CST 2017

...is the title of a proposal I wrote today. The full proposal is available at:


But the tl;dr is that, if you write this:

	"Hello, \(name)!"

Instead of generating this:

		.init(stringInterpolationSegment: .init(stringLiteral: "Hello, ")),
		.init(stringInterpolationSegment: name),
		.init(stringInterpolationSegment: .init(stringLiteral: "!"))

We should generate this:

		.init(stringLiteral: "Hello, "),
		.init(stringInterpolationSegment: name),
		.init(stringLiteral: "!")

I actually have an implementation of it, available here:


But I'm literally messing with the constraint generator the very first time I modify the compiler, so I'm assuming it'll need some serious code review before it actually gets pulled in. (All the regular tests *do* at least pass.)

Despite the word "fix" in the title, this really only does half the job; I think we also need to tackle string formatting, at least by adding a mechanism, if not by settling on exact APIs. The proposal includes a sketch of my thoughts about that as well.

Comments extremely welcome.

Brent Royal-Gordon

More information about the swift-evolution mailing list