D has a very nice feature of token strings:
string a = q{
               looksLikeCode();
            };

It is useful in writing mixins and to have syntax highlighting in editors. Although I like it, it is not something I ever felt like missing in other languages. What I do always miss are these two options:

1. Have something like this:

string a = |q{
                 firstLine();
                 if (cond) {
                     secondLine()
                 }
              };

mean count the number of whitespace characters at the start of a first new line of string literal and then strip up to that many whitespace characters from the start of each line.

2. If we just put for example "-" instead of "|" in above example have that mean: replace all whitespace with a single space in following string literal.

I think it is clear why would these be useful but if you want me I can add a few examples. This would not make any breaking changes to the language and it should be possible to simply implement it wholly in the lexer.

So what do think?

Reply via email to