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

Unified Diff: docs/language/dartLangSpec.tex

Issue 2852533003: Change specification of main. (Closed)
Patch Set: Address comments. Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: docs/language/dartLangSpec.tex
diff --git a/docs/language/dartLangSpec.tex b/docs/language/dartLangSpec.tex
index 50683dbe0475f0e394787c26f66aef951846e71d..52430cf936d07a5a6540c5a32c32ad3c6fa8874b 100644
--- a/docs/language/dartLangSpec.tex
+++ b/docs/language/dartLangSpec.tex
@@ -7187,36 +7187,47 @@ It's a compile-time error if the same library contains two part directives with
\LMLabel{scripts}
\LMHash{}
-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 more than two required parameters.
+A {\em script} is a library whose exported namespace (\ref{exports}) includes
+a top-level function declaration named \code{main}
+that has either zero, one or two required arguments.
-A script $S$ may be executed as follows:
+A script $S$ is executed as follows:
\LMHash{}
-First, $S$ is compiled as a library as specified above. Then, the top-level function \code{main} that is in the exported namespace of $S$ is invoked. If \code{main} 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 actual argument whose runtime type implements \code{List<String>}. Otherwise \code{main} is invoked with the following two actual arguments:
+First, $S$ is compiled as a library as specified above.
+Then, the top-level function defined by \code{main}
+in the exported namespace of $S$ is invoked (\ref{functionInvocation})
+as follows:
+If \code{main} can be be called with with two positional arguments,
+it is invoked with the following two actual arguments:
\begin{enumerate}
\item An object whose runtime type implements \code{List<String>}.
-\item The initial message of the current isolate $i$ as determined by the invocation of \code{Isolate.spawnUri} that spawned $i$.
+\item An object specified when the current isolate $i$ was created,
+for example through the invocation of \code{Isolate.spawnUri} that spawned $i$,
+or \NULL{} if no such object was supplied.
\end{enumerate}
+If \code{main} cannot be called with two positional arguments,
+but it can be called with one positional argument,
+it is invoked with an object whose runtime type implements \code{List<String>}
+as the only argument.
+If \code{main} cannot be called with one or two positional arguments,
+it is invoked with no arguments.
-\LMHash{}
-It is a run time error if $S$ does not declare or export either:
-\begin{itemize}
-\item A top-level function named \code{main}, or
-\item A top-level getter named \code{main} that returns a function.
-\end{itemize}
-
-\commentary {
-Note that if \code{main} requires more than two arguments, a run time error will occur.
-}
-
-\rationale{
-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 good practice.
+\commentary{
+Note that if \code{main} requires more than two positional arguments,
+the library is not considered a script.
}
-\commentary {
+\commentary{
A Dart program will typically be executed by executing a script.
}
+\LMHASH{}
+If a non-script library is provided where a script is expected,
+it precludes execution.
+As such, it should be reported as a compile-time error,
+even if that library compiles successfully as a non-script library.
+
\subsection{URIs}
\LMLabel{uris}
« 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