Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
July 14, 2019 Today's weird D edge case | ||||
---|---|---|---|---|
| ||||
https://run.dlang.io/is/l5Vyn4 Using an is statement inside a template constraint doesn't propagate the is results in to a function. You have to static if with the same is statement to make it work. |
July 14, 2019 Re: Today's weird D edge case | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ethan | On Sunday, 14 July 2019 at 00:22:10 UTC, Ethan wrote: > https://run.dlang.io/is/l5Vyn4 > > Using an is statement inside a template constraint doesn't propagate the is results in to a function. You have to static if with the same is statement to make it work. https://run.dlang.io/is/rR5UCA And now with the full example. Derp. |
July 14, 2019 Re: Today's weird D edge case | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ethan | On Sunday, 14 July 2019 at 00:22:10 UTC, Ethan wrote: > https://run.dlang.io/is/l5Vyn4 > > Using an is statement inside a template constraint doesn't propagate the is results in to a function. You have to static if with the same is statement to make it work. I hit the exact same limitation yesterday. It turns out it is a known thing from 2011: https://issues.dlang.org/show_bug.cgi?id=6269 |
July 14, 2019 Re: Today's weird D edge case | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ethan | On Sunday, 14 July 2019 at 00:23:49 UTC, Ethan wrote: > On Sunday, 14 July 2019 at 00:22:10 UTC, Ethan wrote: >> https://run.dlang.io/is/l5Vyn4 >> >> Using an is statement inside a template constraint doesn't propagate the is results in to a function. You have to static if with the same is statement to make it work. > > https://run.dlang.io/is/rR5UCA > > And now with the full example. Derp. I realise this doesn't work for all template constraints, but for some cases there's a workaround using normal type specialisation. ... and as I was about to show it, I hit an ICE (goes away when you uncomment the second line in the !compiles): https://run.dlang.io/is/aWkOOo |
July 14, 2019 Re: Today's weird D edge case | ||||
---|---|---|---|---|
| ||||
Posted in reply to Les De Ridder | On Sunday, 14 July 2019 at 19:58:20 UTC, Les De Ridder wrote: > On Sunday, 14 July 2019 at 00:23:49 UTC, Ethan wrote: >> On Sunday, 14 July 2019 at 00:22:10 UTC, Ethan wrote: >>> https://run.dlang.io/is/l5Vyn4 >>> >>> Using an is statement inside a template constraint doesn't propagate the is results in to a function. You have to static if with the same is statement to make it work. >> >> https://run.dlang.io/is/rR5UCA >> >> And now with the full example. Derp. > > I realise this doesn't work for all template constraints, but for some > cases there's a workaround using normal type specialisation. > > ... and as I was about to show it, I hit an ICE (goes away when you > uncomment the second line in the !compiles): > > https://run.dlang.io/is/aWkOOo took note of the ICE : https://issues.dlang.org/show_bug.cgi?id=20051 |
July 14, 2019 Re: Today's weird D edge case | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ethan | On 7/13/2019 5:22 PM, Ethan wrote:
> https://run.dlang.io/is/l5Vyn4
>
> Using an is statement inside a template constraint doesn't propagate the is results in to a function. You have to static if with the same is statement to make it work.
URLs to those sand boxes tend to be ephemeral. Much better to just quote the text in the email, like this:
import std.stdio;
string SomeFunc( T )() if( is( T : AT[], AT ) )
{
return AT.stringof;
}
void main()
{
writeln(SomeFunc!( int[] ));
}
|
July 16, 2019 Re: Today's weird D edge case | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Sunday, 14 July 2019 at 23:10:33 UTC, Walter Bright wrote:
> On 7/13/2019 5:22 PM, Ethan wrote:
>> https://run.dlang.io/is/l5Vyn4
>>
>> Using an is statement inside a template constraint doesn't propagate the is results in to a function. You have to static if with the same is statement to make it work.
>
> URLs to those sand boxes tend to be ephemeral. Much better to just quote the text in the email, like this:
>
>
> import std.stdio;
>
> string SomeFunc( T )() if( is( T : AT[], AT ) )
> {
> return AT.stringof;
> }
>
> void main()
> {
> writeln(SomeFunc!( int[] ));
> }
I think that's an opinion. Since I use the web interface mainly then it's much more convenient to me at least that there is a link I can just click and run the example instead of having to copy-paste it.
|
July 17, 2019 Re: Today's weird D edge case | ||||
---|---|---|---|---|
| ||||
Posted in reply to bauss | On Tuesday, 16 July 2019 at 14:09:05 UTC, bauss wrote:
> I think that's an opinion. Since I use the web interface mainly then it's much more convenient to me at least that there is a link I can just click and run the example instead of having to copy-paste it.
That's not at all what Walter meant by saying it's ephemeral. His point is that when reading this thread in a year, the link may have expired.
Thus, the correct solution is to paste the code and provide the link for convenience.
|
Copyright © 1999-2021 by the D Language Foundation