Type-Conversions.html 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <html lang="en">
  2. <head>
  3. <title>Type Conversions - 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="List-Transformations.html#List-Transformations" title="List Transformations">
  10. <link rel="next" href="Comparison.html#Comparison" title="Comparison">
  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="Type-Conversions"></a>
  28. <p>
  29. Next:&nbsp;<a rel="next" accesskey="n" href="Comparison.html#Comparison">Comparison</a>,
  30. Previous:&nbsp;<a rel="previous" accesskey="p" href="List-Transformations.html#List-Transformations">List Transformations</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.4 Type Conversions</h4>
  35. <p>External library functions accessed by the <code>library</code> combinator
  36. as explained in <a href="Library-combinator.html#Library-combinator">Library combinator</a> may operate on data other
  37. than the <code>list</code> type usually used by <code>avram</code>, such as
  38. floating point numbers and arrays, but a virtual code application must
  39. be able to represent the arguments and results of these functions in
  40. order to use them. As a matter of convention, a data structure
  41. occupying <var>size</var> bytes of contiguous storage on the host machine
  42. appears as a list of length <var>size</var> to a virtual code application,
  43. in which each item corresponds to a byte, and is represented according
  44. to <a href="Character-Table.html#Character-Table">Character Table</a>.
  45. <p>In principle, a virtual code application invoking a library function
  46. to operate on a contiguous block of data, such as an IEEE double
  47. precision number, for example, would construct a list of eight
  48. character representations (one for each byte in a double precision
  49. number), and pass this list as an argument to the library
  50. function. The virtual machine would transparently convert this
  51. representation to the native floating point format, evaluate the
  52. function, and convert the result back to a list. In practice, high
  53. level language features beyond the scope of this document would
  54. insulate the programmer from some of the details on the application
  55. side as well.
  56. <p>To save the time of repeatedly converting between the list
  57. representation and the contiguous native binary representation, the
  58. structure referenced by a <code>list</code> pointer contains a <code>value</code>
  59. <a name="index-value-field-439"></a>field which is a <code>void</code> pointer to a block of memory of
  60. unspecified type, and serves as a persistent cache of the value
  61. represented by the list. This field normally should be managed by the
  62. API rather than being accessed directly by client modules, but see the
  63. code in <samp><span class="file">mpfr.c</span></samp> for an example of a situation in which it's
  64. appropriate to break this rule. (Generally these situations involve
  65. library functions operating on non-contiguous data.)
  66. <ul class="menu">
  67. <li><a accesskey="1" href="Primitive-types.html#Primitive-types">Primitive types</a>
  68. <li><a accesskey="2" href="One-dimensional-arrays.html#One-dimensional-arrays">One dimensional arrays</a>
  69. <li><a accesskey="3" href="Two-dimensional-arrays.html#Two-dimensional-arrays">Two dimensional arrays</a>
  70. <li><a accesskey="4" href="Related-utility-functions.html#Related-utility-functions">Related utility functions</a>
  71. </ul>
  72. </body></html>