1、 Reference number ECMA-123:2009 Ecma International 2009 ECMA-408 3rd Edition / June 2015 Dart Programming Language Specification Ecma International 2015 iii This Ecma Standard has been adopted by the General Assembly of June 2015. “COPYRIGHT NOTICE 2015 Ecma International This document may be copied
2、, published and distributed to others, and certain derivative works of it may be prepared, copied, published, and distributed, in whole or in part, provided that the above copyright notice and this Copyright License and Disclaimer are included on all such copies and derivative works. The only deriva
3、tive works that are permissible under this Copyright License and Disclaimer are: (i) works which incorporate all or portion of this document for the purpose of providing commentary or explanation (such as an annotated version of the document), (ii) works which incorporate all or portion of this docu
4、ment for the purpose of incorporating features that provide accessibility, (iii) translations of this document into languages other than English and into different formats and (iv) works by making use of this specification in standard conformant products by implementing (e.g. by copy and paste wholl
5、y or partly) the functionality therein. However, the content of this document itself may not be modified in any way, including by removing the copyright notice or references to Ecma International, except as required to translate it into languages other than English or into a different format. The of
6、ficial version of an Ecma International document is the English language version on the Ecma International website. In the event of discrepancies between a translated version and the official version, the official version shall govern. The limited permissions granted above are perpetual and will not
7、 be revoked by Ecma International or its successors or assigns. This document and the information contained herein is provided on an “AS IS“ basis and ECMA INTERNATIONAL DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WIL
8、L NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.“ iv Ecma International 2015 Dart Programming Language SpecificationVersion 1.9April 15, 2015Contents1 Scope 62 Conformance 63 Normative References 64 Terms and Definitions 65 Notatio
9、n 66 Overview 86.1 Scoping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96.2 Privacy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116.3 Concurrency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 Errors and Warnings 118 Variables 128.1 Evaluation o
10、f Implicit Variable Getters . . . . . . . . . . . . . . . 169 Functions 169.1 Function Declarations . . . . . . . . . . . . . . . . . . . . . . . . 189.2 Formal Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . 199.2.1 Required Formals . . . . . . . . . . . . . . . . . . . . . . . 209.2
11、.2 Optional Formals . . . . . . . . . . . . . . . . . . . . . . . 209.3 Type of a Function . . . . . . . . . . . . . . . . . . . . . . . . . . 219.4 External Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 2210 Classes 2210.1 Instance Methods . . . . . . . . . . . . . . . . . . . . . .
12、 . . . . . 2410.1.1 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . 2510.2 Getters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26110.3 Setters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2710.4 Abstract Instance Members . . . . . . . . . . .
13、. . . . . . . . . . 2710.5 Instance Variables . . . . . . . . . . . . . . . . . . . . . . . . . . 2810.6 Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2910.6.1 Generative Constructors . . . . . . . . . . . . . . . . . . . 2910.6.2 Factories . . . . . . . . . . . . . . . . .
14、. . . . . . . . . . 3310.6.3 Constant Constructors . . . . . . . . . . . . . . . . . . . . 3410.7 Static Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3610.8 Static Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3710.9 Superclasses . . . . . . . . . . . . . . . .
15、 . . . . . . . . . . . . . . 3710.9.1 Inheritance and Overriding . . . . . . . . . . . . . . . . . 3710.10 Superinterfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4011 Interfaces 4111.1 Superinterfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4111.1.1 Inheritance and O
16、verriding . . . . . . . . . . . . . . . . . 4112 Mixins 4312.1 Mixin Application . . . . . . . . . . . . . . . . . . . . . . . . . . 4312.2 Mixin Composition . . . . . . . . . . . . . . . . . . . . . . . . . . 4413 Enums 4514 Generics 4515 Metadata 4716 Expressions 4716.0.1 Object Identity . . . . .
17、 . . . . . . . . . . . . . . . . . . . 4816.1 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4916.2 Null . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5216.3 Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5216.4 Booleans . . . .
18、 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5416.4.1 Boolean Conversion . . . . . . . . . . . . . . . . . . . . . 5416.5 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5516.5.1 String Interpolation . . . . . . . . . . . . . . . . . . . . . 5816.6 Symbols . . .
19、 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5916.7 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5916.8 Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6116.9 Throw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
20、216.10 Function Expressions . . . . . . . . . . . . . . . . . . . . . . . . 6316.11 This . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6516.12 Instance Creation . . . . . . . . . . . . . . . . . . . . . . . . . . 6516.12.1 New . . . . . . . . . . . . . . . . . . . . . . . . . .
21、 . . . . 6516.12.2 Const . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6716.13 Spawning an Isolate . . . . . . . . . . . . . . . . . . . . . . . . . 6916.14 Function Invocation . . . . . . . . . . . . . . . . . . . . . . . . . 69216.14.1 Actual Argument List Evaluation . . . . . . . . .
22、. . . . 7116.14.2 Binding Actuals to Formals . . . . . . . . . . . . . . . . . 7216.14.3 Unqualified Invocation . . . . . . . . . . . . . . . . . . . 7216.14.4 Function Expression Invocation . . . . . . . . . . . . . . 7316.15 Lookup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
23、16.15.1 Method Lookup . . . . . . . . . . . . . . . . . . . . . . . 7416.15.2 Getter and Setter Lookup . . . . . . . . . . . . . . . . . 7416.16 Top level Getter Invocation . . . . . . . . . . . . . . . . . . . . . 7416.17 Method Invocation . . . . . . . . . . . . . . . . . . . . . . . . . . 7416.17
24、.1 Ordinary Invocation . . . . . . . . . . . . . . . . . . . . . 7416.17.2 Cascaded Invocations . . . . . . . . . . . . . . . . . . . . 7616.17.3 Super Invocation . . . . . . . . . . . . . . . . . . . . . . . 7716.17.4 Sending Messages . . . . . . . . . . . . . . . . . . . . . . . 7816.18 Property E
25、xtraction . . . . . . . . . . . . . . . . . . . . . . . . . 7816.18.1 Getter Access and Method Extraction . . . . . . . . . . . 7916.18.2 Super Getter Access and Method Closurization . . . . . . 8116.18.3 General Closurization . . . . . . . . . . . . . . . . . . . . 8216.18.4 Named Constructor Extra
26、ction . . . . . . . . . . . . . . . 8316.18.5 Anonymous Constructor Extraction . . . . . . . . . . . . 8316.18.6 General Super Property Extraction . . . . . . . . . . . . . 8316.18.7 Ordinary Member Closurization . . . . . . . . . . . . . . 8416.18.8 Named Constructor Closurization . . . . . . . . .
27、 . . . . . 8516.18.9 Anonymous Constructor Closurization . . . . . . . . . . . 8516.18.10Super Closurization . . . . . . . . . . . . . . . . . . . . . 8616.19 Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8716.19.1 Compound Assignment . . . . . . . . . . . . . . . . . . . 89
28、16.20 Conditional . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9116.21If-null Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . 9216.22 Logical Boolean Expressions . . . . . . . . . . . . . . . . . . . . 9216.23 Equality . . . . . . . . . . . . . . . . . . . . . . . . .
29、. . . . . . 9316.24 Relational Expressions . . . . . . . . . . . . . . . . . . . . . . . 9416.25 Bitwise Expressions . . . . . . . . . . . . . . . . . . . . . . . . . 9416.26 Shift . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9516.27 Additive Expressions . . . . . . . . . . .
30、. . . . . . . . . . . . . 9616.28 Multiplicative Expressions . . . . . . . . . . . . . . . . . . . . . 9616.29 Unary Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . 9716.30 Await Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . 9816.31 Postfix Expressions . . . . . . .
31、 . . . . . . . . . . . . . . . . . . 9916.32 Assignable Expressions . . . . . . . . . . . . . . . . . . . . . . . 10016.33 Identifier Reference . . . . . . . . . . . . . . . . . . . . . . . . . 10116.34 Type Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10416.35 Type Cast . . . .
32、. . . . . . . . . . . . . . . . . . . . . . . . . . 105317 Statements 10517.1 Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10617.2 Expression Statements . . . . . . . . . . . . . . . . . . . . . . . . 10617.3 Local Variable Declaration . . . . . . . . . . . . . . . . . .
33、. . . . 10717.4 Local Function Declaration . . . . . . . . . . . . . . . . . . . . . 10717.5 If . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10817.6 For . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10917.6.1 For Loop . . . . . . . . . . . . . . . .
34、 . . . . . . . . . . . 11017.6.2 For-in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11017.6.3 Asynchronous For-in . . . . . . . . . . . . . . . . . . . . . 11017.7 While . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11117.8 Do . . . . . . . . . . . . . . . . . . . .
35、 . . . . . . . . . . . . . . . 11117.9 Switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11217.10 Rethrow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11517.11 Try . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11617.12 Return . . . . . .
36、. . . . . . . . . . . . . . . . . . . . . . . . . . 11817.13 Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12117.14 Break . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12117.15 Continue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12217
37、.16 Yield and Yield-Each . . . . . . . . . . . . . . . . . . . . . . . . 12317.16.1 Yield . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12317.16.2 Yield-Each . . . . . . . . . . . . . . . . . . . . . . . . . . 12417.17 Assert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
38、. . 12518 Libraries and Scripts 12618.1 Imports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12718.2 Exports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13218.3 Parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13318.4 Scripts . . . . .
39、. . . . . . . . . . . . . . . . . . . . . . . . . . . . 13418.5 URIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13419 Types 13519.1 Static Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13519.1.1 Type Promotion . . . . . . . . . . . . . . . . . . . . . . . 1
40、3719.2 Dynamic Type System . . . . . . . . . . . . . . . . . . . . . . . . 13719.3 Type Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . 13819.3.1 Typedef . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13819.4 Interface Types . . . . . . . . . . . . . . . . . . . . . . . . .
41、 . . . 13919.5 Function Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14019.6 Type dynamic . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14219.7 Type Void . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14319.8 Parameterized Types . . . . . . . . . . . . . . .
42、 . . . . . . . . . . 14319.8.1 Actual Type of Declaration . . . . . . . . . . . . . . . . . 14419.8.2 Least Upper Bounds . . . . . . . . . . . . . . . . . . . . . 144420 Reference 14520.1 Lexical Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14520.1.1 Reserved Words . . . . . . . .
43、 . . . . . . . . . . . . . . . 14520.1.2 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . 14620.2 Operator Precedence . . . . . . . . . . . . . . . . . . . . . . . . . 1465Dart Programming Language Specification 61 Scope ecmaScopeThis Ecma standard specifies the syntax and semantics of
44、 the Dart program-ming language. It does not specify the APIs of the Dart libraries except wherethose library elements are essential to the correct functioning of the languageitself (e.g., the existence of class Object with methods such as noSuchMethod,runtimeType).2 Conformance ecmaConformanceA con
45、forming implementation of the Dart programming language mustprovide and support all the APIs (libraries, types, functions, getters, setters,whether top-level, static, instance or local) mandated in this specification.A conforming implementation is permitted to provide additional APIs, butnot additio
46、nal syntax, except for experimental features in support of null-awarecascades and tear-offs that are likely to be introduced in the next revision ofthis specification.3 Normative References ecmaNormativeReferencesThe following referenced documents are indispensable for the applicationof this documen
47、t. For dated references, only the edition cited applies. Forundated references, the latest edition of the referenced document (includingany amendments) applies.1. The Unicode Standard, Version 5.0, as amended by Unicode 5.1.0, orsuccessor.2. Dart API Reference, https:/api.dartlang.org/4 Terms and De
48、finitions ecmaTermsAndDefinitionsTerms and definitions used in this specification are given in the body ofthe specification proper. Such terms are highlighted in italics when they areintroduced, e.g., we use the term verbosity to refer to the property of excessverbiage.5 Notation notationWe distingu
49、ish between normative and non-normative text. Normative textdefines the rules of Dart. It is given in this font. At this time, non-normativetext includes:Dart Programming Language Specification 7Rationale Discussion of the motivation for language design decisions appears in ital-ics. Distinguishing normative from non-normative helps clarify what partof the text is binding and what part is merely expository.Commentary Comments such as “The careful reader will have noticed that the name Darthas four characters” serve to illustrate or clarify the specification, but areredundant with th
copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1