String Interpolation

Jonathan M Davis newsgroup.d at jmdavisprog.com
Wed Oct 25 11:40:15 UTC 2023


On Wednesday, October 25, 2023 3:55:13 AM MDT Imperatorn via Digitalmars-d 
wrote:
> On Wednesday, 25 October 2023 at 07:08:06 UTC, Walter Bright
>
> wrote:
> > On 10/21/2023 2:11 PM, Imperatorn wrote:
> >> Agreed. We need a better/simpler way to get the string from
> >> the expression without special syntax.
> >
> > ```
> > import std.format;
> > alias f = std.format.format;
> >
> > enum b = "betty";
> > pragma(msg, i"hello $b".f);
> > ```
>
> I get your point, however, it forces the user to import
> std.format in the entire codebase wherever a function takes or
> returns a string and the user wants to use string interpolation

That's what you have to do now anyway, and all string interpolation really
is is a way to do format with variable names thrown in the middle of the
string instead of %s.

- Jonathan M Davis





More information about the Digitalmars-d mailing list