June 18
On 6/18/20 10:04 AM, Stanislav Blinov wrote:
> On Thursday, 18 June 2020 at 13:59:42 UTC, Steven Schveighoffer wrote:
> 
>> age.to!string will allocate a temporary string just to throw it away. text will not do that.
>>
>> -Steve
> 
> Wouldn't it?
> 
> https://github.com/dlang/phobos/blob/master/std/conv.d#L4193

Yikes. Let me rephrase.

text is perfectly capable of avoiding this, and should, but for some reason doesn't.

For sure format does not do this.

(checks... yeah, it avoids that, but the code is a mess comparatively)

-Steve
June 18
On Thursday, 18 June 2020 at 14:24:40 UTC, Steven Schveighoffer wrote:
> On 6/18/20 10:04 AM, Stanislav Blinov wrote:
>> On Thursday, 18 June 2020 at 13:59:42 UTC, Steven Schveighoffer wrote:
>> 
>>> age.to!string will allocate a temporary string just to throw it away. text will not do that.
>>>
>> 
>> Wouldn't it?
>> 
>> https://github.com/dlang/phobos/blob/master/std/conv.d#L4193
>
> Yikes. Let me rephrase.

Let's rephrase it then ;)

https://issues.dlang.org/show_bug.cgi?id=20950

June 19
On Thursday, 18 June 2020 at 14:24:40 UTC, Steven Schveighoffer wrote:
> On 6/18/20 10:04 AM, Stanislav Blinov wrote:
>> https://github.com/dlang/phobos/blob/master/std/conv.d#L4193
>
> Yikes. Let me rephrase.
>
> text is perfectly capable of avoiding this, and should, but for some reason doesn't.

It used to call std.conv.toChars but that triggered a dmd regression with a particular set of circumstances so it was changed to use to!():
https://github.com/dlang/phobos/pull/6659

In bugzilla there was a better alternative workaround but no one submitted a pull for that in time for the release:
https://issues.dlang.org/show_bug.cgi?id=17712#c11

I haven't been able to reproduce the test case with v2.092.0, but maybe I'm doing something wrong.
June 19
On Thursday, 18 June 2020 at 09:13:53 UTC, Dennis wrote:
> On Thursday, 18 June 2020 at 09:00:42 UTC, zoujiaqing wrote:
>> Type should be automatically converted to string!
>
> While this could be made to work for floating point numbers, it is ambiguous for integers since integers are often implicitly convertible to characters:
>
> writeln("AB"~67); // prints "ABC", code unit 67 represents 'C'

This is actually an open issue (someone filed it as a duplicate of a more subtle bug though):
https://issues.dlang.org/show_bug.cgi?id=18346

June 19
On 6/19/20 6:57 AM, Nick Treleaven wrote:
> On Thursday, 18 June 2020 at 14:24:40 UTC, Steven Schveighoffer wrote:
>> On 6/18/20 10:04 AM, Stanislav Blinov wrote:
>>> https://github.com/dlang/phobos/blob/master/std/conv.d#L4193
>>
>> Yikes. Let me rephrase.
>>
>> text is perfectly capable of avoiding this, and should, but for some reason doesn't.
> 
> It used to call std.conv.toChars but that triggered a dmd regression with a particular set of circumstances so it was changed to use to!():
> https://github.com/dlang/phobos/pull/6659
> 
> In bugzilla there was a better alternative workaround but no one submitted a pull for that in time for the release:
> https://issues.dlang.org/show_bug.cgi?id=17712#c11
> 
> I haven't been able to reproduce the test case with v2.092.0, but maybe I'm doing something wrong.

I think we should revert back to toChars, and see what the test suite produces. The test case should be added to the test suite as well.

-Steve
June 19
On Friday, 19 June 2020 at 10:57:42 UTC, Nick Treleaven wrote:

