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

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

Issue 2444843002: Make `C()`, where `C` is a class name, a compile-time error. (Closed)
Patch Set: Also prohibit calls on constructors when not a single identifier. Created 4 years, 1 month 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 | « 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{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 \newcommand{\code}[1]{{\sf #1}} 8 \newcommand{\code}[1]{{\sf #1}}
9 \title{Dart Programming Language Specification \\ 9 \title{Dart Programming Language Specification \\
10 {4th edition draft}\\ 10 {4th edition draft}\\
(...skipping 3692 matching lines...) Expand 10 before | Expand all | Expand 10 after
3703 An unqualified function invocation $i$ has the form 3703 An unqualified function invocation $i$ has the form
3704 3704
3705 $id(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}: a_{n+k})$, 3705 $id(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}: a_{n+k})$,
3706 3706
3707 where $id$ is an identifier. 3707 where $id$ is an identifier.
3708 3708
3709 \LMHash{} 3709 \LMHash{}
3710 If there exists a lexically visible declaration named $id$, let $f_{id}$ be the innermost such declaration. Then: 3710 If there exists a lexically visible declaration named $id$, let $f_{id}$ be the innermost such declaration. Then:
3711 \begin{itemize} 3711 \begin{itemize}
3712 \item 3712 \item
3713 If $f_{id}$ is a prefix object, a compile-time error occurs. 3713 If $f_{id}$ is a prefix object or a type literal, a compile-time error occurs.
3714 \item 3714 \item
3715 If $f_{id}$ is a local function, a library function, a library or static getter or a variable then $i$ is interpreted as a function expression invocation (\ref {functionExpressionInvocation}). 3715 If $f_{id}$ is a local function, a library function, a library or static getter or a variable then $i$ is interpreted as a function expression invocation (\ref {functionExpressionInvocation}).
3716 \item 3716 \item
3717 Otherwise, if $f_{id}$ is a static method of the enclosing class $C$, $i$ is equ ivalent to $C.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k}) $. 3717 Otherwise, if $f_{id}$ is a static method of the enclosing class $C$, $i$ is equ ivalent to $C.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k}) $.
3718 \item Otherwise, $f_{id}$ is considered equivalent to the ordinary method invoca tion $\THIS{}.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k}) $. 3718 \item Otherwise, $f_{id}$ is considered equivalent to the ordinary method invoca tion $\THIS{}.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k}) $.
3719 \end{itemize} 3719 \end{itemize}
3720 3720
3721 \LMHash{} 3721 \LMHash{}
3722 Otherwise, if $i$ occurs inside a top level or static function (be it function, method, getter, or setter) or variable initializer, evaluation of $i$ causes a \cd{NoSuchMethodError} to be thrown. 3722 Otherwise, if $i$ occurs inside a top level or static function (be it function, method, getter, or setter) or variable initializer, evaluation of $i$ causes a \cd{NoSuchMethodError} to be thrown.
3723 3723
3724 \LMHash{} 3724 \LMHash{}
3725 If $i$ does not occur inside a top level or static function, $i$ is equivalent t o $\THIS{}.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. 3725 If $i$ does not occur inside a top level or static function, $i$ is equivalent t o $\THIS{}.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$.
3726 3726
3727 3727
3728 % Should also say: 3728 % Should also say:
3729 % It is a static warning if $i$ occurs inside a top level or static function (b e it function, method, getter, or setter) or variable initializer and there is no lexically visible declaration named $id$ in scope. 3729 % It is a static warning if $i$ occurs inside a top level or static function (b e it function, method, getter, or setter) or variable initializer and there is no lexically visible declaration named $id$ in scope.
3730 3730
3731 3731
3732 3732
3733 3733
3734 3734
3735 \subsubsection{ Function Expression Invocation} 3735 \subsubsection{ Function Expression Invocation}
3736 \LMLabel{functionExpressionInvocation} 3736 \LMLabel{functionExpressionInvocation}
3737 3737
3738 \LMHash{} 3738 \LMHash{}
3739 A function expression invocation $i$ has the form 3739 A function expression invocation $i$ has the form
3740 3740
3741 $e_f(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$, 3741 $e_f(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$,
3742 3742
3743 where $e_f$ is an expression. If $e_f$ is an identifier $id$, then $id$ must nec essarily denote a local function, a library function, a library or static getter or a variable as described above, or $i$ is not considered a function expressio n invocation. If $e_f$ is a property extraction expression (\ref{propertyExtract ion}), then $i$ is is not a function expression invocation and is instead recogn ized as an ordinary method invocation (\ref{ordinaryInvocation}). 3743 where $e_f$ is an expression. If $e_f$ is an identifier $id$, then $id$ must nec essarily denote a local function, a library function, a library or static getter or a variable as described above, or $i$ is not considered a function expressio n invocation.
3744 It is a compile time error if $e_f$ is a type literal, or $e_f$ is $T.k$ where $ T$ is a type literal and $k$ is the name of a constructor on the class denoted b y $T$.
3745 Otherwise, if $e_f$ is a property extraction expression (\ref{propertyExtraction }), then $i$ is is not a function expression invocation and is instead recognize d as an ordinary method invocation (\ref{ordinaryInvocation}). It is a compile-t ime error if $e_f$ denotes a constructor.
eernst 2016/10/25 08:04:53 In which case can $e_f$ denote a constructor, whic
Lasse Reichstein Nielsen 2016/11/16 11:36:03 Agree, it should be covered by the previous line.
3744 3746
3745 \commentary{ 3747 \commentary{
3746 \code{$a.b(x)$} is parsed as a method invocation of method \code{$b()$} on objec t \code{$a$}, not as an invocation of getter \code{$b$} on \code{$a$} followed b y a function call \code{$(a.b)(x)$}. If a method or getter \code{$b$} exists, t he two will be equivalent. However, if \code{$b$} is not defined on \code{$a$}, the resulting invocation of \code{noSuchMethod()} would differ. The \code{Invoc ation} passed to \code{noSuchMethod()} would describe a call to a method \code{$ b$} with argument \code{$x$} in the former case, and a call to a getter \code{$b $} (with no arguments) in the latter. 3748 \code{$a.b(x)$} is parsed as a method invocation of method \code{$b()$} on objec t \code{$a$}, not as an invocation of getter \code{$b$} on \code{$a$} followed b y a function call \code{$(a.b)(x)$}. If a method or getter \code{$b$} exists, t he two will be equivalent. However, if \code{$b$} is not defined on \code{$a$}, the resulting invocation of \code{noSuchMethod()} would differ. The \code{Invoc ation} passed to \code{noSuchMethod()} would describe a call to a method \code{$ b$} with argument \code{$x$} in the former case, and a call to a getter \code{$b $} (with no arguments) in the latter.
3747 } 3749 }
3748 3750
3749 \LMHash{} 3751 \LMHash{}
3750 Otherwise: 3752 Otherwise:
3751 3753
3752 A function expression invocation $e_f(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldot s , x_{n+k}: a_{n+k})$ is equivalent to $e_f.call(a_1, \ldots , a_n, x_{n+1}: a_ {n+1}, \ldots , x_{n+k}: a_{n+k})$. 3754 A function expression invocation $e_f(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldot s , x_{n+k}: a_{n+k})$ is equivalent to $e_f.call(a_1, \ldots , a_n, x_{n+1}: a_ {n+1}, \ldots , x_{n+k}: a_{n+k})$.
3753 3755
(...skipping 4158 matching lines...) Expand 10 before | Expand all | Expand 10 after
7912 7914
7913 The invariant that each normative paragraph is associated with a line 7915 The invariant that each normative paragraph is associated with a line
7914 containing the text \LMHash{} should be maintained. Extra occurrences 7916 containing the text \LMHash{} should be maintained. Extra occurrences
7915 of \LMHash{} can be added if needed, e.g., in order to make 7917 of \LMHash{} can be added if needed, e.g., in order to make
7916 individual \item{}s in itemized lists addressable. Each \LM.. command 7918 individual \item{}s in itemized lists addressable. Each \LM.. command
7917 must occur on a separate line. \LMHash{} must occur immediately 7919 must occur on a separate line. \LMHash{} must occur immediately
7918 before the associated paragraph, and \LMLabel must occur immediately 7920 before the associated paragraph, and \LMLabel must occur immediately
7919 after the associated \section{}, \subsection{} etc. 7921 after the associated \section{}, \subsection{} etc.
7920 7922
7921 ---------------------------------------------------------------------- 7923 ----------------------------------------------------------------------
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