String Interpolation

Imperatorn johan_forsberg_86 at hotmail.com
Fri Oct 27 14:22:14 UTC 2023


On Friday, 27 October 2023 at 12:55:35 UTC, Arafel wrote:
> On 27/10/23 13:59, Imperatorn wrote:
>> [...]
>
> Not possible. A string in D is just another name (literally, 
> just an alias) for an array of immutable chars. So there is no 
> string class, and no constructor to speak of, other than the 
> generic array constructor.
>
> Technically, the best solution would probably be to return a 
> (templated) struct with an "alias this" to the already 
> interpolated string, and all other interpolation information 
> also included, so functions would be able to choose what to 
> accept.
>
> But "alias this" is just a way to have implicit casting, and 
> that's something (probably rightly) opposed here on principle, 
> so I don't think we'll be having it anytime soon.

I don't mean any of those solutions. I mean that it would do what 
C# does for example.


More information about the Digitalmars-d mailing list