C++/CLI Language Specification
Total Page:16
File Type:pdf, Size:1020Kb
Ecma/TC39-TG5/2004/25 C++/CLI Language Specification Working Draft 1.5, Jun, 2004 Public Review Document Text highlighted like this indicates a placeholder for some future action. It might be a note from the editor to himself, or an indication of the actual or expected direction of some as-yet open issue. Note: In the spirit of the "Working Draft, Standard for Programming Language C++", this is an early draft. It’s known to be incomplet and incorrekt, and it has lots of bad formatting. Publication Time: 6/17/2004 11:44 PM Table of Contents Table of Contents Introduction....................................................................................................................................................xi 1. Scope............................................................................................................................................................. 1 2. Conformance ............................................................................................................................................... 2 3. Normative references .................................................................................................................................. 3 4. Definitions .................................................................................................................................................... 4 5. Notational conventions................................................................................................................................ 7 6. Acronyms and abbreviations ..................................................................................................................... 8 7. General description..................................................................................................................................... 9 8. Language overview.................................................................................................................................... 10 8.1 Getting started ....................................................................................................................................... 10 8.2 Types ..................................................................................................................................................... 10 8.2.1 Fundamental types and the CLI ...................................................................................................... 12 8.2.2 Conversions .................................................................................................................................... 13 8.2.3 Array types...................................................................................................................................... 13 8.2.4 Type system unification.................................................................................................................. 13 8.2.5 Pointers, handles, and null .............................................................................................................. 14 8.3 Parameters ............................................................................................................................................. 15 8.4 Automatic memory management........................................................................................................... 17 8.5 Expressions............................................................................................................................................ 18 8.6 Statements.............................................................................................................................................. 18 8.7 Delegates ............................................................................................................................................... 18 8.8 Native and ref classes ............................................................................................................................ 19 8.8.1 Literal fields.................................................................................................................................... 19 8.8.2 Initonly fields.................................................................................................................................. 20 8.8.3 Functions......................................................................................................................................... 20 8.8.4 Properties ........................................................................................................................................ 21 8.8.5 Events.............................................................................................................................................. 23 8.8.6 Static operators ............................................................................................................................... 24 8.8.7 Instance constructors....................................................................................................................... 25 8.8.8 Destructors...................................................................................................................................... 25 8.8.9 Static constructors........................................................................................................................... 25 8.8.10 Inheritance .................................................................................................................................... 25 8.8.10.1 Function overriding................................................................................................................ 25 8.9 Value classes ......................................................................................................................................... 27 8.10 Interfaces ............................................................................................................................................. 27 8.11 Enums.................................................................................................................................................. 29 8.12 Namespaces and assemblies ................................................................................................................ 29 8.13 Versioning ........................................................................................................................................... 30 8.14 Attributes ............................................................................................................................................. 31 8.15 Generics............................................................................................................................................... 32 8.15.1 Creating and consuming generics ................................................................................................. 32 8.15.2 Constraints .................................................................................................................................... 33 8.15.3 Generic functions.......................................................................................................................... 34 9. Lexical structure........................................................................................................................................ 36 9.1 Tokens ................................................................................................................................................... 36 9.1.1 Identifiers........................................................................................................................................ 36 iii C++/CLI Language Specification 9.1.2 Keywords........................................................................................................................................ 37 9.1.3 Literals ............................................................................................................................................ 37 9.1.3.1 The null literal .......................................................................................................................... 38 9.1.4 Operators and punctuators .............................................................................................................. 38 10. Basic concepts.......................................................................................................................................... 39 10.1 Members.............................................................................................................................................. 39 10.1.1 Value class members..................................................................................................................... 39 10.1.2 Delegate members......................................................................................................................... 39 10.2 Member access .................................................................................................................................... 40 10.2.1 Declared accessibility ................................................................................................................... 40 11. Preprocessor ............................................................................................................................................ 41 11.1 Predefined macro names...................................................................................................................... 41 12.