Jeremy Siek 3 anni fa
parent
commit
f032e2eabf
2 ha cambiato i file con 20 aggiunte e 9 eliminazioni
  1. 18 8
      book.tex
  2. 2 1
      defs.tex

+ 18 - 8
book.tex

@@ -12641,11 +12641,21 @@ application is shown in Figures~\ref{fig:Rfun-concrete-syntax} and
 \LangFun{} begin with zero or more function definitions.  The function
 names from these definitions are in-scope for the entire program,
 including all other function definitions (so the ordering of function
-definitions does not matter). The concrete syntax for function
-application\index{subject}{function application} is $(\Exp \; \Exp \ldots)$
-where the first expression must
-evaluate to a function and the rest are the arguments.
-The abstract syntax for function application is
+definitions does not matter).
+%
+\python{The abstract syntax for function parameters in
+  Figure~\ref{fig:Rfun-syntax} is a list of pairs, where each pair
+  consists of a parameter name and its type.  This differs from
+  Python's \code{ast} module, which has a more complex syntax for
+  function parameters, for example, to handle keyword parameters and
+  defaults. The type checker in \code{type\_check\_Lfun} converts the
+  more commplex syntax into the simpler syntax of
+  Figure~\ref{fig:Rfun-syntax}.}
+%
+The concrete syntax for function application\index{subject}{function
+  application} is $(\Exp \; \Exp \ldots)$ where the first expression
+must evaluate to a function and the rest are the arguments.  The
+abstract syntax for function application is
 $\APPLY{\Exp}{\Exp\ldots}$.
 
 %% The syntax for function application does not include an explicit
@@ -12693,8 +12703,8 @@ inside each other.
 \newcommand{\LfunASTPython}{
   \begin{array}{lcl}
     \Type &::=& \key{FunctionType}\LP \Type^{*} \key{, } \Type \RP \\
-    \itm{arguments}&::=& 
-   \Def &::=& \FUNDEF{\Var}{\itm{arguments}}{\Type}{}{\Stmt^{+}} 
+   \Exp &::& \CALL{\Exp}{\Exp^{*}}\\
+   \Def &::=& \FUNDEF{\Var}{\LS \LP \Var \key{, } \Type \RP \key{, } \ldots \RS}{\Type}{}{\Stmt^{+}} 
   \end{array}
 }
 
@@ -12769,7 +12779,7 @@ inside each other.
   \gray{\LtupASTPython} \\  \hline
   \LfunASTPython \\
 \begin{array}{rcl}
-  \LangFunM{} &::=& ??
+  \LangFunM{} &::=& \PROGRAM{}{\LS \Def \ldots \Stmt \ldots \RS}
 \end{array}
 \end{array}
 \]

+ 2 - 1
defs.tex

@@ -207,12 +207,14 @@
 \newcommand{\GLOBAL}[1]{\key{Global}\LP#1\RP}
 \newcommand{\CGLOBAL}[1]{#1\LP\key{\%rip}\RP}
 \newcommand{\CNEG}[1]{\key{-}~#1}
+\newcommand{\CALL}[2]{\key{(Call}~#1~#2\code{)}}
 \fi % pythonEd
 
 \if\edition\racketEd
 \newcommand{\BEGIN}[2]{\LP\key{Begin}~#1~#2\RP}
 \newcommand{\CBEGIN}[2]{\LP\key{begin}~#1~#2\RP}
 \newcommand{\CNEG}[1]{\LP\key{-}~#1\RP}
+\newcommand{\CALL}[2]{\key{Call}\LP #1\code{, } #2 \RP}
 \fi
 \newcommand{\PRIM}[2]{\LP\key{Prim}~#1~\LP #2\RP\RP}
 \newcommand{\PROGRAMDEFSEXP}[3]{\code{(ProgramDefsExp}~#1~#2~#3\code{)}}
@@ -241,7 +243,6 @@
 
 \newcommand{\VOID}[1]{\key{(Void)}}
 \newcommand{\APPLY}[2]{\key{(Apply}~#1~#2\code{)}}
-\newcommand{\CALL}[2]{\key{(Call}~#1~#2\code{)}}
 \newcommand{\TAILCALL}[2]{\key{(TailCall}~#1~#2\code{)}}
 \newcommand{\FUNREF}[1]{\key{(FunRef}~#1\code{)}}
 \newcommand{\CFUNREF}[1]{\key{(fun-ref}~#1\code{)}}