Jump to page: 1 210  
Page
Thread overview
Interpolated strings
Apr 15, 2017
Jonas Drewsen
Apr 15, 2017
cym13
Apr 15, 2017
Stanislav Blinov
Apr 15, 2017
Jonas Drewsen
Apr 15, 2017
cym13
Apr 16, 2017
Russel Winder
Apr 15, 2017
cym13
Apr 15, 2017
Stanislav Blinov
Apr 15, 2017
cym13
Apr 18, 2017
Walter Bright
Apr 18, 2017
Jacob Carlborg
Apr 18, 2017
Kagamin
Apr 18, 2017
Jonathan Marler
Apr 18, 2017
H. S. Teoh
Apr 18, 2017
Faux Amis
Apr 19, 2017
Walter Bright
Apr 19, 2017
Nick Treleaven
Apr 19, 2017
Jonas Drewsen
Apr 19, 2017
Stefan Koch
Apr 19, 2017
Jonas Drewsen
Apr 19, 2017
Stefan Koch
Apr 19, 2017
Jonas Drewsen
Apr 19, 2017
Meta
Apr 19, 2017
Jonathan Marler
Apr 19, 2017
Patrick Schluter
Apr 19, 2017
H. S. Teoh
Apr 19, 2017
Adam D. Ruppe
Apr 21, 2017
Nick Treleaven
Apr 15, 2017
Adam D. Ruppe
Apr 16, 2017
Stanislav Blinov
Apr 17, 2017
Jonas Drewsen
Apr 15, 2017
crimaniak
Apr 15, 2017
Jonas Drewsen
Apr 17, 2017
Jacob Carlborg
Apr 17, 2017
crimaniak
Apr 17, 2017
Jonas Drewsen
Apr 20, 2017
Kagamin
Apr 20, 2017
Kagamin
Apr 21, 2017
Nick Treleaven
Apr 15, 2017
Jack Stouffer
Apr 15, 2017
Jonas Drewsen
Apr 15, 2017
Xinok
Apr 15, 2017
Jonas Drewsen
Apr 16, 2017
Dmitry Olshansky
Apr 16, 2017
Jacob Carlborg
Apr 17, 2017
Jonas Drewsen
Apr 17, 2017
Jonathan M Davis
Apr 17, 2017
Jonas Drewsen
Apr 18, 2017
Jacob Carlborg
Apr 18, 2017
Stefan Koch
Apr 18, 2017
Jacob Carlborg
Apr 18, 2017
bpr
Apr 19, 2017
Walter Bright
Apr 19, 2017
bpr
Apr 19, 2017
Jacob Carlborg
Apr 19, 2017
jmh530
Apr 19, 2017
Jacob Carlborg
Apr 19, 2017
H. S. Teoh
Apr 17, 2017
Kapps
Apr 20, 2017
Atila Neves
Apr 20, 2017
Adam D. Ruppe
Apr 20, 2017
H. S. Teoh
Apr 21, 2017
Nick Treleaven
Apr 21, 2017
Gary Willoughby
Apr 21, 2017
Gary Willoughby
Apr 21, 2017
ketmar
Apr 21, 2017
Anonymouse
Apr 21, 2017
bitwise
Apr 21, 2017
Kapps
Aug 24
Suliman
Aug 25
Seb
Aug 24
Biotronic
Apr 18, 2017
Walter Bright
Apr 19, 2017
Jonas Drewsen
Apr 19, 2017
Walter Bright
Apr 19, 2017
Walter Bright
Apr 19, 2017
Jon Degenhardt
Apr 20, 2017
Faux Amis
April 15, 2017
Hi all

  I've been wanting to have support for interpolated strings in D for some time now that will allow you to write e.g.:

auto a = 7;
writeln( $"{a} times 3 is {a*3}" );

Code speaks louder that words so I've made a PR that adds this support to ddmd as a RFC [1].

The compiler will basically lower the $"..." string to a mixin that concatenates
the expression parts of the (inside the {}) and the plain text parts.

I do recognize that this is not part of the 2017 H1 plan but I also believe such smaller improvements added regularly can make the language both more productive and attractive.

In case this addition gets a thumbs up I will of course improve test coverage and any needed quality of implementation.

[1] https://github.com/dlang/dmd/pull/6703

April 15, 2017
On Saturday, 15 April 2017 at 20:04:13 UTC, Jonas Drewsen wrote:
> Hi all
>
>   I've been wanting to have support for interpolated strings in D for some time now that will allow you to write e.g.:
>
> auto a = 7;
> writeln( $"{a} times 3 is {a*3}" );
>
> Code speaks louder that words so I've made a PR that adds this support to ddmd as a RFC [1].
>
> The compiler will basically lower the $"..." string to a mixin that concatenates
> the expression parts of the (inside the {}) and the plain text parts.
>
> I do recognize that this is not part of the 2017 H1 plan but I also believe such smaller improvements added regularly can make the language both more productive and attractive.
>
> In case this addition gets a thumbs up I will of course improve test coverage and any needed quality of implementation.
>
> [1] https://github.com/dlang/dmd/pull/6703

This has been proposed before, and I still don't see the added value compared to:

    auto a=7;
    writeln(a, " times 3 is ", a*3);

besides adding compiler complexity, language complexity and parsing complexity which leaves room for more bugs to be invented. I'm a bit more harsh than I could be, but if this simple question has no clear answer I don't see why it sould make it into the language.
April 15, 2017
On Saturday, 15 April 2017 at 20:12:41 UTC, cym13 wrote:
> On Saturday, 15 April 2017 at 20:04:13 UTC, Jonas Drewsen wrote:

