C like macro is useful

davidl davidl at 126.com
Wed Jul 23 05:15:37 PDT 2008


consider:

version(v1)
{
   enum e
   {
      a,
      b
   }
}
else
{
   enum e
   {
      a,
      b,
      c
   }
}

If my enum contains a lot of stuffs.... D version becomes a disaster.


consider:
version(v1)
{
   if ( cond1() && cond2() && a==b)
   {
      //blah
   }
}
else
{
   if ( cond1() && cond2() && a!=b)
   {
      //blah
   }
}

in C you can do it

if ( cond1() && cond2() &&
#ifdef v1
      a==b
#else
      a!=b
#endif
    )
{
    // blah
}


Any good and practical way to solve these?




-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/



More information about the Digitalmars-d mailing list