static interface

"のしいか (noshiika)" noshiika at gmail.com
Wed Nov 18 11:29:08 PST 2009


In order to achieve good completion support by editors (like
IntelliSense) with duck-typed variables, concept-checking code should
contain more type information than that of the code now used in Phobos.

Example:

   static interface InputRange(T) {
     const bool empty();
     T front();
     void popFront();
   }

or in the current D syntax,

   template isInputRange(T, R) {
     enum isInputRange =
       is(const(R).init.empty() == bool) &&
       is(R.init.front() == T) &&
       is(R.init.popFront() == void);
   }

How do you think about this?



More information about the Digitalmars-d mailing list