In C++ templates are instantiated with angle brackets vector<int>
and the Java and C# languages have adopted the same syntax for their generics.
The creators of D, however, have been quite vocal about the problems that angle brackets bring and they made a new syntax foo!(int)
— but I've never seen too many details about what problems angle brackets bring, exactly.
One of them was when instantiating a template with another template vector<vector<int>>
, which would cause some (older?) compilers to confuse the trailing '>>` with the bit-shift or streaming operators. The solution was to insert a space between the two angle brackets, but haven't compilers become able to parse that syntax, nowadays?
Another problem was when using the greater-than operator foo<3 > 2>
. The parser would think that the operator actually closes the template instantiation; the fix was to introduce parentheses foo<(3 > 2)>
. But I don't think there that many cases where you need to do this and, at any rate, I'd rather have to type the extra parentheses when they are needed, instead of introducing new syntax and always having to type the exclamation mark.
What other problems are there with angle brackets that made the D developers create a new syntax?