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

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

Issue 2852533003: Change specification of main. (Closed)
Patch Set: Address comments. Created 3 years, 6 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 | « 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 \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 7169 matching lines...) Expand 10 before | Expand all | Expand 10 after
7180 \LMHash{} 7180 \LMHash{}
7181 Compiling a part directive of the form \code{\PART{} $s$;} causes the Dart syste m to attempt to compile the contents of the URI that is the value of $s$. The to p-level declarations at that URI are then compiled by the Dart compiler in the s cope of the current library. It is a compile-time error if the contents of the U RI are not a valid part declaration. It is a static warning if the referenced pa rt declaration $p$ names a library other than the current library as the library to which $p$ belongs. 7181 Compiling a part directive of the form \code{\PART{} $s$;} causes the Dart syste m to attempt to compile the contents of the URI that is the value of $s$. The to p-level declarations at that URI are then compiled by the Dart compiler in the s cope of the current library. It is a compile-time error if the contents of the U RI are not a valid part declaration. It is a static warning if the referenced pa rt declaration $p$ names a library other than the current library as the library to which $p$ belongs.
7182 7182
7183 \LMHash{} 7183 \LMHash{}
7184 It's a compile-time error if the same library contains two part directives with the same URI. 7184 It's a compile-time error if the same library contains two part directives with the same URI.
7185 7185
7186 \subsection{Scripts} 7186 \subsection{Scripts}
7187 \LMLabel{scripts} 7187 \LMLabel{scripts}
7188 7188
7189 \LMHash{} 7189 \LMHash{}
7190 A {\em script} is a library whose exported namespace (\ref{exports}) includes a top-level member named \code{main}. It is a static warning if the static type of \code{main} is not assignable to a function type or is a function type with m ore than two required parameters. 7190 A {\em script} is a library whose exported namespace (\ref{exports}) includes
7191 a top-level function declaration named \code{main}
7192 that has either zero, one or two required arguments.
7191 7193
7192 A script $S$ may be executed as follows: 7194 A script $S$ is executed as follows:
7193 7195
7194 \LMHash{} 7196 \LMHash{}
7195 First, $S$ is compiled as a library as specified above. Then, the top-level func tion \code{main} that is in the exported namespace of $S$ is invoked. If \code{m ain} has no positional parameters, it is invoked with no arguments. Otherwise if \code{main} has exactly one positional parameter, it is invoked with a single a ctual argument whose runtime type implements \code{List<String>}. Otherwise \co de{main} is invoked with the following two actual arguments: 7197 First, $S$ is compiled as a library as specified above.
7198 Then, the top-level function defined by \code{main}
7199 in the exported namespace of $S$ is invoked (\ref{functionInvocation})
7200 as follows:
7201 If \code{main} can be be called with with two positional arguments,
7202 it is invoked with the following two actual arguments:
7196 \begin{enumerate} 7203 \begin{enumerate}
7197 \item An object whose runtime type implements \code{List<String>}. 7204 \item An object whose runtime type implements \code{List<String>}.
7198 \item The initial message of the current isolate $i$ as determined by the invoca tion of \code{Isolate.spawnUri} that spawned $i$. 7205 \item An object specified when the current isolate $i$ was created,
7206 for example through the invocation of \code{Isolate.spawnUri} that spawned $i$,
7207 or \NULL{} if no such object was supplied.
7199 \end{enumerate} 7208 \end{enumerate}
7209 If \code{main} cannot be called with two positional arguments,
7210 but it can be called with one positional argument,
7211 it is invoked with an object whose runtime type implements \code{List<String>}
7212 as the only argument.
7213 If \code{main} cannot be called with one or two positional arguments,
7214 it is invoked with no arguments.
7200 7215
7201 \LMHash{} 7216 \commentary{
7202 It is a run time error if $S$ does not declare or export either: 7217 Note that if \code{main} requires more than two positional arguments,
7203 \begin{itemize} 7218 the library is not considered a script.
7204 \item A top-level function named \code{main}, or
7205 \item A top-level getter named \code{main} that returns a function.
7206 \end{itemize}
7207
7208 \commentary {
7209 Note that if \code{main} requires more than two arguments, a run time error will occur.
7210 } 7219 }
7211 7220
7212 \rationale{ 7221 \commentary{
7213 The names of scripts are optional, in the interests of interactive, informal use . However, any script of long term value should be given a name as a matter of g ood practice. 7222 A Dart program will typically be executed by executing a script.
7214 } 7223 }
7215 7224
7216 \commentary { 7225 \LMHASH{}
7217 A Dart program will typically be executed by executing a script. 7226 If a non-script library is provided where a script is expected,
7218 } 7227 it precludes execution.
7228 As such, it should be reported as a compile-time error,
7229 even if that library compiles successfully as a non-script library.
7219 7230
7220 \subsection{URIs} 7231 \subsection{URIs}
7221 \LMLabel{uris} 7232 \LMLabel{uris}
7222 7233
7223 \LMHash{} 7234 \LMHash{}
7224 URIs are specified by means of string literals: 7235 URIs are specified by means of string literals:
7225 7236
7226 \begin{grammar} 7237 \begin{grammar}
7227 {\bf uri:} 7238 {\bf uri:}
7228 stringLiteral 7239 stringLiteral
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
8177 8188
8178 The invariant that each normative paragraph is associated with a line 8189 The invariant that each normative paragraph is associated with a line
8179 containing the text \LMHash{} should be maintained. Extra occurrences 8190 containing the text \LMHash{} should be maintained. Extra occurrences
8180 of \LMHash{} can be added if needed, e.g., in order to make 8191 of \LMHash{} can be added if needed, e.g., in order to make
8181 individual \item{}s in itemized lists addressable. Each \LM.. command 8192 individual \item{}s in itemized lists addressable. Each \LM.. command
8182 must occur on a separate line. \LMHash{} must occur immediately 8193 must occur on a separate line. \LMHash{} must occur immediately
8183 before the associated paragraph, and \LMLabel must occur immediately 8194 before the associated paragraph, and \LMLabel must occur immediately
8184 after the associated \section{}, \subsection{} etc. 8195 after the associated \section{}, \subsection{} etc.
8185 8196
8186 ---------------------------------------------------------------------- 8197 ----------------------------------------------------------------------
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