Smooth transition to D2 for Tango users?

Sergey Gromov snake.scaly at gmail.com
Sun Sep 21 20:50:48 PDT 2008


Bruce Adams <tortoise_74 at yeah.who.co.uk> wrote:
> I don't think its unreasonable to expect that braces will be balanced
> in all future versions of the language.

Braces can be in strings or comments.  It's quite likely to have braces 
in strings in many kinds of parser programs.

If you want code hidden from a compiler, put it in a string and mix in. 

enum veryD2Code = `
  auto foo(T)(T x) if (__traits(hasMember, "opCall"))
  {
    return x();
  }
`;

version (D_Version2)
{
  mixin(veryD2Code);
}

In D2 you can use token strings for that purpose, so that the code will 
even be highlighted in your editor, but will not interfere with the 
compiler.



More information about the Digitalmars-d mailing list