DIP 1027---String Interpolation---Community Review Round 1

aliak something at something.com
Mon Dec 16 13:59:45 UTC 2019


On Monday, 16 December 2019 at 12:43:04 UTC, Patrick Schluter 
wrote:
> On Monday, 16 December 2019 at 11:38:34 UTC, aliak wrote:
>> On Monday, 16 December 2019 at 11:08:00 UTC, Patrick Schluter 
>> wrote:
>>> [...]
>>
>> Exactly. And then explain why. And what is that thing on the 
>> right. And why is string assignment not working on an 
>> interpolated _string_?
>>
>>> [...]
>>
>> In any language, they can be assigned to strings.
>
> Not true for some languages I checked
>
> - C# and Kotlin do the resolution at runtime and the 
> interpolated string is not a string and has to be converted 
> with .toString which is equivalent in calling .format in D.
> - Rust and Java do not have interpolated strings
> - Swift I don't know. Looks powerful but in a whole different 
> difficulty level.

You can assign strings to interpolated strings in all these 
languages you mentioned that have interpolated string support

Kotlin:

var x = 3
var s: String = "$x" + "$x"

Swift:

let x = 3
let y: String = "\(x)"

C#
string n = "hello";
string x = $"{n}";


More information about the Digitalmars-d mailing list