Search code examples
c#c#-4.0keywordlanguage-specifications

C# 'dynamic' keyword... is it really a RESERVED keyword or just a identifier that means something special when used as type?


I have a C# 4.0 parser. It accepts 'dynamic' as a keyword as a type. My parser trips over statements found in working C# 3.0 programs of the form of:

dynamic = <exp> ;

So, it dynamic really a keyword? Or can it still be used as an arbitrary identifier name? (If so, why isn't 'int' treated the same way)?

Is there a reference spec somewhere that states whether dynamic is keyword? The latest ECMA C# 4 specification doesn't even mention 'dynamic', and the best I can find at the MS site is a "preliminary specification" which says its a keyword but I suspect that's just sloppy writing.


Solution

  • dynamic is a contextual keyword as of C# 4.0. The fourth edition of the ECMA C# spec does not refer to C# 4.0. (Note the 2006 publication date.)

    MSDN describes it as a keyword.

    It's also in this table of contextual keywords. (Scroll down.)