Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Side by Side Diff: docs/language/dartLangSpec.tex

Issue 2678003002: Specification adjustments for covariant overrides in Dart 1. (Closed)
Patch Set: Rebasing Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « docs/language/dart.sty ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 \documentclass{article} 1 \documentclass{article}
2 \usepackage{epsfig} 2 \usepackage{epsfig}
3 \usepackage{color} 3 \usepackage{color}
4 \usepackage{dart} 4 \usepackage{dart}
5 \usepackage{bnf} 5 \usepackage{bnf}
6 \usepackage{hyperref} 6 \usepackage{hyperref}
7 \usepackage{lmodern} 7 \usepackage{lmodern}
8 \usepackage[T1]{fontenc} 8 \usepackage[T1]{fontenc}
9 \newcommand{\code}[1]{{\sf #1}} 9 \newcommand{\code}[1]{{\sf #1}}
10 \title{Dart Programming Language Specification \\ 10 \title{Dart Programming Language Specification \\
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 387
388 \section{Variables} 388 \section{Variables}
389 \LMLabel{variables} 389 \LMLabel{variables}
390 390
391 \LMHash{} 391 \LMHash{}
392 Variables are storage locations in memory. 392 Variables are storage locations in memory.
393 393
394 \begin{grammar} 394 \begin{grammar}
395 {\bf variableDeclaration:} 395 {\bf variableDeclaration:}
396 declaredIdentifier (`,' identifier)* 396 declaredIdentifier (`,' identifier)*
397 . 397 .
398 398
399 {\bf declaredIdentifier:} 399 {\bf declaredIdentifier:}
400 metadata finalConstVarOrType identifier 400 metadata finalConstVarOrType identifier
401 . 401 .
402 402
403 {\bf finalConstVarOrType:}\FINAL{} type?; 403 {\bf finalConstVarOrType:}\FINAL{} type?;
404 \CONST{} type?; 404 \CONST{} type?;
405 » varOrType 405 varOrType
406 . 406 .
407 407
408 {\bf varOrType:}\VAR{}; 408 {\bf varOrType:}\VAR{};
409 » type 409 type
410 . 410 .
411 411
412 {\bf initializedVariableDeclaration:} 412 {\bf initializedVariableDeclaration:}
413 declaredIdentifier (`=' expression)? (`,' initializedIdentifier)* % could do top level here 413 declaredIdentifier (`=' expression)? (`,' initializedIdentifier)* % could do top level here
414 . 414 .
415 415
416 {\bf initializedIdentifier:} 416 {\bf initializedIdentifier:}
417 identifier (`=' expression)? % could do top-level here 417 identifier (`=' expression)? % could do top-level here
418 . 418 .
419 419
420 {\bf initializedIdentifierList:} 420 {\bf initializedIdentifierList:}
421 initializedIdentifier (`,' initializedIdentifier)* 421 initializedIdentifier (`,' initializedIdentifier)*
422 . 422 .
423 423 \end{grammar}
424
425
426
427 \end{grammar}
428 424
429 \LMHash{} 425 \LMHash{}
430 A variable that has not been initialized has the initial value \NULL{} (\ref{nul l}). 426 A variable that has not been initialized has the initial value \NULL{} (\ref{nul l}).
431 427
432 \LMHash{} 428 \LMHash{}
433 A variable declared at the top-level of a library is referred to as either a {\e m library variable} or simply a top-level variable. 429 A variable declared at the top-level of a library is referred to as either a {\e m library variable} or simply a top-level variable.
434 430
435 \LMHash{} 431 \LMHash{}
436 A {\em static variable} is a variable that is not associated with a particular i nstance, but rather with an entire library or class. Static variables include l ibrary variables and class variables. Class variables are variables whose declar ation is immediately nested inside a class declaration and includes the modifier \STATIC{}. A library variable is implicitly static. It is a compile-time error to preface a top-level variable declaration with the built-in identifier (\ref{ identifierReference}) \STATIC{}. 432 A {\em static variable} is a variable that is not associated with a particular i nstance, but rather with an entire library or class. Static variables include l ibrary variables and class variables. Class variables are variables whose declar ation is immediately nested inside a class declaration and includes the modifier \STATIC{}. A library variable is implicitly static. It is a compile-time error to preface a top-level variable declaration with the built-in identifier (\ref{ identifierReference}) \STATIC{}.
437 433
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 753
758 \LMHash{} 754 \LMHash{}
759 A {\em required formal parameter} may be specified in one of three ways: 755 A {\em required formal parameter} may be specified in one of three ways:
760 \begin{itemize} 756 \begin{itemize}
761 \item By means of a function signature that names the parameter and describes it s type as a function type (\ref{functionTypes}). It is a compile-time error if any default values are specified in the signature of such a function type.% expl ain what the type is in this case? Where is this described in general? 757 \item By means of a function signature that names the parameter and describes it s type as a function type (\ref{functionTypes}). It is a compile-time error if any default values are specified in the signature of such a function type.% expl ain what the type is in this case? Where is this described in general?
762 \item As an initializing formal, which is only valid as a parameter to a generat ive constructor (\ref{generativeConstructors}). % do we need to say this, or any thing more? 758 \item As an initializing formal, which is only valid as a parameter to a generat ive constructor (\ref{generativeConstructors}). % do we need to say this, or any thing more?
763 \item Via an ordinary variable declaration (\ref{variables}). 759 \item Via an ordinary variable declaration (\ref{variables}).
764 \end{itemize} 760 \end{itemize}
765 761
766 \begin{grammar} 762 \begin{grammar}
767 {\bf normalFormalParameter:}functionSignature; 763 {\bf normalFormalParameter:}functionFormalParameter;
768 fieldFormalParameter; 764 fieldFormalParameter;
769 simpleFormalParameter 765 simpleFormalParameter
770 . 766 .
771 767
772 {\bf simpleFormalParameter:}declaredIdentifier; 768 {\bf functionFormalParameter:}
773 metadata identifier 769 metadata \COVARIANT{}? returnType? identifier formalParameterList
770 .
771
772 {\bf simpleFormalParameter:}
773 metadata \COVARIANT{}? finalConstVarOrType? identifier;
774 . 774 .
775 775
776 {\bf fieldFormalParameter:} 776 {\bf fieldFormalParameter:}
777 metadata finalConstVarOrType? \THIS{} `{\escapegrammar .}' identifier formalP arameterList? 777 metadata finalConstVarOrType? \THIS{} `{\escapegrammar .}' identifier formalP arameterList?
778 . 778 .
779 \end{grammar} 779 \end{grammar}
780 780
781 \LMHash{}
782 It is possible to include the modifier \COVARIANT{} in some forms of parameter d eclarations.
783 This modifier has no effect.
784
785 \rationale{
786 The modifier \COVARIANT{} is used in strong mode.
787 The modifier is allowed here even though it has no effect, such that source code can be used in both contexts.
788 }
789
790 \LMHash{}
791 It is a compile-time error if the modifier \COVARIANT{} occurs on a parameter of a function which is not an instance method, instance setter, or instance operat or.
792
781 %\subsubsection{Rest Formals} 793 %\subsubsection{Rest Formals}
782 %\LMLabel{restFormals} 794 %\LMLabel{restFormals}
783 795
784 %A rest formal $R$ must be the last parameter in a formal parameter list. If a type $T$ is specified for $R$, it signifies that the type of $R$ is $T[]$. 796 %A rest formal $R$ must be the last parameter in a formal parameter list. If a type $T$ is specified for $R$, it signifies that the type of $R$ is $T[]$.
785 797
786 %\begin{grammar} 798 %\begin{grammar}
787 %restFormalParameter: 799 %restFormalParameter:
788 % finalConstVarOrType? '{\escapegrammar ...}' identifier 800 % finalConstVarOrType? '{\escapegrammar ...}' identifier
789 %\end{grammar} 801 %\end{grammar}
790 802
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 \STATIC{}? functionSignature; 913 \STATIC{}? functionSignature;
902 \STATIC{}? getterSignature; 914 \STATIC{}? getterSignature;
903 \STATIC{}? setterSignature; 915 \STATIC{}? setterSignature;
904 operatorSignature 916 operatorSignature
905 . 917 .
906 918
907 {\bf declaration:}constantConstructorSignature (redirection $|$ initializers)?; 919 {\bf declaration:}constantConstructorSignature (redirection $|$ initializers)?;
908 constructorSignature (redirection $|$ initializers)?; 920 constructorSignature (redirection $|$ initializers)?;
909 \EXTERNAL{} constantConstructorSignature; 921 \EXTERNAL{} constantConstructorSignature;
910 \EXTERNAL{} constructorSignature; 922 \EXTERNAL{} constructorSignature;
911 ((\EXTERNAL{} \STATIC{} ?))? getterSignature; 923 ((\EXTERNAL{} \STATIC{}?))? getterSignature;
912 ((\EXTERNAL{} \STATIC{}?))? setterSignature; 924 ((\EXTERNAL{} \STATIC{}?))? setterSignature;
913 \EXTERNAL{}? operatorSignature; 925 \EXTERNAL{}? operatorSignature;
914 ((\EXTERNAL{} \STATIC{}?))? functionSignature; 926 ((\EXTERNAL{} \STATIC{}?))? functionSignature;
915 \STATIC{} (\FINAL{} $|$ \CONST{}) type? staticFinalDeclarationList; 927 \STATIC{} (\FINAL{} $|$ \CONST{}) type? staticFinalDeclarationList;
916 % \CONST{} type? staticFinalDeclarationList; 928 % \CONST{} type? staticFinalDeclarationList;
917 \FINAL{} type? initializedIdentifierList; 929 \FINAL{} type? initializedIdentifierList;
918 \STATIC{}? (\VAR{} $|$ type) initializedIdentifierList 930 (\STATIC{} $|$ \COVARIANT{})? (\VAR{} $|$ type) initializedIdentifierList
919 . 931 .
920 932
921 {\bf staticFinalDeclarationList:} 933 {\bf staticFinalDeclarationList:}
922 staticFinalDeclaration (`,' staticFinalDeclaration)* 934 staticFinalDeclaration (`,' staticFinalDeclaration)*
923 . 935 .
924 936
925 {\bf staticFinalDeclaration:} 937 {\bf staticFinalDeclaration:}
926 identifier `=' expression 938 identifier `=' expression
927 . 939 .
928 940
929 \end{grammar} 941 \end{grammar}
930 942
931 \LMHash{} 943 \LMHash{}
944 It is possible to include the modifier \COVARIANT{} in some forms of declaration s.
945 This modifier has no effect.
946
947 \rationale{
948 The modifier \COVARIANT{} is used in strong mode.
949 The modifier is allowed here even though it has no effect, such that source code can be used in both contexts.
950 }
951
952 \LMHash{}
932 A class has constructors, instance members and static members. The instance mem bers of a class are its instance methods, getters, setters and instance variable s. The static members of a class are its static methods, getters, setters and st atic variables. The members of a class are its static and instance members. 953 A class has constructors, instance members and static members. The instance mem bers of a class are its instance methods, getters, setters and instance variable s. The static members of a class are its static methods, getters, setters and st atic variables. The members of a class are its static and instance members.
933 954
934 \LMHash{} 955 \LMHash{}
935 A class has several scopes: 956 A class has several scopes:
936 \begin{itemize} 957 \begin{itemize}
937 \item A {\em type-parameter scope}, which is empty if the class is not generic ( \ref{generics}). The enclosing scope of the type-parameter scope of a class is the enclosing scope of the class declaration. 958 \item A {\em type-parameter scope}, which is empty if the class is not generic ( \ref{generics}). The enclosing scope of the type-parameter scope of a class is the enclosing scope of the class declaration.
938 \item A {\em static scope}. The enclosing scope of the static scope of a class is the type parameter scope (\ref{generics}) of the class. 959 \item A {\em static scope}. The enclosing scope of the static scope of a class is the type parameter scope (\ref{generics}) of the class.
939 \item An {\em instance scope}. 960 \item An {\em instance scope}.
940 The enclosing scope of a class' instance scope is the class' static scope. 961 The enclosing scope of a class' instance scope is the class' static scope.
941 \end{itemize} 962 \end{itemize}
(...skipping 4398 matching lines...) Expand 10 before | Expand all | Expand 10 after
5340 An assignable expression of the form \code{\SUPER{}[$e_2$]} is equivalent to the method invocation \code{\SUPER{}.[]($e_2$)}. 5361 An assignable expression of the form \code{\SUPER{}[$e_2$]} is equivalent to the method invocation \code{\SUPER{}.[]($e_2$)}.
5341 5362
5342 \subsection{ Identifier Reference} 5363 \subsection{ Identifier Reference}
5343 \LMLabel{identifierReference} 5364 \LMLabel{identifierReference}
5344 5365
5345 \LMHash{} 5366 \LMHash{}
5346 An {\em identifier expression} consists of a single identifier; it provides acce ss to an object via an unqualified name. 5367 An {\em identifier expression} consists of a single identifier; it provides acce ss to an object via an unqualified name.
5347 5368
5348 \begin{grammar} 5369 \begin{grammar}
5349 {\bf identifier:} 5370 {\bf identifier:}
5350 IDENTIFIER 5371 IDENTIFIER
5351 . 5372 .
5352 5373
5353 5374 {\bf IDENTIFIER\_NO\_DOLLAR:}
5354 {\bf IDENTIFIER\_NO\_DOLLAR:}
5355 IDENTIFIER\_START\_NO\_DOLLAR IDENTIFIER\_PART\_NO\_DOLLAR* 5375 IDENTIFIER\_START\_NO\_DOLLAR IDENTIFIER\_PART\_NO\_DOLLAR*
5356 . 5376 .
5357 5377
5358 {\bf IDENTIFIER:} 5378 {\bf IDENTIFIER:}
5359 IDENTIFIER\_START IDENTIFIER\_PART* 5379 IDENTIFIER\_START IDENTIFIER\_PART*
5360 . 5380 .
5361 5381
5362 {\bf BUILT\_IN\_IDENTIFIER:} \ABSTRACT{}; 5382 {\bf BUILT\_IN\_IDENTIFIER:}\ABSTRACT{};
5363 \AS{}; 5383 \AS{};
5364 \DEFERRED{}; 5384 \COVARIANT{};
5365 \DYNAMIC{}; 5385 \DEFERRED{};
5366 \EXPORT{}; 5386 \DYNAMIC{};
5367 \EXTERNAL{}; 5387 \EXPORT{};
5368 \FACTORY{}; 5388 \EXTERNAL{};
5369 \GET{}; 5389 \FACTORY{};
5370 \IMPLEMENTS{}; 5390 \GET{};
5371 \IMPORT{}; 5391 \IMPLEMENTS{};
5372 \LIBRARY{}; 5392 \IMPORT{};
5373 \OPERATOR{}; 5393 \LIBRARY{};
5374 \PART{}; 5394 \OPERATOR{};
5395 \PART{};
5375 \SET{}; 5396 \SET{};
5376 \STATIC{}; 5397 \STATIC{};
5377 \TYPEDEF{} 5398 \TYPEDEF{}
5378 . 5399 .
5379 5400
5380 {\bf IDENTIFIER\_START:}IDENTIFIER\_START\_NO\_DOLLAR; 5401 {\bf IDENTIFIER\_START:}IDENTIFIER\_START\_NO\_DOLLAR;
5381 `\$' 5402 `\$'
5382 . 5403 .
5383 5404
5384 {\bf IDENTIFIER\_START\_NO\_DOLLAR:}LETTER; 5405 {\bf IDENTIFIER\_START\_NO\_DOLLAR:}LETTER;
5385 `\_' 5406 `\_'
5386 . 5407 .
5387 5408
5388 {\bf IDENTIFIER\_PART\_NO\_DOLLAR:}IDENTIFIER\_START\_NO\_DOLLAR; 5409 {\bf IDENTIFIER\_PART\_NO\_DOLLAR:}IDENTIFIER\_START\_NO\_DOLLAR;
5389 DIGIT 5410 DIGIT
5390 . 5411 .
5391 5412
5392
5393 {\bf IDENTIFIER\_PART:}IDENTIFIER\_START; 5413 {\bf IDENTIFIER\_PART:}IDENTIFIER\_START;
5394 DIGIT 5414 DIGIT
5395 . 5415 .
5396 5416
5397
5398
5399 {\bf qualified:} 5417 {\bf qualified:}
5400 identifier (`{\escapegrammar .}' identifier)? 5418 identifier (`{\escapegrammar .}' identifier)?
5401 . 5419 .
5402 \end{grammar} 5420 \end{grammar}
5403 5421
5404 \LMHash{} 5422 \LMHash{}
5405 A built-in identifier is one of the identifiers produced by the production {\em BUILT\_IN\_IDENTIFIER}. 5423 A built-in identifier is one of the identifiers produced by the production {\em BUILT\_IN\_IDENTIFIER}.
5406 It is a compile-time error if a built-in identifier is used as the declared name of a prefix, class, type parameter or type alias. 5424 It is a compile-time error if a built-in identifier is used as the declared name of a prefix, class, type parameter or type alias.
5407 It is a compile-time error to use a built-in identifier other than \DYNAMIC{} in a type annotation or type parameter. 5425 It is a compile-time error to use a built-in identifier other than \DYNAMIC{} in a type annotation or type parameter.
5408 5426
5409 \rationale{ 5427 \rationale{
5410 Built-in identifiers are identifiers that are used as keywords in Dart, but are not reserved words in Javascript. To minimize incompatibilities when porting Jav ascript code to Dart, we do not make these into reserved words. A built-in ident ifier may not be used to name a class or type. In other words, they are treated as reserved words when used as types. This eliminates many confusing situations without causing compatibility problems. After all, a Javascript program has no type declarations or annotations so no clash can occur. Furthermore, types shou ld begin with an uppercase letter (see the appendix) and so no clash should occu r in any Dart user program anyway. 5428 Built-in identifiers are identifiers that are used as keywords in Dart, but are not reserved words in Javascript. To minimize incompatibilities when porting Jav ascript code to Dart, we do not make these into reserved words. A built-in ident ifier may not be used to name a class or type. In other words, they are treated as reserved words when used as types. This eliminates many confusing situations without causing compatibility problems. After all, a Javascript program has no type declarations or annotations so no clash can occur. Furthermore, types shou ld begin with an uppercase letter (see the appendix) and so no clash should occu r in any Dart user program anyway.
5411 } 5429 }
(...skipping 2703 matching lines...) Expand 10 before | Expand all | Expand 10 after
8115 8133
8116 The invariant that each normative paragraph is associated with a line 8134 The invariant that each normative paragraph is associated with a line
8117 containing the text \LMHash{} should be maintained. Extra occurrences 8135 containing the text \LMHash{} should be maintained. Extra occurrences
8118 of \LMHash{} can be added if needed, e.g., in order to make 8136 of \LMHash{} can be added if needed, e.g., in order to make
8119 individual \item{}s in itemized lists addressable. Each \LM.. command 8137 individual \item{}s in itemized lists addressable. Each \LM.. command
8120 must occur on a separate line. \LMHash{} must occur immediately 8138 must occur on a separate line. \LMHash{} must occur immediately
8121 before the associated paragraph, and \LMLabel must occur immediately 8139 before the associated paragraph, and \LMLabel must occur immediately
8122 after the associated \section{}, \subsection{} etc. 8140 after the associated \section{}, \subsection{} etc.
8123 8141
8124 ---------------------------------------------------------------------- 8142 ----------------------------------------------------------------------
OLDNEW
« no previous file with comments | « docs/language/dart.sty ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698