> This has been proposed before, and I still don't see the added value compared to:
>
>     auto a=7;
>     writeln(a, " times 3 is ", a*3);
>
> besides adding compiler complexity, language complexity and parsing complexity which leaves room for more bugs to be invented. I'm a bit more harsh than I could be, but if this simple question has no clear answer I don't see why it sould make it into the language.

Try a different context:

auto a = 7;

import std.format;
auto str = format("%s times 3 is %s", a, a*3);

//or

import std.conv;
auto str = text(a, " times 3 is ", a*3);

//or

auto str = $"{a} times 3 is {a*3}";
April 15, 2017
On Saturday, 15 April 2017 at 20:04:13 UTC, Jonas Drewsen wrote:
> The compiler will basically lower the $"..." string to a mixin that concatenates
> the expression parts of the (inside the {}) and the plain text parts.
It's easy implementable as a library (see https://github.com/Abscissa/scriptlike#string-interpolation) so it does not seem like a good idea to modify the language, only to change interp!"" to $"".
April 15, 2017
On Saturday, 15 April 2017 at 20:20:49 UTC, Stanislav Blinov wrote:
> On Saturday, 15 April 2017 at 20:12:41 UTC, cym13 wrote:
>> On Saturday, 15 April 2017 at 20:04:13 UTC, Jonas Drewsen wrote:
>
>> This has been proposed before, and I still don't see the added value compared to:
>>
>>     auto a=7;
>>     writeln(a, " times 3 is ", a*3);
>>
>> besides adding compiler complexity, language complexity and parsing complexity which leaves room for more bugs to be invented. I'm a bit more harsh than I could be, but if this simple question has no clear answer I don't see why it sould make it into the language.
>
> Try a different context:
>
> auto a = 7;
>
> import std.format;
> auto str = format("%s times 3 is %s", a, a*3);
>
> //or
>
> import std.conv;
> auto str = text(a, " times 3 is ", a*3);
>
> //or
>
> auto str = $"{a} times 3 is {a*3}";

Yes this is a very basic lowering. The value comes from the fact (assumption?) that this pattern of constructing a string from a mix of strings and expressions is very common. The value of a feature could be described as

usage * productivity_improvement = feature_value

So while the productivity_improvement may be modest the usage is high enough to give a high feature_value and justify the addition. A sign of this is the number of other popular languages supporting this feature (not arguing for just copy other languages but it is still an indicator). Unfortunately I have no hard data for these numbers.















April 15, 2017
On Saturday, 15 April 2017 at 20:35:56 UTC, crimaniak wrote:
> On Saturday, 15 April 2017 at 20:04:13 UTC, Jonas Drewsen wrote:
>> The compiler will basically lower the $"..." string to a mixin that concatenates
>> the expression parts of the (inside the {}) and the plain text parts.
> It's easy implementable as a library (see https://github.com/Abscissa/scriptlike#string-interpolation) so it does not seem like a good idea to modify the language, only to change interp!"" to $"".

Lowerings are by definition possible to implement in a library.

Using that argument foreach (i; 0..100) {} should not be part of the
language even though I think very few would live without foreach.



April 15, 2017
On Saturday, 15 April 2017 at 20:04:13 UTC, Jonas Drewsen wrote:
> ...

First, there's a process for language additions, please see https://github.com/dlang/DIPs/blob/master/README.md

Secondly, I can tell you that any proposal that can be solved via the standard library has a very low chance of being accepted. D is  already a complex language and it would take a important problem in order to  justify making it more complex.

As this is already do-able via Phobos, I would personally vote no to this addition.
April 15, 2017
On Saturday, 15 April 2017 at 20:04:13 UTC, Jonas Drewsen wrote:
> Hi all
>
> <snip>

I shared my thoughts on such a feature just a couple weeks ago:

https://forum.dlang.org/post/oedeijdewmhazaqazdyo@forum.dlang.org
April 15, 2017
On Saturday, 15 April 2017 at 20:57:33 UTC, Jack Stouffer wrote:
> On Saturday, 15 April 2017 at 20:04:13 UTC, Jonas Drewsen wrote:
>> ...
>
> First, there's a process for language additions, please see https://github.com/dlang/DIPs/blob/master/README.md
>
> Secondly, I can tell you that any proposal that can be solved via the standard library has a very low chance of being accepted. D is  already a complex language and it would take a important problem in order to  justify making it more complex.
>
> As this is already do-able via Phobos, I would personally vote no to this addition.

Thank you.

I have been following the forums for many years so am aware of the
process and chances of something like this getting in.

For that exact reason I wanted to do a minimal implementation to show that I'm serious
and a RFC. Doing a DIP is a lot of work that I'm only willing to use my time on if
I have some confidence that it will not be in vain. I will do the DIP if this ever
gets a thumbs up.


April 15, 2017
On Saturday, 15 April 2017 at 21:03:27 UTC, Xinok wrote:
> On Saturday, 15 April 2017 at 20:04:13 UTC, Jonas Drewsen wrote:
>> Hi all
>>
>> <snip>
>
> I shared my thoughts on such a feature just a couple weeks ago:
>
> https://forum.dlang.org/post/oedeijdewmhazaqazdyo@forum.dlang.org

Most of you points applies to std.conv.text as well don't they?

If you need special output buffers or memory management then use the tools right for that. This is about making the common case easier and keep the uncommon as it has always been.

« First   ‹ Prev
1 2 3 4 5 6 7 8 9 10