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

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

Issue 2060163002: Add trailing commas to argument and parameter lists. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 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 \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 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 648
649 %The formal parameter scope of a function maps the name of each formal parameter $p$ to the value $p$ is bound to. 649 %The formal parameter scope of a function maps the name of each formal parameter $p$ to the value $p$ is bound to.
650 650
651 % The formal parameters of a function are processed in the enclosing scope of th e function. 651 % The formal parameters of a function are processed in the enclosing scope of th e function.
652 % \commentary{this means that the parameters themselves may not be referenced wi thin the formal parameter list.} 652 % \commentary{this means that the parameters themselves may not be referenced wi thin the formal parameter list.}
653 653
654 \LMHash{} 654 \LMHash{}
655 It is a compile-time error if a formal parameter is declared as a constant varia ble (\ref{variables}). 655 It is a compile-time error if a formal parameter is declared as a constant varia ble (\ref{variables}).
656 656
657 \begin{grammar} 657 \begin{grammar}
658 {\bf formalParameterList:}`(' `)'; 658 {\bf formalParameterList:}
659 `(' normalFormalParameters ( `,' optionalFormalParameters)? `)'; 659 `(' `)';
660 `(' optionalFormalParameters `)' 660 `(' normalFormalParameters `,'? `)';
661 `(' normalFormalParameters `,' optionalFormalParameters `)';
662 `(' optionalFormalParameters `)'
661 . 663 .
662 %\end{grammar} 664 %\end{grammar}
663 %} 665 %}
664 666
665 %\begin{grammar} 667 %\begin{grammar}
666 %formalParameterList: 668 %formalParameterList:
667 % '(' restFormalParameter? ')'; 669 % '(' restFormalParameter? ')';
668 % '(' namedFormalParameters ')'; 670 % '(' namedFormalParameters ')';
669 % '(' normalFormalParameters normalFormalParameterTail? ')' 671 % '(' normalFormalParameters normalFormalParameterTail? ')'
670 % . 672 % .
671 673
672 {\bf normalFormalParameters:} 674 {\bf normalFormalParameters:}
673 normalFormalParameter (`,' normalFormalParameter)* 675 normalFormalParameter (`,' normalFormalParameter)*
674 . 676 .
675 677
676 {\bf optionalFormalParameters:}optionalPositionalFormalParameters; 678 {\bf optionalFormalParameters:}
679 optionalPositionalFormalParameters;
677 namedFormalParameters 680 namedFormalParameters
678 . 681 .
679 682
680 {\bf optionalPositionalFormalParameters:} 683 {\bf optionalPositionalFormalParameters:}
681 `[' defaultFormalParameter (`,' defaultFormalParameter)* `]' 684 `[' defaultFormalParameter (`,' defaultFormalParameter)* `,'? `]'
682 . 685 .
683 {\bf namedFormalParameters:} 686 {\bf namedFormalParameters:}
684 `\{' defaultNamedParameter (`,' defaultNamedParameter)* `\}' 687 `\{' defaultNamedParameter (`,' defaultNamedParameter)* `,'? `\}'
685 . 688 .
686 \end{grammar} 689 \end{grammar}
687 690
688 %Formal parameters are always \FINAL{}. 691 %Formal parameters are always \FINAL{}.
689 %\Q{We're awaiting some data on whether enforcing this would cause widespread pa in.} 692 %\Q{We're awaiting some data on whether enforcing this would cause widespread pa in.}
690 %A formal parameter is always considered to be initialized. \rationale{This is because it will always be initialized by the call - even if it is optional.} 693 %A formal parameter is always considered to be initialized. \rationale{This is because it will always be initialized by the call - even if it is optional.}
691 694
692 695
693 \subsubsection{Required Formals} 696 \subsubsection{Required Formals}
694 \LMLabel{requiredFormals} 697 \LMLabel{requiredFormals}
(...skipping 2906 matching lines...) Expand 10 before | Expand all | Expand 10 after
3601 3604
3602 3605
3603 \subsubsection{ Actual Argument List Evaluation} 3606 \subsubsection{ Actual Argument List Evaluation}
3604 \LMLabel{actualArguments} 3607 \LMLabel{actualArguments}
3605 3608
3606 \LMHash{} 3609 \LMHash{}
3607 Function invocation involves evaluation of the list of actual arguments to the f unction and binding of the results to the function's formal parameters. 3610 Function invocation involves evaluation of the list of actual arguments to the f unction and binding of the results to the function's formal parameters.
3608 3611
3609 \begin{grammar} 3612 \begin{grammar}
3610 {\bf arguments:} 3613 {\bf arguments:}
3611 `(' argumentList? `)' 3614 `(' (argumentList `,'?)? `)'
3612 . 3615 .
3613 3616
3614 {\bf argumentList:}namedArgument (`,' namedArgument)*; 3617 {\bf argumentList:}
3615 % expressionList ',' spreadArgument; 3618 namedArgument (`,' namedArgument)*;
3616 expressionList (`,' namedArgument)* 3619 expressionList (`,' namedArgument)*
eernst 2016/06/14 09:08:32 I think we should gather all the changes motivated
Lasse Reichstein Nielsen 2016/06/27 17:27:53 Let's do that. Reinserted for now.
3617 % spreadArgument
3618 . 3620 .
3619 3621
3620 {\bf namedArgument:} 3622 {\bf namedArgument:}
3621 label expression % could be top level expression? 3623 label expression % could be top level expression?
3622 . 3624 .
3623 \end{grammar} 3625 \end{grammar}
3624 3626
3625 \LMHash{} 3627 \LMHash{}
3626 Evaluation of an actual argument list of the form 3628 Evaluation of an actual argument list of the form
3627 3629
3628 $(a_1, \ldots, a_m, q_1: a_{m+1}, \ldots, q_l: a_{m+l})$ 3630 $(a_1, \ldots, a_m, q_1: a_{m+1}, \ldots, q_l: a_{m+l})$
3629 3631
3630 proceeds as follows: 3632 (ignoring any trailing comma) proceeds as follows:
eernst 2016/06/14 09:08:33 The given argument list serves as the basis for sp
3631 3633
3632 \LMHash{} 3634 \LMHash{}
3633 The arguments $a_1, \ldots, a_{m+l}$ are evaluated in the order they appear in t he program, yielding objects $o_1, \ldots, o_{m+l}$. 3635 The arguments $a_1, \ldots, a_{m+l}$ are evaluated in the order they appear in t he program, yielding objects $o_1, \ldots, o_{m+l}$.
3634 3636
3635 \commentary{Simply stated, an argument list consisting of $m$ positional argumen ts and $l$ named arguments is evaluated from left to right. 3637 \commentary{Simply stated, an argument list consisting of $m$ positional argumen ts and $l$ named arguments is evaluated from left to right.
3636 } 3638 }
3637 3639
3638 3640
3639 \subsubsection{ Binding Actuals to Formals} 3641 \subsubsection{ Binding Actuals to Formals}
3640 \LMLabel{bindingActualsToFormals} 3642 \LMLabel{bindingActualsToFormals}
3641 3643
3642 \LMHash{} 3644 \LMHash{}
3643 Let $f$ be a function with $h$ required parameters, let $p_1 \ldots p_n$ be the positional parameters of $f$ and let $p_{h+1}, \ldots, p_{h+k}$ be the optional parameters declared by $f$. 3645 Let $f$ be a function with $h$ required parameters, let $p_1 \ldots p_n$ be the positional parameters of $f$ and let $p_{h+1}, \ldots, p_{h+k}$ be the optional parameters declared by $f$.
3644 3646
3645 \LMHash{} 3647 \LMHash{}
3646 An evaluated actual argument list $o_1 \ldots o_{m+l}$ derived from an actual ar gument list of the form $(a_1, \ldots, a_m, q_1: a_{m+1}, \ldots, q_l: a_{m+l})$ is bound to the formal parameters of $f$ as follows: 3648 An evaluated actual argument list $o_1 \ldots o_{m+l}$ derived from an actual ar gument list of the form $(a_1, \ldots, a_m, q_1: a_{m+1}, \ldots, q_l: a_{m+l})$ (ignoring any trailing comma) is bound to the formal parameters of $f$ as follo ws:
eernst 2016/06/14 09:08:33 Same issue as line 3632.
3647 3649
3648 \commentary{ 3650 \commentary{
3649 We have an argument list consisting of $m$ positional arguments and $l$ named ar guments. We have a function with $h$ required parameters and $k$ optional parame ters. The number of positional arguments must be at least as large as the number of required parameters, and no larger than the number of positional parameters. All named arguments must have a corresponding named parameter. You may not prov ide a given named argument more than once. If an optional parameter has no corr esponding argument, it gets its default value. In checked mode, all arguments mu st belong to subtypes of the type of their corresponding formal. 3651 We have an argument list consisting of $m$ positional arguments and $l$ named ar guments. We have a function with $h$ required parameters and $k$ optional parame ters. The number of positional arguments must be at least as large as the number of required parameters, and no larger than the number of positional parameters. All named arguments must have a corresponding named parameter. You may not prov ide a given named argument more than once. If an optional parameter has no corr esponding argument, it gets its default value. In checked mode, all arguments mu st belong to subtypes of the type of their corresponding formal.
3650 } 3652 }
3651 3653
3652 \commentary{ 3654 \commentary{
3653 If $l > 0$, then it is necessarily the case that $n = h$, because a method canno t have both optional positional parameters and named parameters. 3655 If $l > 0$, then it is necessarily the case that $n = h$, because a method canno t have both optional positional parameters and named parameters.
3654 } 3656 }
3655 3657
3656 3658
(...skipping 4224 matching lines...) Expand 10 before | Expand all | Expand 10 after
7881 7883
7882 The invariant that each normative paragraph is associated with a line 7884 The invariant that each normative paragraph is associated with a line
7883 containing the text \LMHash{} should be maintained. Extra occurrences 7885 containing the text \LMHash{} should be maintained. Extra occurrences
7884 of \LMHash{} can be added if needed, e.g., in order to make 7886 of \LMHash{} can be added if needed, e.g., in order to make
7885 individual \item{}s in itemized lists addressable. Each \LM.. command 7887 individual \item{}s in itemized lists addressable. Each \LM.. command
7886 must occur on a separate line. \LMHash{} must occur immediately 7888 must occur on a separate line. \LMHash{} must occur immediately
7887 before the associated paragraph, and \LMLabel must occur immediately 7889 before the associated paragraph, and \LMLabel must occur immediately
7888 after the associated \section{}, \subsection{} etc. 7890 after the associated \section{}, \subsection{} etc.
7889 7891
7890 ---------------------------------------------------------------------- 7892 ----------------------------------------------------------------------
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