1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="AsciiDoc 8.6.8">
<title>LambdaFree</title>
<link rel="stylesheet" href="./asciidoc.css" type="text/css">
<link rel="stylesheet" href="./pygments.css" type="text/css">
<script type="text/javascript" src="./asciidoc.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
asciidoc.install();
/*]]>*/
</script>
<link rel="stylesheet" href="./mlton.css" type="text/css"/>
</head>
<body class="article">
<div id="banner">
<div id="banner-home">
<a href="./Home">MLton 20130715</a>
</div>
</div>
<div id="header">
<h1>LambdaFree</h1>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="paragraph"><p><a href="LambdaFree">LambdaFree</a> is an analysis pass for the <a href="SXML">SXML</a>
<a href="IntermediateLanguage">IntermediateLanguage</a>, invoked from <a href="ClosureConvert">ClosureConvert</a>.</p></div>
</div>
</div>
<div class="sect1">
<h2 id="_description">Description</h2>
<div class="sectionbody">
<div class="paragraph"><p>This pass descends the entire <a href="SXML">SXML</a> program and attaches a property
to each <span class="monospaced">Lambda</span> <span class="monospaced">PrimExp.t</span> in the program. Then, you can use
<span class="monospaced">lambdaFree</span> and <span class="monospaced">lambdaRec</span> to get free variables of that <span class="monospaced">Lambda</span>.</p></div>
</div>
</div>
<div class="sect1">
<h2 id="_implementation">Implementation</h2>
<div class="sectionbody">
<div class="ulist"><ul>
<li>
<p>
<a href="https://github.com/MLton/mlton/blob/master/mlton/closure-convert/lambda-free.sig"><span class="monospaced">lambda-free.sig</span></a>
</p>
</li>
<li>
<p>
<a href="https://github.com/MLton/mlton/blob/master/mlton/closure-convert/lambda-free.fun"><span class="monospaced">lambda-free.fun</span></a>
</p>
</li>
</ul></div>
</div>
</div>
<div class="sect1">
<h2 id="_details_and_notes">Details and Notes</h2>
<div class="sectionbody">
<div class="paragraph"><p>For <span class="monospaced">Lambda</span>-s bound in a <span class="monospaced">Fun</span> dec, <span class="monospaced">lambdaFree</span> gives the union of
the frees of the entire group of mutually recursive functions. Hence,
<span class="monospaced">lambdaFree</span> for every <span class="monospaced">Lambda</span> in a single <span class="monospaced">Fun</span> dec is the same.
Furthermore, for a <span class="monospaced">Lambda</span> bound in a <span class="monospaced">Fun</span> dec, <span class="monospaced">lambdaRec</span> gives
the list of other functions bound in the same dec defining that
<span class="monospaced">Lambda</span>.</p></div>
<div class="paragraph"><p>For example:</p></div>
<div class="listingblock">
<div class="content monospaced">
<pre>val rec f = fn x => ... y ... g ... f ...
and g = fn z => ... f ... w ...</pre>
</div></div>
<div class="listingblock">
<div class="content monospaced">
<pre>lambdaFree(fn x =>) = [y, w]
lambdaFree(fn z =>) = [y, w]
lambdaRec(fn x =>) = [g, f]
lambdaRec(fn z =>) = [f]</pre>
</div></div>
</div>
</div>
</div>
<div id="footnotes"><hr></div>
<div id="footer">
<div id="footer-text">
</div>
<div id="footer-badges">
</div>
</div>
</body>
</html>
|