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

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

Issue 26990005: It's an error if to instantiate a subclass of a malbounded type,or a type variable. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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{dart} 3 \usepackage{dart}
4 \usepackage{bnf} 4 \usepackage{bnf}
5 \usepackage{hyperref} 5 \usepackage{hyperref}
6 \newcommand{\code}[1]{{\sf #1}} 6 \newcommand{\code}[1]{{\sf #1}}
7 \title{Dart Programming Language Specification \\ 7 \title{Dart Programming Language Specification \\
8 {\large Draft Version 0.71}} 8 {\large Draft Version 0.71}}
9 \author{The Dart Team} 9 \author{The Dart Team}
10 \begin{document} 10 \begin{document}
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 \ref{return}: Added warning if \RETURN{} without expression mixed with \RETURN{} with an expression. 504 \ref{return}: Added warning if \RETURN{} without expression mixed with \RETURN{} with an expression.
505 505
506 \ref{exports}: Ensure that exports treat \code{dart:} libs specially, like impor ts do. 506 \ref{exports}: Ensure that exports treat \code{dart:} libs specially, like impor ts do.
507 507
508 \ref{typePromotion}: Added notion of type promotion. 508 \ref{typePromotion}: Added notion of type promotion.
509 509
510 \ref{typedef}: Banned all recursion in typedefs. 510 \ref{typedef}: Banned all recursion in typedefs.
511 511
512 \subsubsection{Changes Since Version 0.7} 512 \subsubsection{Changes Since Version 0.7}
513 513
514 \ref{new}: Instantiating subclasses of malbounded types is a dynamic error.
515
514 \ref{leastUpperBounds}: Extended LUBs to all types. 516 \ref{leastUpperBounds}: Extended LUBs to all types.
515 517
516 518
517 519
518 \section{Notation} 520 \section{Notation}
519 \label{notation} 521 \label{notation}
520 522
521 We distinguish between normative and non-normative text. Normative text defines the rules of Dart. It is given in this font. At this time, non-normative text in cludes: 523 We distinguish between normative and non-normative text. Normative text defines the rules of Dart. It is given in this font. At this time, non-normative text in cludes:
522 \begin{itemize} 524 \begin{itemize}
523 \item[Rationale] Discussion of the motivation for language design decisions appe ars in italics. \rationale{Distinguishing normative from non-normative helps cla rify what part of the text is binding and what part is merely expository.} 525 \item[Rationale] Discussion of the motivation for language design decisions appe ars in italics. \rationale{Distinguishing normative from non-normative helps cla rify what part of the text is binding and what part is merely expository.}
(...skipping 2639 matching lines...) Expand 10 before | Expand all | Expand 10 after
3163 \end{itemize} 3165 \end{itemize}
3164 3166
3165 If $R$ is a generic with $l \ne m$ type parameters then for $ i \in 1 .. l$, let $V_i = \DYNAMIC{}$. In any other case, let $V_i = U_i$ for $ i \in 1 .. m$. 3167 If $R$ is a generic with $l \ne m$ type parameters then for $ i \in 1 .. l$, let $V_i = \DYNAMIC{}$. In any other case, let $V_i = U_i$ for $ i \in 1 .. m$.
3166 3168
3167 Evaluation of $e$ proceeds as follows: 3169 Evaluation of $e$ proceeds as follows:
3168 3170
3169 First, the argument list $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k} : a_{n+k})$ is evaluated. 3171 First, the argument list $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k} : a_{n+k})$ is evaluated.
3170 3172
3171 Then, if $q$ is a non-factory constructor of an abstract class then an \code{Abs tractClassInstantiationError} is thrown. 3173 Then, if $q$ is a non-factory constructor of an abstract class then an \code{Abs tractClassInstantiationError} is thrown.
3172 3174
3173 If $T$ is malformed a dynamic error occurs. In checked mode, if $T$ is malbound ed a dynamic error occurs. 3175 If $T$ is malformed or if $T$ is type variable a dynamic error occurs. In check ed mode, if $T$ or any of its superclasses is malbounded a dynamic error occurs.
regis 2013/10/16 00:48:34 is *a* type variable Can a class be malbounded? W
gbracha 2013/10/16 00:54:40 Done.
3174 Otherwise, if $q$ is not defined or not accessible, a \code{NoSuchMethodError} is thrown. If $q$ has less than $n$ positional parameters or more than $n$ req uired parameters, or if $q$ lacks any of the keyword parameters $\{ x_{n+1}, \ld ots, x_{n+k}\}$ a \code{NoSuchMethodError} is thrown. 3176 Otherwise, if $q$ is not defined or not accessible, a \code{NoSuchMethodError} is thrown. If $q$ has less than $n$ positional parameters or more than $n$ req uired parameters, or if $q$ lacks any of the keyword parameters $\{ x_{n+1}, \ld ots, x_{n+k}\}$ a \code{NoSuchMethodError} is thrown.
3175 3177
3176 Otherwise, if $q$ is a generative constructor (\ref{generativeConstructors}), th en: 3178 Otherwise, if $q$ is a generative constructor (\ref{generativeConstructors}), th en:
3177 3179
3178 %Let $T_i$ be the type parameters of $R$ (if any) and let $B_i$ be the bound of $T_i, 1 \le i \le l$. 3180 %Let $T_i$ be the type parameters of $R$ (if any) and let $B_i$ be the bound of $T_i, 1 \le i \le l$.
3179 %In checked mode, it is a dynamic type error if $V_i$ is not a subtype of $[V_ 1, \ldots, V_l/T_1, \ldots, T_l]B_i, i \in 1.. l$. 3181 %In checked mode, it is a dynamic type error if $V_i$ is not a subtype of $[V_ 1, \ldots, V_l/T_1, \ldots, T_l]B_i, i \in 1.. l$.
3180 3182
3181 \commentary{Note that it this point we are assured that the number of actual typ e arguments match the number of formal type parameters.} 3183 \commentary{Note that it this point we are assured that the number of actual typ e arguments match the number of formal type parameters.}
3182 3184
3183 A fresh instance (\ref{generativeConstructors}), $i$, of class $R$ is allocated . For each instance variable $f$ of $i$, if the variable declaration of $f$ has an initializer expression $e_f$, then $e_f$ is evaluated to an object $o_f$ and $f$ is bound to $o_f$. Otherwise $f$ is bound to \NULL{}. 3185 A fresh instance (\ref{generativeConstructors}), $i$, of class $R$ is allocated . For each instance variable $f$ of $i$, if the variable declaration of $f$ has an initializer expression $e_f$, then $e_f$ is evaluated to an object $o_f$ and $f$ is bound to $o_f$. Otherwise $f$ is bound to \NULL{}.
(...skipping 2428 matching lines...) Expand 10 before | Expand all | Expand 10 after
5612 %Likewise, we could opt to ignore malformed types entirely in checked mode. 5614 %Likewise, we could opt to ignore malformed types entirely in checked mode.
5613 5615
5614 %For now, we have opted to treat a malformed type as an error type that has no s ubtypes or supertypes, and which causes a runtime error when tested against any other type. 5616 %For now, we have opted to treat a malformed type as an error type that has no s ubtypes or supertypes, and which causes a runtime error when tested against any other type.
5615 } 5617 }
5616 5618
5617 \commentary{ 5619 \commentary{
5618 Here is an example involving malbounded types: 5620 Here is an example involving malbounded types:
5619 } 5621 }
5620 5622
5621 \begin{dartCode} 5623 \begin{dartCode}
5622 \INTERFACE{} I$<$T \EXTENDS{} num$>$ \{\} 5624 \CLASS{} I$<$T \EXTENDS{} num$>$ \{\}
5623 \INTERFACE{} J \{\} 5625 \CLASS{} J \{\}
5624 5626
5625 \CLASS{} A$<$T$>$ \IMPLEMENTS{} J, I$<$T$>$ // type warning: T is not a subtype of num 5627 \CLASS{} A$<$T$>$ \IMPLEMENTS{} J, I$<$T$>$ // type warning: T is not a subtype of num
5626 \{ ... 5628 \{ ...
5627 \} 5629 \}
5628 \end{dartCode} 5630 \end{dartCode}
5629 5631
5630 \commentary{Given the declarations above, the following} 5632 \commentary{Given the declarations above, the following}
5631 5633
5632 \begin{dartCode} 5634 \begin{dartCode}
5633 I x = \NEW{} A$<$String$>$(); 5635 I x = \NEW{} A$<$String$>$();
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
6123 \item The names of compile time constant variables never use lower case letters. If they consist of multiple words, those words are separated by underscores. Ex amples: PI, I\_AM\_A\_CONSTANT. 6125 \item The names of compile time constant variables never use lower case letters. If they consist of multiple words, those words are separated by underscores. Ex amples: PI, I\_AM\_A\_CONSTANT.
6124 \item The names of functions (including getters, setters, methods and local or l ibrary functions) and non-constant variables begin with a lowercase letter. If t he name consists of multiple words, each word (except the first) begins with an uppercase letter. No other uppercase letters are used. Examples: camlCase, dar t4TheWorld 6126 \item The names of functions (including getters, setters, methods and local or l ibrary functions) and non-constant variables begin with a lowercase letter. If t he name consists of multiple words, each word (except the first) begins with an uppercase letter. No other uppercase letters are used. Examples: camlCase, dar t4TheWorld
6125 \item The names of types (including classes and type aliases) begin with an uppe r case letter. If the name consists of multiple words, each word begins with an uppercase letter. No other uppercase letters are used. Examples: CamlCase, D art4TheWorld. 6127 \item The names of types (including classes and type aliases) begin with an uppe r case letter. If the name consists of multiple words, each word begins with an uppercase letter. No other uppercase letters are used. Examples: CamlCase, D art4TheWorld.
6126 \item The names of type variables are short (preferably single letter). Examples : T, S, K, V , E. 6128 \item The names of type variables are short (preferably single letter). Examples : T, S, K, V , E.
6127 \item The names of libraries or library prefixes never use upper case letters. I f they consist of multiple words, those words are separated by underscores. Exam ple: my\_favorite\_library. 6129 \item The names of libraries or library prefixes never use upper case letters. I f they consist of multiple words, those words are separated by underscores. Exam ple: my\_favorite\_library.
6128 \end{itemize} 6130 \end{itemize}
6129 } 6131 }
6130 6132
6131 6133
6132 \end{document} 6134 \end{document}
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698