Template instantiation syntax

Nick Sabalausky a at a.a
Sat Oct 11 14:43:00 PDT 2008


"Walter Bright" <newshound1 at digitalmars.com> wrote in message 
news:gcr67e$20a4$1 at digitalmars.com...
> Dave wrote:
>> Still there may be an issue with a<b,c>d, but again that is apparently 
>> solved in C#, Java  and C++0x,
>
> In C++, this is resolved by looking 'a' up in the symbol table to see if 
> it is a template or not. This means it is impossible to parse C++ without 
> doing semantic analysis. Such means it is impossible to write *correct* 
> C++ tools that analyze syntax, such as color syntax highlighting, without 
> writing most of a full compiler.
>
> (In cases, such as template bodies, where the compiler cannot do semantic 
> analysis for parsing, the language requires the 'template' keyword be 
> inserted before the 'a'..)
>
> There are a lot of hackish ways to parse C++ 95% correctly, and these are 
> often used in editors. But none of them do it 100% unless they are backed 
> by a full C++ compiler.
>
> C++ pays a high price for the < >, and still fails to get the job done 
> correctly.
>
> I don't know specifically how Java and C# do it, but their generics are 
> not true templates, they are only types, and so can only appear in very 
> restricted circumstances.

*Extremely* restricted in the case of C# (*cough* No IArithmetic or operator 
constraints *cough*). Although that is really a separate issue... Sorry, pet 
peeve. ;) 





More information about the Digitalmars-d mailing list