String Interpolation

Imperatorn johan_forsberg_86 at hotmail.com
Thu Oct 26 07:56:14 UTC 2023


On Thursday, 26 October 2023 at 02:02:49 UTC, Jonathan M Davis 
wrote:
> On Wednesday, October 25, 2023 7:47:33 PM MDT Adam D Ruppe via 
> Digitalmars-d wrote:
>> On Thursday, 26 October 2023 at 00:24:33 UTC, Walter Bright 
>> wrote:
>> > The money shot:
>> >
>> > "The design of template expressions deliberately makes it 
>> > impossible to go directly from a string literal or text 
>> > block with embedded expressions to a String with the 
>> > expressions' values interpolated. This prevents dangerously 
>> > incorrect strings from spreading through a program."
>>
>> Yup. Even if we went with an object in D instead of a tuple, 
>> I'd be against the `alias toString this;` part. Just too much 
>> history saying that's a bad idea for D to embrace it at this 
>> point.
>
> Implicit conversions are fraught with dangers in general. 
> Sometimes, they're really useful to have, but they're often 
> problematic, and they're even more problematic in generic code. 
> So, they should be used with care, and IMHO, we should default 
> to avoiding them rather than adding them.
>
> - Jonathan M Davis

I'm just putting it here as an observation.

If D does not provide a way to implicitly get a string, it would 
be the *only* language that would do so.

All other languages with more than 10 users has a way to do that.

I even asked GPT-4 etc and it could not provide any examples of a 
language where you can't easily get a string from the expression 
or where it's the default.

As more or less the collective knowledge of humanity, maybe we 
should listen to it.

If we don't, it's more likely that we are wrong, not everyone 
else.


More information about the Digitalmars-d mailing list