@@ -8608,13 +8608,11 @@ \subsection{Constants}
8608
8608
respectively a constant type expression
8609
8609
if{}f $T$ is a potentially constant type expression
8610
8610
respectively a constant type expression.
8611
- \item
8612
- A type variable is a potentially constant type expression.
8613
8611
\item
8614
8612
%% TODO(eernst): This does not allow for type variables introduced by
8615
8613
%% the type itself. `Function<X>(X)` could be a constant type expression,
8616
8614
%% but that is not covered by the current rules: `X` is a type variable,
8617
- %% and they are never allowed .
8615
+ %% and they are never constant type expressions .
8618
8616
A function type
8619
8617
\code{$R$ Function<\metavar{typeParameters}>(\metavar{parameterTypes})}
8620
8618
(where $R$ and \code{<\metavar{typeParameters}>} may be omitted)
@@ -8624,9 +8622,11 @@ \subsection{Constants}
8624
8622
(if present) contain only potentially constant type expressions
8625
8623
respectively constant type expressions.
8626
8624
\item
8627
- The type \VOID is a potentially constant and a constant type expression.
8625
+ The type \VOID{} is a potentially constant and a constant type expression.
8626
+ \item
8627
+ The type \DYNAMIC{} is a potentially constant and a constant type expression.
8628
8628
\item
8629
- The type \DYNAMIC is a potentially constant and a constant type expression.
8629
+ A type variable is a potentially constant type expression.
8630
8630
\end{itemize}
8631
8631
8632
8632
% Being potentially constant is entirely structural, not type based,
@@ -20440,6 +20440,76 @@ \subsection{Parts}
20440
20440
\subsection{Scripts}
20441
20441
\LMLabel{scripts}
20442
20442
20443
+ \LMHash{}%
20444
+ Let $L$ be a library that exports a declaration $D$ named \code{main}.
20445
+ It is a \Error{compile-time error} unless $D$ is
20446
+ a non-getter function declaration.
20447
+ It is a \Error{compile-time error} if $D$ declares
20448
+ more than two required positional parameters,
20449
+ or if there are any required named parameters.
20450
+ It is a \Error{compile-time error} if $D$ declares
20451
+ at least one positional parameter,
20452
+ and the first positional parameter has a type which is
20453
+ not a supertype of \code{List<String>}.
20454
+
20455
+ \LMHash{}%
20456
+ Implementations are free to impose any additional restrictions on
20457
+ the signature of \code{main}.
20458
+
20459
+ \LMHash{}%
20460
+ A \Index{script} is a library that exports a declaration named \code{main}.
20461
+ A script $L$ is executed as follows:
20462
+
20463
+ \LMHash{}%
20464
+ First, $L$ is compiled as a library as specified above.
20465
+ Then, the top-level function defined by \code{main}
20466
+ in the exported namespace of $L$ is invoked as follows:
20467
+
20468
+ \LMHash{}%
20469
+ If \code{main} can be called with two positional arguments,
20470
+ it is invoked with the following two actual arguments:
20471
+
20472
+ \begin{itemize}
20473
+ \item
20474
+ An object whose run-time type implements \code{List<String>}.
20475
+ \item
20476
+ An object specified when the current isolate $i$ was created,
20477
+ (\commentary{%
20478
+ for example through the invocation of \code{Isolate.spawnUri}
20479
+ that spawned $i$%
20480
+ }),
20481
+ or the null object if no such object was supplied.
20482
+ A dynamic error occurs if
20483
+ the run-time type of this object is not a subtype of
20484
+ the declared type of the corresponding parameter of \code{main}.
20485
+ \end{itemize}
20486
+
20487
+ \LMHash{}%
20488
+ If \code{main} cannot be called with two positional arguments,
20489
+ but it can be called with one positional argument,
20490
+ it is invoked with an object whose run-time type implements \code{List<String>}
20491
+ as the only argument.
20492
+
20493
+ \LMHash{}%
20494
+ If \code{main} cannot be called with one or two positional arguments,
20495
+ it is invoked with no arguments.
20496
+
20497
+ \LMHash{}%
20498
+ In each of the above three cases,
20499
+ an implementation is free to provide additional arguments
20500
+ allowed by the signature of \code{main}
20501
+ (\commentary{%
20502
+ the above rules ensure that the corresponding parameters are optional%
20503
+ }).
20504
+ But the implementation must ensure that a dynamic error occurs
20505
+ if an actual argument does not have a run-time type which is
20506
+ a subtype of the declared type of the parameter.
20507
+
20508
+ \LMHash{}%
20509
+ A Dart program will typically be executed by executing a script.
20510
+ The procedure whereby this script is chosen is implementation specific.
20511
+
20512
+ ----------------------------------------------------------------------
20443
20513
\LMHash{}%
20444
20514
A \Index{script} is a library whose exported namespace (\ref{exports}) includes
20445
20515
a top-level function declaration named \code{main}
@@ -24035,72 +24105,20 @@ \subsubsection{Null promotion}
24035
24105
These are extended as per
24036
24106
[separate proposal](https://github.com/dart-lang/language/blob/master/resources/type-system/flow-analysis.md).
24037
24107
24038
- \subsubsection{The main function }
24108
+ \subsubsection{Runtime type equality operator }
24039
24109
24040
24110
!!!TODO!!!
24041
24111
24042
- The section 'Scripts' in the language specification is replaced by the
24043
- following:
24044
-
24045
- Let $L$ be a library that exports a declaration $D$ named \code{main}.
24046
- It is a \Error{compile-time error} unless $D$ is a non-getter function
24047
- declaration. It is a \Error{compile-time error} if $D$ declares more
24048
- than two required positional parameters, or if there are any required
24049
- named parameters. It is a \Error{compile-time error} if $D$ declares
24050
- at least one positional parameter, and the first positional parameter
24051
- has a type which is not a supertype of \code{List<String>}.
24052
-
24053
- Implementations are free to impose any additional restrictions on the
24054
- signature of \code{main}.
24055
-
24056
- A _script_ is a library that exports a declaration named \code{main}.
24057
- A script $L$ is executed as follows:
24058
-
24059
- First, $L$ is compiled as a library as specified above.
24060
- Then, the top-level function defined by \code{main}
24061
- in the exported namespace of $L$ is invoked as follows:
24062
-
24063
- If \code{main} can be called with two positional arguments,
24064
- it is invoked with the following two actual arguments:
24065
-
24066
- \begin{itemize}
24067
- \item An object whose run-time type implements \code{List<String>}.
24068
- \item An object specified when the current isolate $i$ was created,
24069
- for example through the invocation of \code{Isolate.spawnUri} that spawned $i$,
24070
- or the null object if no such object was supplied.
24071
- A dynamic error occurs if the run-time type of this object is not a
24072
- subtype of the declared type of the corresponding parameter of \code{main}.
24073
- \end{itemize}
24074
-
24075
- If \code{main} cannot be called with two positional arguments, but it can be
24076
- called with one positional argument, it is invoked with an object whose
24077
- run-time type implements \code{List<String>} as the only argument.
24078
-
24079
- If \code{main} cannot be called with one or two positional arguments, it is
24080
- invoked with no arguments.
24081
-
24082
- In each of the above three cases, an implementation is free to provide
24083
- additional arguments allowed by the signature of \code{main}
24084
- (\commentary{the above rules ensure that the corresponding parameters are optional}).
24085
- But the implementation must ensure that a dynamic error occurs if an
24086
- actual argument does not have a run-time type which is a subtype of
24087
- the declared type of the parameter.
24088
-
24089
- A Dart program will typically be executed by executing a script. The
24090
- procedure whereby this script is chosen is implementation specific.
24091
-
24092
- \subsection{Runtime semantics}
24093
-
24094
- \subsubsection{Runtime type equality operator}
24095
-
24096
- Two objects $T_1$ and $T_2$ which are instances of \code{Type} (that is, runtime type
24097
- objects) are considered equal if and only if the runtime type objects $T_1$ and
24098
- $T_2$ corresponds to the types $S_1$ and $S_2$ respectively, and the normal forms
24099
- \NormalizedTypeOf{$S_1$} and \NormalizedTypeOf{$S_2$} are syntactically equal up to equivalence of
24100
- bound variables. Note that we do not equate primitive top types. \code{List<\VOID>}
24101
- and \code{List<\DYNAMIC>} are still considered distinct runtime type objects. Note
24102
- that we also do not equate function
24103
- types which differ in the placement of \REQUIRED{} on parameter types.
24112
+ Two objects $T_1$ and $T_2$ which are instances of \code{Type} (that
24113
+ is, runtime type objects) are considered equal if and only if the
24114
+ runtime type objects $T_1$ and $T_2$ corresponds to the types $S_1$
24115
+ and $S_2$ respectively, and the normal forms \NormalizedTypeOf{$S_1$}
24116
+ and \NormalizedTypeOf{$S_2$} are syntactically equal up to equivalence
24117
+ of bound variables. Note that we do not equate primitive top types.
24118
+ \code{List<\VOID>} and \code{List<\DYNAMIC>} are still considered
24119
+ distinct runtime type objects. Note that we also do not equate
24120
+ function types which differ in the placement of \REQUIRED{} on
24121
+ parameter types.
24104
24122
24105
24123
\subsubsection{Constant evaluation and canonicalization}
24106
24124
0 commit comments