Re: enums and std.traits

2012-08-06 Thread Christophe Travert
Jonathan M Davis , dans le message (digitalmars.D:174310), a écrit : IMO, the behavior should be this: when trying to call the template with a argument that is an enum type based on string, the compiler should try to instanciate the template for this enum type, and isSomeString should fail.

Re: enums and std.traits

2012-08-06 Thread deadalnix
Le 04/08/2012 23:09, Jonathan M Davis a écrit : At present (though it didn't used to work this way until about 4 months ago - the change is in 2.060), a number of std.traits templates - including isSomeString - evaluate to false for enums. So, enum E : string { a = hello } static

Re: enums and std.traits

2012-08-06 Thread deadalnix
Le 05/08/2012 14:38, Christophe Travert a écrit : Jonathan M Davis , dans le message (digitalmars.D:174267), a écrit : On Saturday, August 04, 2012 15:22:34 Jonathan M Davis wrote: On Sunday, August 05, 2012 00:15:02 Timon Gehr wrote: T fun(T)(T arg) if(isSomeString!arg){ return

Re: enums and std.traits

2012-08-05 Thread Christophe Travert
Andrej Mitrovic , dans le message (digitalmars.D:174259), a écrit : On 8/4/12, Jonathan M Davis jmdavisp...@gmx.com wrote: snip I agree with you. isSomeString!T predicate failing maybe isn't as serious as !isSomeString!T passing and ending up with wrong results. At the very least this

Re: enums and std.traits

2012-08-05 Thread Christophe Travert
Jonathan M Davis , dans le message (digitalmars.D:174267), a écrit : On Saturday, August 04, 2012 15:22:34 Jonathan M Davis wrote: On Sunday, August 05, 2012 00:15:02 Timon Gehr wrote: T fun(T)(T arg) if(isSomeString!arg){ return arg~arg[0]; } IMO, the behavior should be this:

Re: enums and std.traits

2012-08-05 Thread Jonathan M Davis
On Sunday, August 05, 2012 12:38:56 Christophe Travert wrote: Jonathan M Davis , dans le message (digitalmars.D:174267), a écrit : On Saturday, August 04, 2012 15:22:34 Jonathan M Davis wrote: On Sunday, August 05, 2012 00:15:02 Timon Gehr wrote: T fun(T)(T arg) if(isSomeString!arg){

enums and std.traits

2012-08-04 Thread Jonathan M Davis
At present (though it didn't used to work this way until about 4 months ago - the change is in 2.060), a number of std.traits templates - including isSomeString - evaluate to false for enums. So, enum E : string { a = hello } static assert(isSomeString!(E.a)); will fail. This is in spite of

Re: enums and std.traits

2012-08-04 Thread Jonathan M Davis
On Saturday, August 04, 2012 14:09:29 Jonathan M Davis wrote: I think that the change to std.traits was a big mistake and will probably file it as a regression, but I thought that I should get other people's thoughts on this. http://d.puremagic.com/issues/show_bug.cgi?id=8508 - Jonathan m

Re: enums and std.traits

2012-08-04 Thread Andrej Mitrovic
On 8/4/12, Jonathan M Davis jmdavisp...@gmx.com wrote: snip I agree with you. isSomeString!T predicate failing maybe isn't as serious as !isSomeString!T passing and ending up with wrong results. At the very least this should have been discussed about before the change. And why should a template

Re: enums and std.traits

2012-08-04 Thread Timon Gehr
On 08/04/2012 11:09 PM, Jonathan M Davis wrote: I agree that an enum's base type should not implicitly convert to the enum type, since that would mean that you could have an invalid enum value, but I see no problem with enums implicitly converted to their base type. Well, there is a problem:

Re: enums and std.traits

2012-08-04 Thread Jonathan M Davis
On Sunday, August 05, 2012 00:15:02 Timon Gehr wrote: On 08/04/2012 11:09 PM, Jonathan M Davis wrote: I agree that an enum's base type should not implicitly convert to the enum type, since that would mean that you could have an invalid enum value, but I see no problem with enums implicitly

Re: enums and std.traits

2012-08-04 Thread Jonathan M Davis
On Saturday, August 04, 2012 15:22:34 Jonathan M Davis wrote: On Sunday, August 05, 2012 00:15:02 Timon Gehr wrote: T fun(T)(T arg) if(isSomeString!arg){ return arg~arg[0]; } Though honestly, I'd argue that the compiler should treat arg ~ arg[0] as being string rather than the

Re: enums and std.traits

2012-08-04 Thread Adam D. Ruppe
On Saturday, 4 August 2012 at 21:09:40 UTC, Jonathan M Davis wrote: I think that the change to std.traits was a big mistake and will probably file it as a regression I don't know what the right answer here is, but if you do end up reverting those changes, be sure to change std.conv.to too so

Re: enums and std.traits

2012-08-04 Thread Jonathan M Davis
On Sunday, August 05, 2012 05:40:40 Adam D. Ruppe wrote: On Saturday, 4 August 2012 at 21:09:40 UTC, Jonathan M Davis wrote: I think that the change to std.traits was a big mistake and will probably file it as a regression I don't know what the right answer here is, but if you do end up