Several language keywords changed from Managed Extensions for C++ to Visual C++ 2005.
In the new Visual C++ 2005 syntax, the double-underscore is removed as a prefix from all keywords (with the obligatory exception вЂ“ in this case, __identifier is retained). For example, a property is now declared as property, not __property. There were two primary reasons for using the double-underscore prefix in Managed Extensions:
It is the conformant method of providing local extensions to the ISO-C++ Standard. A primary goal of the Managed Extensions design was to not introduce incompatibilities with the standard language, such as new keywords and tokens. It was this reason, in large part, which motivated the choice of pointer syntax for the declaration of objects of managed reference types.
The use of the double-underscore, apart from its conformant aspect, is also a reasonable guarantee of being non-invasive with the existing code base of our users. This was a second primary goal of the Managed Extensions design.
Why, then, did we remove the double-underscore (as well as introduce a number of new tokens)? No, it is not that we are no longer concerned with being conformant with the standard!
We remain committed to being conformant. However, we recognize that support for the CLR dynamic object model represents a new and powerful programming paradigm. Both our experience with Managed Extensions and our experience with the design and evolution of the C++ language itself have convinced us that support of this new paradigm requires its own high-level keywords and tokens. We have sought to provide a first-class expression of this new paradigm while integrating it and supporting the standard language. We hope you agree that the new syntax design provides a first class programming experience of these two disparate object models.
Similarly, we are very concerned with maximizing the non-invasive nature of these new language keywords. This has been accomplished with the use of contextual and spaced keywords. Before we look at the actual new language syntax, letвЂ™s try to make sense of these two special keyword flavors.
A contextual keyword has a special meaning within specific program contexts. Within the general program, for example, sealed is treated as an ordinary identifier. However, when it occurs within the declaration portion of a managed reference class type, it is treated as a keyword within the context of that class declaration. This minimizes the potential invasive impact of introducing a new keyword in the language, something that we feel is very important to users with an existing code base. At the same time, it allows users of the new functionality to have a first-class experience of the additional language feature вЂ“ something we felt was missing from Managed Extensions. WeвЂ™ll see an example of how sealed is used in Declaration of a Managed Class Type.
A spaced keyword is a special case of a contextual keyword. It literally pairs an existing keyword with a contextual modifier separated by a space. The pair is treated as a single unit, such as value class, rather than as two separate keywords.