The-Universal-Function.html 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <html lang="en">
  2. <head>
  3. <title>The Universal Function - 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="Indirection.html#Indirection" title="Indirection">
  10. <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
  11. <meta http-equiv="Content-Style-Type" content="text/css">
  12. <style type="text/css"><!--
  13. pre.display { font-family:inherit }
  14. pre.format { font-family:inherit }
  15. pre.smalldisplay { font-family:inherit; font-size:smaller }
  16. pre.smallformat { font-family:inherit; font-size:smaller }
  17. pre.smallexample { font-size:smaller }
  18. pre.smalllisp { font-size:smaller }
  19. span.sc { font-variant:small-caps }
  20. span.roman { font-family:serif; font-weight:normal; }
  21. span.sansserif { font-family:sans-serif; font-weight:normal; }
  22. --></style>
  23. </head>
  24. <body>
  25. <div class="node">
  26. <a name="The-Universal-Function"></a>
  27. <p>
  28. Previous:&nbsp;<a rel="previous" accesskey="p" href="Indirection.html#Indirection">Indirection</a>,
  29. Up:&nbsp;<a rel="up" accesskey="u" href="Lists.html#Lists">Lists</a>
  30. <hr>
  31. </div>
  32. <h4 class="subsection">3.1.8 The Universal Function</h4>
  33. <p><a name="index-universal-function-501"></a>A function computing the result of the invisible operator used to
  34. specify the virtual code semantics in <a href="Virtual-Code-Semantics.html#Virtual-Code-Semantics">Virtual Code Semantics</a>, is
  35. easily available by way of a declaration in <samp><span class="file">apply.h</span></samp>.
  36. <div class="defun">
  37. &mdash; Function: void <b>avm_initialize_apply</b> ()<var><a name="index-avm_005finitialize_005fapply-502"></a></var><br>
  38. <blockquote><p>This function should be called by the client program at least once prior
  39. to the first call to <code>avm_apply</code> or
  40. <code>avm_recoverable_apply</code>. It causes certain internal data structures
  41. and error message texts to be initialized.
  42. </p></blockquote></div>
  43. <div class="defun">
  44. &mdash; Function: void <b>avm_count_apply</b> ()<var><a name="index-avm_005fcount_005fapply-503"></a></var><br>
  45. <blockquote><p>This function should be used at the end of a run for the purpose of
  46. detecting and reporting any unreclaimed storage associated with
  47. functions in this section. If the function <code>avm_count_lists()</code> is
  48. also being used, it should be called after this one.
  49. </p></blockquote></div>
  50. <div class="defun">
  51. &mdash; Function: list <b>avm_apply</b> (<var>list operator, list operand</var>)<var><a name="index-avm_005fapply-504"></a></var><br>
  52. <blockquote><p>This is the function that evaluates the operator used to describe the
  53. virtual code semantics. For example, the value of <var>f</var> <var>x</var>
  54. can be obtained as the result returned by
  55. <code>avm_apply(</code><var>f</var><code>,</code><var>x</var><code>)</code>.
  56. <p>Both parameters to this function are deallocated unconditionally and
  57. should not be referenced again by the caller. If the parameters are
  58. needed subsequently, then only copies of them should be passed to
  59. <code>avm_apply</code> using <code>avm_copied</code>.
  60. <p>This function is not guaranteed to terminate, and may cause a memory
  61. overflow error. In the event of an exceptional condition, the error
  62. message is written to standard error and the program is halted. There is
  63. no externally visible distinction between different levels of error
  64. conditions.
  65. </p></blockquote></div>
  66. <div class="defun">
  67. &mdash; Function: list <b>avm_recoverable_apply</b> (<var>list operator, list operand, int *fault</var>)<var><a name="index-avm_005frecoverable_005fapply-505"></a></var><br>
  68. <blockquote><p>This function is similar to <code>avm_apply</code> but leaves the
  69. responsibility of error handling with the caller. If any
  70. overflow or exceptional condition occurs, the result returned is a list
  71. representing the error message, and the <var>fault</var> flag is set to
  72. a non-zero value. This behavior contrasts with that of <code>avm_apply</code>,
  73. which will display the message to standard error and kill the process.
  74. </p></blockquote></div>
  75. </body></html>