> It used to call std.conv.toChars but that triggered a dmd regression with a particular set of circumstances so it was changed to use to!():
> https://github.com/dlang/phobos/pull/6659
>
> In bugzilla there was a better alternative workaround but no one submitted a pull for that in time for the release:
> https://issues.dlang.org/show_bug.cgi?id=17712#c11
>
> I haven't been able to reproduce the test case with v2.092.0, but maybe I'm doing something wrong.

Am I reading this right? Library was downgraded because of a regression in the compiler? Tell me I'm not reading this right.
June 19
On 6/19/20 8:37 AM, Stanislav Blinov wrote:
> On Friday, 19 June 2020 at 10:57:42 UTC, Nick Treleaven wrote:
> 
>> It used to call std.conv.toChars but that triggered a dmd regression with a particular set of circumstances so it was changed to use to!():
>> https://github.com/dlang/phobos/pull/6659
>>
>> In bugzilla there was a better alternative workaround but no one submitted a pull for that in time for the release:
>> https://issues.dlang.org/show_bug.cgi?id=17712#c11
>>
>> I haven't been able to reproduce the test case with v2.092.0, but maybe I'm doing something wrong.
> 
> Am I reading this right? Library was downgraded because of a regression in the compiler? Tell me I'm not reading this right.

I don't think it's a regression in the compiler, I think it's a bug that always existed in the compiler, and a change to phobos brought it out. So the decision was made to undo the phobos change rather than tackle the (probably very difficult) compiler bug.

Not saying I agree with the decision, but that was why it was done. Some were not happy with the resolution. I wish the compiler could be fixed, but I lack the skills to even approach it. It seems the speculative generation of templates is a difficult problem for even regular D compiler devs to approach.

-Steve
June 19
On Friday, 19 June 2020 at 12:06:36 UTC, Steven Schveighoffer wrote:
> On 6/19/20 6:57 AM, Nick Treleaven wrote:
>> I haven't been able to reproduce the test case with v2.092.0, but maybe I'm doing something wrong.
>
> I think we should revert back to toChars, and see what the test suite produces. The test case should be added to the test suite as well.

OK. I added the two test cases in the issue to dmd/test/compilable, then when that's merged we can revert:
https://github.com/dlang/phobos/pull/7536
June 20
On Friday, 19 June 2020 at 10:57:42 UTC, Nick Treleaven wrote:
> On Thursday, 18 June 2020 at 14:24:40 UTC, Steven Schveighoffer wrote:
>> On 6/18/20 10:04 AM, Stanislav Blinov wrote:
>>> https://github.com/dlang/phobos/blob/master/std/conv.d#L4193
>>
>> Yikes. Let me rephrase.
>>
>> text is perfectly capable of avoiding this, and should, but for some reason doesn't.
>
> It used to call std.conv.toChars but that triggered a dmd regression with a particular set of circumstances so it was changed to use to!():
> https://github.com/dlang/phobos/pull/6659
>
> In bugzilla there was a better alternative workaround but no one submitted a pull for that in time for the release:
> https://issues.dlang.org/show_bug.cgi?id=17712#c11
>
> I haven't been able to reproduce the test case with v2.092.0, but maybe I'm doing something wrong.

I reduced it a but, but then it started to depend on the order of operations:

fail:

string test1()
{
	import std.uni : CodepointSet;
	import std.conv : to;
	uint a;
	CodepointSet charsets;
	string code = to!string(a);
	charsets.toSourceCode;
	return code;
}

success:

string test1()
{
	import std.uni : CodepointSet;
	import std.conv : to;
	uint a;
	CodepointSet charsets;
	charsets.toSourceCode;
	string code = to!string(a);
	return code;
}

Looks like it couldn't compare template instances well.
June 20
Reduced std.uni
--- test3 ---
string test1()
{
	import test3a;
	import std.conv : to;
	uint a;
	//B.c();
	string s = to!string(a);
	B.c();
	return s;
}
int main(){ return 0; }
--- test3a ---
alias B = A!int;

template A(T)
{
    string c()
    {
        import std.format : format;
        return format("%s","");
    }
}
---
1 2 3