ranges of characters and the overabundance of traits that go with them

Sebastiaan Koppe via Digitalmars-d digitalmars-d at puremagic.com
Fri Mar 17 00:33:48 PDT 2017


On Thursday, 16 March 2017 at 22:42:21 UTC, Jonathan M Davis 
wrote:
> On Thursday, March 16, 2017 21:50:18 Sebastiaan Koppe via The 
> problem is that that then catches when an enum is passed to 
> isSomeString, not when the template constraint or static if 
> that isSomeString is being used in should have checked for 
> enums and didn't. And checking isSomeString with an enum is 
> perfectly valid. It's just that we'd like it to be false, 
> whereas right now it's true. Code could quite legitimately be 
> doing something like
>
> auto foo(T)(T str)
>     if(isSomeString!T)
> {
>     static if(is(T == enum))
>         return foo!(StringTypeOf!T)(str);
>     else
>     {
>         ...
>     }
> }

Ahh yes, silly me. It's not so much about isSomeString but how 
people use it in conjunction with extra constraints. Quite messy.

So for my proposed static deprecated to work it would only have 
to show a message when it would have changed the outcome of the 
template constraint where it is used in. Which still gives false 
positives due to overloads.

So the only way to change a template trait is to either just do 
it - and risk breakage - or to create a new one under another 
name?

> So, probably, all we could do is figure out how often 
> isSomeString is used in the D code that's publicly up on places 
> like github or bitbucket and not much about how it's used. I 
> don't know for sure though.
>
> - Jonathan M Davis

Yeah, you are right. You'll would need to instantiate the 
templates to resolve the types and as far as I know dcd/scanner 
don't.


More information about the Digitalmars-d mailing list