diff-scm.texi 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. @node Differences between Pre-Scheme & Scheme
  2. @section Differences between Pre-Scheme & Scheme
  3. Pre-Scheme is often considered either a dialect of Scheme or a subset
  4. of Scheme. However, there are several very important fundamental
  5. differences between the semantics of Pre-Scheme & Scheme to detail.
  6. @table @strong
  7. @cindex Pre-Scheme memory management
  8. @cindex Pre-Scheme garbage collection
  9. @cindex memory management in Pre-Scheme
  10. @cindex garbage collection in Pre-Scheme
  11. @item There is no garbage collector in Pre-Scheme.
  12. All memory management is manual, as in C, although there are two levels
  13. to memory management, for higher- and lower-level purposes: pointers &
  14. addresses. Pointers represent higher-level data that are statically
  15. checked for type coherency, such as vectors of a certain element type,
  16. or strings. Addresses represent direct, low-level memory indices.
  17. @cindex closures in Pre-Scheme
  18. @cindex Pre-Scheme closures
  19. @item Pre-Scheme has no closures.
  20. @code{Lambda} expressions that would require full closures at run-time
  21. --- @eg{}, those whose values are stored in the heap --- are not
  22. permitted in Pre-Scheme. However, the Pre-Scheme compiler can hoist
  23. many @code{lambda} expressions to the top level, removing the need of
  24. closures for them. (Closures would be much less useful in the absence
  25. of garbage collection, in any case.) If the Pre-Scheme compiler is
  26. unable to move a @code{lambda} to a place where it requires no closure,
  27. it signals an error to the user.
  28. @cindex Pre-Scheme tail call optimization
  29. @cindex tail call optimization in Pre-Scheme
  30. @cindex tail recursion in Pre-Scheme
  31. @item Tail call optimization is not universal.
  32. The Pre-Scheme compiler optimizes tail calls where it is possible ---
  33. typically, just in local loops and top-level procedures that are not
  34. exported from the package, but there are other heuristics ---, but it
  35. is not universal. Programmers may force tail call optimization with
  36. Pre-Scheme's @code{goto} special form (@pxref{Tail call optimization in
  37. Pre-Scheme}), but, in situations where the compiler would not have
  38. optimized the tail call, this can make the generated code have to jump
  39. through many hoops to be a tail call --- often necessitating code bloat,
  40. because the code of the tail-called procedure is integrated into the
  41. caller's driver loop ---; and, where the compiler would have otherwise
  42. optimized the tail call, @code{goto} has no effect anyway.
  43. @cindex Pre-Scheme type inference
  44. @cindex static types in Pre-Scheme
  45. @item Types are strictly verified with Hindley-Milner type inference.
  46. The types of Pre-Scheme programs are statically verified based on
  47. Hindley-Milner type inference, with some modifications specific to
  48. Pre-Scheme. Type information is @emph{not} retained at run-time; any
  49. tagging must be performed explicitly.
  50. @cindex continuations in Pre-Scheme
  51. @item Pre-Scheme does not support first-class continuations.
  52. There is no @code{call-with-current-continuation} or other continuation
  53. manipulation interface. It has been suggested that downward-only
  54. continuations, based on C's @code{setjmp} & @code{longjmp}, might be
  55. implemented in the future, but this is not yet the case.@footnote{It
  56. may be possible to use Pre-Scheme's C FFI to manually use @code{setjmp}
  57. & @code{longjmp}, but the author of this manual cannot attest to this
  58. working.}
  59. @cindex Pre-Scheme numbers
  60. @cindex numbers in Pre-Scheme
  61. @item The full numeric tower of R5RS is not supported by Pre-Scheme.
  62. Pre-Scheme's only numeric types are fixnums and flonums, with precision
  63. determined by the architecture on which the Pre-Scheme code runs.
  64. Fixnums are translated to C as the @code{long} type; flonums are
  65. translated as the @code{float} type.
  66. @cindex top-level evaluation in Pre-Scheme
  67. @cindex evaluation of top-level code in Pre-Scheme
  68. @cindex Pre-Scheme top-level evaluation
  69. @cindex compile-time evaluation in Pre-Scheme
  70. @item Top-level Pre-Scheme code is evaluated at compile-time.
  71. Closures actually @emph{are} available, as long as they may be
  72. eliminated before run-time. Code evaluated at compile-time also does
  73. not require satisfaction of strict static typing. Moreover, certain
  74. procedures, such as @code{vector-length}, are available only at
  75. compile-time.
  76. @end table