dmd 1.046 and 2.031 releases - is() expression

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Jul 6 22:22:42 PDT 2009


The Anh Tran wrote:
> Andrei Alexandrescu wrote:
>> I agree there are ugly constructs in D, and is-expressions would near 
>> the top of the list (particularly the absolutely awful is(T : T[])), 
>> but you have no case (heh) with the switch statement.
>>
>>
>> Andrei
> 
> Just a funny suggestion: could we change the is() expression to 
> imperative style?
> 
> Now:
> template Something(T, U, V) if ( is(T : T[]) && is(...) )
> {
>      alias T blah1;
>      U blah2;
>      class C {};
>      struct S {};
> }
> 
> In mirror universe:
> template Something(T, U, V)
> in
> {
>     static if ( T : T[] ) // static if here mean if (is (...))
>     {
>        // may do something with T, make alias, change type
>        // or check another constraint.
>     }
>     else
>     {
>         pragma(msg, "T must be Klingon");
>         static assert(false); // Or return false; ????
>     }
> 
>     static if ( U == int )
>     {
>        V = float; // ?????
>     }
>     return true;
> }
> body
> {
>      alias T blah1;
>      U blah2;
>      class C {};
>      struct S {};
> }

I wished for the longest time to simplify the often-used if(is(...)) 
syntax, but Walter said there are too many ambiguities involved if "is" 
gets dropped.

Andrei


More information about the Digitalmars-d-announce mailing list