How convice people that D it's wonderfull in a hour ?

Trass3r un at known.com
Sun Oct 9 13:01:35 PDT 2011


Talk about stuff that's hard to do or impossible in C++ (or just a PITA  
like the whole language) and compare it to some nifty D code.

For example template metaprogramming. No easy way to do template  
constraints, no is expressions nor a proper typeof so you have to use  
specialization a lot.
You could also show something that checks for an "interface" at  
compile-time, like
template isInputRange(R)
{
     enum bool isInputRange = is(typeof(
     {
         R r;              // can define a range object
         if (r.empty) {}   // can test for empty
         r.popFront();     // can invoke popFront()
         auto h = r.front; // can get the front of the range
     }()));
}

CTFE is another strong feature.
You could for example show some code that generates Token handling code  
(an enum for the tokens, associative arrays for token 2 string and the  
other way around, etc.) to be used by a lexer without the necessity for a  
DSL like in Clang or a separate tool like dmd.


More information about the Digitalmars-d-learn mailing list