Index: docs/language/dartLangSpec.tex |
diff --git a/docs/language/dartLangSpec.tex b/docs/language/dartLangSpec.tex |
index f643ef1b4c525783671578723d7bb4eb0c3ac4ee..e616ecffbaf4c550d2d5fc1d9c4aeb662b467d1f 100644 |
--- a/docs/language/dartLangSpec.tex |
+++ b/docs/language/dartLangSpec.tex |
@@ -7159,36 +7159,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 can be called with zero, one or two positional arguments. |
eernst
2017/05/10 09:30:34
So the situation before: A library containing `mai
Lasse Reichstein Nielsen
2017/05/30 05:45:38
As discussed, I disagree that we should impose con
eernst
2017/05/30 09:14:42
Unsurprisingly, I would still prefer to go from "s
|
-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} |
eernst
2017/05/10 09:30:34
An exported namespace is a mapping that binds name
Lasse Reichstein Nielsen
2017/05/30 05:45:38
Going for "top level function \code{main}".
eernst
2017/05/30 09:14:42
Acknowledged.
|
+in the exported namespace of $S$ is invoked (\ref{functionInvocation}) |
+with up to two arguments, depending on how many it will accept. |
eernst
2017/05/10 09:30:34
The 'depending ..' is too imprecise. Just `up to t
Lasse Reichstein Nielsen
2017/05/30 05:45:38
Going for just "as follows:".
The "up to two argum
eernst
2017/05/30 09:14:42
Acknowledged.
|
+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} |
- |
-\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} |
+If \code{main} cannot be called with two positional arguments, |
+but it can be called with one positional argument, |
+it is invoked an object whose runtime type implements \code{List<String>} |
eernst
2017/05/10 09:30:34
`invoked [with] an object`
Lasse Reichstein Nielsen
2017/05/30 05:45:37
Done.
|
+as the only argument. |
+If \code{main} cannot be called with one or two positional arguments, |
+it is invoked with no arguments. |
\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. |
+Note that if \code{main} requires more than two positional arguments, |
+the library is not considered a script. |
eernst
2017/05/10 09:30:34
If we keep the approach where `main(a,b,c){}` is d
Lasse Reichstein Nielsen
2017/05/30 05:45:37
I don't plan to keep that approach, so retaining t
eernst
2017/05/30 09:14:42
Right, that's the consistent approach.
|
} |
\commentary { |
A Dart program will typically be executed by executing a script. |
} |
+\LMHASH{} |
eernst
2017/05/10 09:30:34
`\LMHash{}`.
Lasse Reichstein Nielsen
2017/05/30 05:45:38
Done.
|
+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. |
eernst
2017/05/10 09:30:34
If we keep the "`main(a,b,c){}` is detected at com
Lasse Reichstein Nielsen
2017/05/30 05:45:38
As discussed, I disagree on that.
It is not a run
eernst
2017/05/30 09:14:42
At this point I'm trying really hard to find a way
|
+ |
\subsection{URIs} |
\LMLabel{uris} |