Deconstruction-Functions.html 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <html lang="en">
  2. <head>
  3. <title>Deconstruction Functions - 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="Lists.html#Lists" title="Lists">
  9. <link rel="prev" href="Comparison.html#Comparison" title="Comparison">
  10. <link rel="next" href="Indirection.html#Indirection" title="Indirection">
  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="Deconstruction-Functions"></a>
  28. <p>
  29. Next:&nbsp;<a rel="next" accesskey="n" href="Indirection.html#Indirection">Indirection</a>,
  30. Previous:&nbsp;<a rel="previous" accesskey="p" href="Comparison.html#Comparison">Comparison</a>,
  31. Up:&nbsp;<a rel="up" accesskey="u" href="Lists.html#Lists">Lists</a>
  32. <hr>
  33. </div>
  34. <h4 class="subsection">3.1.6 Deconstruction Functions</h4>
  35. <p>A fast native implementation of the deconstruction operation is provided
  36. <a name="index-deconstruction-485"></a>by the functions declared in <samp><span class="file">decons.h</span></samp>.
  37. <div class="defun">
  38. &mdash; Function: void <b>avm_initialize_decons</b> ()<var><a name="index-avm_005finitialize_005fdecons-486"></a></var><br>
  39. <blockquote><p>This should be called prior to the first call to
  40. <code>avm_deconstruction</code>, so as to initialize some necessary internal
  41. data structures. Results will be undefined if it is not.
  42. </p></blockquote></div>
  43. <div class="defun">
  44. &mdash; Function: void <b>avm_count_decons</b> ()<var><a name="index-avm_005fcount_005fdecons-487"></a></var><br>
  45. <blockquote><p>For ecologically sound memory management, this function should be called
  46. at the end of a run to verify that there have been no leaks due to the
  47. deconstruction functions, which there won't be unless the code in
  48. <samp><span class="file">decons.c</span></samp> has been ineptly modified. An error message to the
  49. effect of unreclaimed &ldquo;points&rdquo; could be the result otherwise.
  50. </p></blockquote></div>
  51. <div class="defun">
  52. &mdash; Function: list <b>avm_deconstruction</b> (<var>list pointer, list operand, int *fault</var>)<var><a name="index-avm_005fdeconstruction-488"></a></var><br>
  53. <blockquote><p>Deconstructions are performed by this function, as described in
  54. <a href="Field.html#Field">Field</a>. In the <code>silly</code> program notation (<a href="A-Simple-Lisp-Like-Language.html#A-Simple-Lisp-Like-Language">A Simple Lisp Like Language</a>), this function computes the value
  55. of ([[<code>field</code>]] <var>pointer</var>) <var>operand</var>.
  56. <p>For example, using the fixed list <code>avm_join(NULL,NULL)</code> as the
  57. <var>pointer</var> parameter will cause a copy of the operand itself
  58. to be returned as the result. A <var>pointer</var> equal to
  59. <code>avm_join(NULL,avm_join(NULL,NULL))</code> will cause a copy of
  60. <code>operand-&gt;tail</code> to be returned, and so on. A <code>NULL</code>
  61. <var>pointer</var> causes an internal error.
  62. <p>If the deconstruction is invalid, as in the case of the tail of an empty
  63. list, the invalid deconstruction error message is returned as the
  64. result, and the <code>*</code><var>fault</var> parameter is set to a non-zero value.
  65. The <code>*</code><var>fault</var> parameter is also set to a non-zero value in the event
  66. of a memory overflow, and the memory overflow message is returned.
  67. </p></blockquote></div>
  68. </body></html>