Commit 02b2ccc3 authored by Björn Peemöller 's avatar Björn Peemöller
Browse files

Finer structure for lifting of local declarations

parent fa792137
......@@ -863,8 +863,8 @@ For the following, we assume that all name conflicts have been resolved,
i.e., the names of functions and argument variables defined
in the different declarations are pairwise different.
\item[Eliminate sections and lambda abstractions:]~\\
\subsubsection{Eliminate Sections and Lambda Abstractions}
Left and right sections\index{section}\index{section!left}\index{left section}%
\index{section!right}\index{right section}
are transformed into partial applications, i.e.,
......@@ -894,7 +894,8 @@ where $f$ is a new function name.
This transformation must be recursively applied to all
$\lambda$-abstractions occurring in $e$.
\item[Eliminate Boolean guards:]~\\
\subsubsection{Eliminate Boolean Guards}
This is done according the meaning described in
A rule of the form
......@@ -915,7 +916,8 @@ $f~t_1\ldots{}t_n$ = if $b_1$ then $e_1$ else
\item[Transform \code{where} into \code{let}:]~\\
\subsubsection{Transform \code{where} into \code{let}}
Each unconditional rule of the form
$l$ = $r$ where $decls$
......@@ -942,7 +944,8 @@ Note that this transformation is not really necessary
but provides for a unified treatment of the elimination
of local pattern and function declarations in \code{let} and \code{where}.
\item[Eliminate \code{fcase}:]~\\
\subsubsection{Eliminate \code{fcase}}
As discussed in Section~\ref{sec-fcase-expressions},
\code{fcase} expressions are a short notation
for flexible pattern matching as used in defined functions.
......@@ -967,7 +970,8 @@ let $f$ $p_1$ | $g_1$ = $e1$
where $f$ is a fresh function symbol not occurring in the
initial \code{fcase} expression.
\item[Eliminate local patterns and functions:]~\\
\subsubsection{Eliminate Local Patterns and Functions}
All local pattern\index{local pattern}\index{pattern!local}
and function declarations\index{local declaration}\index{declaration!local}
in a rule ``\code{$l$\,\,=\,$r$}'' are eliminated by iterating
......@@ -980,8 +984,8 @@ We apply the following transformations as long as possible
to eliminate all local pattern and function declarations
in a rule of the form
\item[Eliminate patterns:]~\\
\paragraph{Eliminate Patterns}
Select a local pattern declaration which contains only
argument variables from the main function's left-hand side
in the expression, i.e., the rule has the form
......@@ -1025,7 +1029,7 @@ and the definition of $l$ can be replaced by
$l$ = $C[f''~x_1\ldots{}x_k~(f_1 e')\ldots{}(f_m e')]_p$
\item[Complete local function definitions:]~\\
\paragraph{Complete Local Function Definitions}
If a locally declared function $f$ refers in its definition
to a variable $v$ not contained in its argument patterns,
then add $v$ as an additional first\footnote{The new arguments must come
......@@ -1047,7 +1051,7 @@ f x = let y free
in g y 0
\item[Globalize local function definitions:]~\\
\paragraph{Globalize Local Function Definitions}
If the definitions of all locally declared functions are completed,
i.e., the definitions only refer to variables in the argument
patterns, delete the locally declared functions and
......@@ -1061,8 +1065,9 @@ f x = let y free in g y 0
Note that the entire transformation process must be applied again
to the new top-level declarations since they may also contain
local declarations.
\subsubsection{Resulting Program}
After applying these transformation steps to all rules in the program,
we obtain a program without sections and $\lambda$-abstractions
where all local declarations contain only free variables.
......@@ -1077,4 +1082,4 @@ following final transformation:
Transform & \code{$l$ = let $decls$ in ($c$|$r$)} & into & \code{$l$ | $c$ = $r$ where $decls$} \\
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment