JavaScript EditorDhtml editor     Free javascript download 

Main Page

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:

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.

See Also


C++/CLI Migration Primer
New C++ Language Features

JavaScript EditorDhtml editor     Free javascript download