Field.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <html lang="en">
  2. <head>
  3. <title>Field - avram - a virtual machine code interpreter</title>
  4. <meta http-equiv="Content-Type" content="text/html">
  5. <meta name="description" content="avram - a virtual machine code interpreter">
  6. <meta name="generator" content="makeinfo 4.13">
  7. <link title="Top" rel="start" href="index.html#Top">
  8. <link rel="up" href="Deconstruction.html#Deconstruction" title="Deconstruction">
  9. <link rel="prev" href="Deconstruction.html#Deconstruction" title="Deconstruction">
  10. <link rel="next" href="Fan.html#Fan" title="Fan">
  11. <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
  12. <meta http-equiv="Content-Style-Type" content="text/css">
  13. <style type="text/css"><!--
  14. pre.display { font-family:inherit }
  15. pre.format { font-family:inherit }
  16. pre.smalldisplay { font-family:inherit; font-size:smaller }
  17. pre.smallformat { font-family:inherit; font-size:smaller }
  18. pre.smallexample { font-size:smaller }
  19. pre.smalllisp { font-size:smaller }
  20. span.sc { font-variant:small-caps }
  21. span.roman { font-family:serif; font-weight:normal; }
  22. span.sansserif { font-family:sans-serif; font-weight:normal; }
  23. --></style>
  24. </head>
  25. <body>
  26. <div class="node">
  27. <a name="Field"></a>
  28. <p>
  29. Next:&nbsp;<a rel="next" accesskey="n" href="Fan.html#Fan">Fan</a>,
  30. Previous:&nbsp;<a rel="previous" accesskey="p" href="Deconstruction.html#Deconstruction">Deconstruction</a>,
  31. Up:&nbsp;<a rel="up" accesskey="u" href="Deconstruction.html#Deconstruction">Deconstruction</a>
  32. <hr>
  33. </div>
  34. <h5 class="subsubsection">2.7.8.1 Field</h5>
  35. <p>The virtual machine supports a generalization of the <code>left</code> and
  36. <a name="index-g_t_0040code_007bleft_007d-291"></a><a name="index-g_t_0040code_007bright_007d-292"></a><code>right</code> deconstruction operations that is applicable to deeply nested
  37. structures. Use of this feature is conducive to code that is faster and
  38. more compact than is possible by relying on the primitive deconstructors
  39. alone. It may also be easier for a code optimizer to recognize and
  40. transform.
  41. <p>The general form of a virtual code application to perform deconstruction
  42. is that it is a pair with a <code>nil</code> left side, and a non-<code>nil</code>
  43. right side. The right side indicates the nature of the deconstruction to
  44. be performed when the function is evaluated on an argument.
  45. <p>To make the expression of deconstruction functions more readable in
  46. <code>silly</code>, the standard library contains the declaration
  47. <pre class="example"> field = couple(constant nil,identity)
  48. </pre>
  49. <p class="noindent">which implies the following theorem.
  50. <dl>
  51. <dt><em>T13</em><dd>[[<code>field</code>]] <var>w</var> = <code>(nil,</code><var>w</var><code>)</code>
  52. </dl>
  53. <p><a name="index-g_t_0040code_007bfield_007d-293"></a>The virtual machine recognizes an application in this form and evaluates
  54. it according to the following properties, where <var>u</var> and
  55. <var>v</var> are other than <code>nil</code>, but <var>x</var>,
  56. <var>y</var>, and <var>z</var> are unrestricted.
  57. <dl>
  58. <dt><em>P10</em><dd>([[<code>field</code>]] <code>(</code><var>u</var><code>,nil)</code>) <code>(</code><var>x</var><code>,</code><var>y</var><code>)</code> = ([[<code>field</code>]] <var>u</var>) <var>x</var>
  59. <br><dt><em>P11</em><dd>([[<code>field</code>]] <code>(nil,</code><var>v</var><code>)</code>) <code>(</code><var>x</var><code>,</code><var>y</var><code>)</code> = ([[<code>field</code>]] <var>v</var>) <var>y</var>
  60. <br><dt><em>P12</em><dd>([[<code>field</code>]] <code>(</code><var>u</var><code>,v)</code>) <var>z</var> = <code>((</code>[[<code>field</code>]] <var>u</var><code>) </code><var>z</var><code>,(</code>[[<code>field</code>]] <var>v</var><code>) </code><var>z</var><code>)</code>
  61. </dl>
  62. <p class="noindent">One might also add that ([[<code>field</code>]] <code>(nil,nil)</code>)
  63. <var>z</var> = <var>z</var>, but this statement would be equivalent to
  64. <em>P0</em>.
  65. <p>A suitable choice of the <code>field</code> operand permits the implementation
  66. of any deconstruction function expressible in terms of <code>compose</code>,
  67. <code>couple</code>, <code>identity</code>, <code>left</code> and <code>right</code>. For
  68. example, the application <code>couple(compose(right,right),left)</code> has an
  69. equivalent representation in
  70. <code>field((nil,(nil,(nil,nil))),((nil,nil),nil))</code>. The latter looks
  71. longer in <code>silly</code> but is smaller and faster in virtual code.
  72. </body></html>