Thread overview
Want to try out string interpolation in D?
Oct 20, 2023
Imperatorn
Oct 20, 2023
Imperatorn
Oct 22, 2023
Imperatorn
Oct 23, 2023
matheus
Oct 23, 2023
Imperatorn
Oct 27, 2023
Imperatorn
October 20, 2023

Here's a script to get you started

git clone https://github.com/adamdruppe/dmd.git
cd dmd
git checkout interp
rdmd compiler/src/build.d

I don't want to copy files anywhere, so the user has to do that manually:

Copy dmd from the generated executable to your D bin installation folder

Example:

copy generated\windows\release\64\dmd.exe C:\d\dmd2\windows\bin64

Copy druntime/src/core/interpolation.d to your corresponding druntime folder + import

Example:

copy druntime/src/core/interpolation.d C:\d\dmd2\src\druntime\import\core\

Now try string interpolation:

import std.stdio;

void main()
{
	string name = "Johan";
	int age = 37;
	int iq = 8001;
	int coffees = 1000;

	writeln(i"Your name is $name and you're $age years old");
	writeln(i"You drink $coffees cups a day and it gives you $(coffees + iq) IQ");
}

Output:

Your name is Johan and you're 37 years old
You drink 1000 cups a day and it gives you 9001 IQ
October 20, 2023

On Friday, 20 October 2023 at 16:41:40 UTC, Imperatorn wrote:

>

Here's a script to get you started

git clone https://github.com/adamdruppe/dmd.git
cd dmd
git checkout interp
rdmd compiler/src/build.d

[...]

We just need support for it in the tools, then D will be a Dream come true

October 22, 2023

On Friday, 20 October 2023 at 16:41:40 UTC, Imperatorn wrote:

>

Here's a script to get you started

Same instructions for DIP1027:

git clone https://github.com/WalterBright/dmd.git
cd dmd
git checkout dip1027
rdmd compiler/src/build.d

Then same instructions as above but without the need to copy interpolation.d

October 23, 2023
On Friday, 20 October 2023 at 16:41:40 UTC, Imperatorn wrote:
> Here's a script to get you started
>...
> Now try string interpolation:
>
> ```d
> import std.stdio;
>
> void main()
> {
> 	string name = "Johan";
> 	int age = 37;
> 	int iq = 8001;
> 	int coffees = 1000;
>
> 	writeln(i"Your name is $name and you're $age years old");
> 	writeln(i"You drink $coffees cups a day and it gives you $(coffees + iq) IQ");
> }
> ```
>
> Output:
> ```
> Your name is Johan and you're 37 years old
> You drink 1000 cups a day and it gives you 9001 IQ
> ```

First of all thanks for writing this.

Well this seems pretty nice... What DIP number is this? - I'd like to read why it was rejected.

Matheus.
October 23, 2023
On Monday, 23 October 2023 at 11:12:20 UTC, matheus wrote:
> On Friday, 20 October 2023 at 16:41:40 UTC, Imperatorn wrote:
>> Here's a script to get you started
>>...
>> Now try string interpolation:
>>
>> ```d
>> import std.stdio;
>>
>> void main()
>> {
>> 	string name = "Johan";
>> 	int age = 37;
>> 	int iq = 8001;
>> 	int coffees = 1000;
>>
>> 	writeln(i"Your name is $name and you're $age years old");
>> 	writeln(i"You drink $coffees cups a day and it gives you $(coffees + iq) IQ");
>> }
>> ```
>>
>> Output:
>> ```
>> Your name is Johan and you're 37 years old
>> You drink 1000 cups a day and it gives you 9001 IQ
>> ```
>
> First of all thanks for writing this.
>
> Well this seems pretty nice... What DIP number is this? - I'd like to read why it was rejected.
>
> Matheus.

Which one did you try?

The first one is YAIDIP:
https://github.com/John-Colvin/YAIDIP

and the second one is DIP1027:
https://github.com/dlang/DIPs/blob/master/DIPs/rejected/DIP1027.md

Make sure you try them both

October 27, 2023
On Monday, 23 October 2023 at 11:43:33 UTC, Imperatorn wrote:
> On Monday, 23 October 2023 at 11:12:20 UTC, matheus wrote:
>> On Friday, 20 October 2023 at 16:41:40 UTC, Imperatorn wrote:
>>> [...]
>>
>> First of all thanks for writing this.
>>
>> Well this seems pretty nice... What DIP number is this? - I'd like to read why it was rejected.
>>
>> Matheus.
>
> Which one did you try?
>
> The first one is YAIDIP:
> https://github.com/John-Colvin/YAIDIP
>
> and the second one is DIP1027:
> https://github.com/dlang/DIPs/blob/master/DIPs/rejected/DIP1027.md
>
> Make sure you try them both

Note: The YAIDIP is now superseed by the 1036e.