type.texi 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. @node Pre-Scheme type specifiers
  2. @section Type specifiers
  3. @cindex Pre-Scheme type inference
  4. @cindex static types in Pre-Scheme
  5. Although Pre-Scheme's static type system is based mostly on
  6. Hindley-Milner type inference, with as little explicit type information
  7. as possible, there are still places where it is necessary to specify
  8. types explicitly; for example, @pxref{Pre-Scheme access to C functions
  9. and macros}. There are several different kinds of types with different
  10. syntax:
  11. @table @code
  12. @item @var{type-name}
  13. Symbols denote either record type or base types. Record types are
  14. defined with the @code{define-record-type} special form described
  15. later; the following base types are defined:
  16. @table @code
  17. @item integer
  18. Fixed-size integers (fixnums). This type is translated into C as
  19. @code{long}. The actual size depends on the size of C's @code{long},
  20. which on most architectures is 32 bits.
  21. @item float
  22. Floating-point data. This type translates to C as @code{double}.
  23. @item null
  24. Type which has no value. The @code{null} type translates to the C
  25. @code{void} type.
  26. @item unit
  27. Type which has one value. Actually, this, too, translates to C's
  28. @code{void}, so that it has one value is not strictly true.
  29. @item boolean
  30. Booleans translate to the C @code{char} type. @code{#t} is emitted as
  31. @code{TRUE}, and @code{#f}, as @code{FALSE}; these are usually the same
  32. as @code{1} & @code{0}, respectively.
  33. @item input-port
  34. @item output-port
  35. I/O ports. On Unix, since Pre-Scheme uses @code{stdio}, these are
  36. translated to @code{FILE *}s, @code{stdio} file streams.
  37. @item char
  38. Characters. The size of characters is dependent on the underlying C
  39. compiler's implementation of the @code{char} type.
  40. @item address
  41. Simple addresses for use in @embedref{Low-level Pre-Scheme memory
  42. manipulation, Pre-Scheme's low-level memory manipulation primitives};
  43. see that section for more details.
  44. @end table
  45. @item (=> (@var{argument-type} @dots{}) @var{return-type} @dots{})
  46. The types of procedures, known as `arrow' types.
  47. @item (^ @var{type})
  48. The type of pointers that point to @var{type}. Note that these are
  49. distinct from the address type. Pointer types are statically verified
  50. to be coherent data, with no defined operations except for accessing
  51. offsets in memory from the pointer --- @ie{} operations such as
  52. @code{vector-ref} ---; addresses simply index bytes, on which only
  53. direct dereferencing, but also arbitrary address arithmetic, is
  54. available. Pointers and addresses are @emph{not} interchangeable, and
  55. and there is no way to convert between them, as that would break the
  56. type safety of Pre-Scheme pointers.
  57. @item (tuple @var{type} @dots{})
  58. Multiple value types, internally used for argument & return types.
  59. @end table