LilyPond-Ruby 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1109) hide show
  1. checksums.yaml +4 -4
  2. data/etc/fonts/conf.d/10-hinting-slight.conf +15 -0
  3. data/etc/fonts/conf.d/10-scale-bitmap-fonts.conf +83 -0
  4. data/etc/fonts/conf.d/11-lcdfilter-default.conf +17 -0
  5. data/etc/fonts/conf.d/20-unhint-small-vera.conf +49 -0
  6. data/etc/fonts/conf.d/30-metric-aliases.conf +637 -0
  7. data/etc/fonts/conf.d/40-nonlatin.conf +332 -0
  8. data/etc/fonts/conf.d/45-generic.conf +136 -0
  9. data/etc/fonts/conf.d/45-latin.conf +301 -0
  10. data/etc/fonts/conf.d/48-spacing.conf +16 -0
  11. data/etc/fonts/conf.d/49-sansserif.conf +22 -0
  12. data/etc/fonts/conf.d/50-user.conf +16 -0
  13. data/etc/fonts/conf.d/51-local.conf +7 -0
  14. data/etc/fonts/conf.d/60-generic.conf +64 -0
  15. data/etc/fonts/conf.d/60-latin.conf +88 -0
  16. data/etc/fonts/conf.d/65-fonts-persian.conf +418 -0
  17. data/etc/fonts/conf.d/65-nonlatin.conf +228 -0
  18. data/etc/fonts/conf.d/69-unifont.conf +28 -0
  19. data/etc/fonts/conf.d/80-delicious.conf +19 -0
  20. data/etc/fonts/conf.d/90-synthetic.conf +64 -0
  21. data/etc/fonts/conf.d/README +23 -0
  22. data/etc/fonts/fonts.conf +101 -0
  23. data/etc/relocate/fontconfig.reloc +2 -0
  24. data/etc/relocate/guile.reloc +2 -0
  25. data/etc/relocate/libexec.reloc +1 -0
  26. data/lib/guile/2.2/ccache/ice-9/and-let-star.go +0 -0
  27. data/lib/guile/2.2/ccache/ice-9/arrays.go +0 -0
  28. data/lib/guile/2.2/ccache/ice-9/atomic.go +0 -0
  29. data/lib/guile/2.2/ccache/ice-9/binary-ports.go +0 -0
  30. data/lib/guile/2.2/ccache/ice-9/boot-9.go +0 -0
  31. data/lib/guile/2.2/ccache/ice-9/buffered-input.go +0 -0
  32. data/lib/guile/2.2/ccache/ice-9/calling.go +0 -0
  33. data/lib/guile/2.2/ccache/ice-9/channel.go +0 -0
  34. data/lib/guile/2.2/ccache/ice-9/command-line.go +0 -0
  35. data/lib/guile/2.2/ccache/ice-9/common-list.go +0 -0
  36. data/lib/guile/2.2/ccache/ice-9/control.go +0 -0
  37. data/lib/guile/2.2/ccache/ice-9/curried-definitions.go +0 -0
  38. data/lib/guile/2.2/ccache/ice-9/debug.go +0 -0
  39. data/lib/guile/2.2/ccache/ice-9/deprecated.go +0 -0
  40. data/lib/guile/2.2/ccache/ice-9/documentation.go +0 -0
  41. data/lib/guile/2.2/ccache/ice-9/eval-string.go +0 -0
  42. data/lib/guile/2.2/ccache/ice-9/eval.go +0 -0
  43. data/lib/guile/2.2/ccache/ice-9/expect.go +0 -0
  44. data/lib/guile/2.2/ccache/ice-9/fdes-finalizers.go +0 -0
  45. data/lib/guile/2.2/ccache/ice-9/format.go +0 -0
  46. data/lib/guile/2.2/ccache/ice-9/ftw.go +0 -0
  47. data/lib/guile/2.2/ccache/ice-9/futures.go +0 -0
  48. data/lib/guile/2.2/ccache/ice-9/gap-buffer.go +0 -0
  49. data/lib/guile/2.2/ccache/ice-9/getopt-long.go +0 -0
  50. data/lib/guile/2.2/ccache/ice-9/hash-table.go +0 -0
  51. data/lib/guile/2.2/ccache/ice-9/hcons.go +0 -0
  52. data/lib/guile/2.2/ccache/ice-9/history.go +0 -0
  53. data/lib/guile/2.2/ccache/ice-9/i18n.go +0 -0
  54. data/lib/guile/2.2/ccache/ice-9/iconv.go +0 -0
  55. data/lib/guile/2.2/ccache/ice-9/lineio.go +0 -0
  56. data/lib/guile/2.2/ccache/ice-9/list.go +0 -0
  57. data/lib/guile/2.2/ccache/ice-9/local-eval.go +0 -0
  58. data/lib/guile/2.2/ccache/ice-9/ls.go +0 -0
  59. data/lib/guile/2.2/ccache/ice-9/mapping.go +0 -0
  60. data/lib/guile/2.2/ccache/ice-9/match.go +0 -0
  61. data/lib/guile/2.2/ccache/ice-9/networking.go +0 -0
  62. data/lib/guile/2.2/ccache/ice-9/null.go +0 -0
  63. data/lib/guile/2.2/ccache/ice-9/occam-channel.go +0 -0
  64. data/lib/guile/2.2/ccache/ice-9/optargs.go +0 -0
  65. data/lib/guile/2.2/ccache/ice-9/peg/cache.go +0 -0
  66. data/lib/guile/2.2/ccache/ice-9/peg/codegen.go +0 -0
  67. data/lib/guile/2.2/ccache/ice-9/peg/simplify-tree.go +0 -0
  68. data/lib/guile/2.2/ccache/ice-9/peg/string-peg.go +0 -0
  69. data/lib/guile/2.2/ccache/ice-9/peg/using-parsers.go +0 -0
  70. data/lib/guile/2.2/ccache/ice-9/peg.go +0 -0
  71. data/lib/guile/2.2/ccache/ice-9/poe.go +0 -0
  72. data/lib/guile/2.2/ccache/ice-9/poll.go +0 -0
  73. data/lib/guile/2.2/ccache/ice-9/popen.go +0 -0
  74. data/lib/guile/2.2/ccache/ice-9/ports.go +0 -0
  75. data/lib/guile/2.2/ccache/ice-9/posix.go +0 -0
  76. data/lib/guile/2.2/ccache/ice-9/pretty-print.go +0 -0
  77. data/lib/guile/2.2/ccache/ice-9/psyntax-pp.go +0 -0
  78. data/lib/guile/2.2/ccache/ice-9/q.go +0 -0
  79. data/lib/guile/2.2/ccache/ice-9/r5rs.go +0 -0
  80. data/lib/guile/2.2/ccache/ice-9/rdelim.go +0 -0
  81. data/lib/guile/2.2/ccache/ice-9/receive.go +0 -0
  82. data/lib/guile/2.2/ccache/ice-9/regex.go +0 -0
  83. data/lib/guile/2.2/ccache/ice-9/runq.go +0 -0
  84. data/lib/guile/2.2/ccache/ice-9/rw.go +0 -0
  85. data/lib/guile/2.2/ccache/ice-9/safe-r5rs.go +0 -0
  86. data/lib/guile/2.2/ccache/ice-9/safe.go +0 -0
  87. data/lib/guile/2.2/ccache/ice-9/sandbox.go +0 -0
  88. data/lib/guile/2.2/ccache/ice-9/save-stack.go +0 -0
  89. data/lib/guile/2.2/ccache/ice-9/scm-style-repl.go +0 -0
  90. data/lib/guile/2.2/ccache/ice-9/serialize.go +0 -0
  91. data/lib/guile/2.2/ccache/ice-9/session.go +0 -0
  92. data/lib/guile/2.2/ccache/ice-9/slib.go +0 -0
  93. data/lib/guile/2.2/ccache/ice-9/stack-catch.go +0 -0
  94. data/lib/guile/2.2/ccache/ice-9/streams.go +0 -0
  95. data/lib/guile/2.2/ccache/ice-9/string-fun.go +0 -0
  96. data/lib/guile/2.2/ccache/ice-9/suspendable-ports.go +0 -0
  97. data/lib/guile/2.2/ccache/ice-9/syncase.go +0 -0
  98. data/lib/guile/2.2/ccache/ice-9/textual-ports.go +0 -0
  99. data/lib/guile/2.2/ccache/ice-9/threads.go +0 -0
  100. data/lib/guile/2.2/ccache/ice-9/time.go +0 -0
  101. data/lib/guile/2.2/ccache/ice-9/top-repl.go +0 -0
  102. data/lib/guile/2.2/ccache/ice-9/unicode.go +0 -0
  103. data/lib/guile/2.2/ccache/ice-9/vlist.go +0 -0
  104. data/lib/guile/2.2/ccache/ice-9/weak-vector.go +0 -0
  105. data/lib/guile/2.2/ccache/language/brainfuck/compile-scheme.go +0 -0
  106. data/lib/guile/2.2/ccache/language/brainfuck/compile-tree-il.go +0 -0
  107. data/lib/guile/2.2/ccache/language/brainfuck/parse.go +0 -0
  108. data/lib/guile/2.2/ccache/language/brainfuck/spec.go +0 -0
  109. data/lib/guile/2.2/ccache/language/bytecode/spec.go +0 -0
  110. data/lib/guile/2.2/ccache/language/bytecode.go +0 -0
  111. data/lib/guile/2.2/ccache/language/cps/closure-conversion.go +0 -0
  112. data/lib/guile/2.2/ccache/language/cps/compile-bytecode.go +0 -0
  113. data/lib/guile/2.2/ccache/language/cps/constructors.go +0 -0
  114. data/lib/guile/2.2/ccache/language/cps/contification.go +0 -0
  115. data/lib/guile/2.2/ccache/language/cps/cse.go +0 -0
  116. data/lib/guile/2.2/ccache/language/cps/dce.go +0 -0
  117. data/lib/guile/2.2/ccache/language/cps/effects-analysis.go +0 -0
  118. data/lib/guile/2.2/ccache/language/cps/elide-values.go +0 -0
  119. data/lib/guile/2.2/ccache/language/cps/handle-interrupts.go +0 -0
  120. data/lib/guile/2.2/ccache/language/cps/intmap.go +0 -0
  121. data/lib/guile/2.2/ccache/language/cps/intset.go +0 -0
  122. data/lib/guile/2.2/ccache/language/cps/licm.go +0 -0
  123. data/lib/guile/2.2/ccache/language/cps/optimize.go +0 -0
  124. data/lib/guile/2.2/ccache/language/cps/peel-loops.go +0 -0
  125. data/lib/guile/2.2/ccache/language/cps/primitives.go +0 -0
  126. data/lib/guile/2.2/ccache/language/cps/prune-bailouts.go +0 -0
  127. data/lib/guile/2.2/ccache/language/cps/prune-top-level-scopes.go +0 -0
  128. data/lib/guile/2.2/ccache/language/cps/reify-primitives.go +0 -0
  129. data/lib/guile/2.2/ccache/language/cps/renumber.go +0 -0
  130. data/lib/guile/2.2/ccache/language/cps/rotate-loops.go +0 -0
  131. data/lib/guile/2.2/ccache/language/cps/self-references.go +0 -0
  132. data/lib/guile/2.2/ccache/language/cps/simplify.go +0 -0
  133. data/lib/guile/2.2/ccache/language/cps/slot-allocation.go +0 -0
  134. data/lib/guile/2.2/ccache/language/cps/spec.go +0 -0
  135. data/lib/guile/2.2/ccache/language/cps/specialize-numbers.go +0 -0
  136. data/lib/guile/2.2/ccache/language/cps/specialize-primcalls.go +0 -0
  137. data/lib/guile/2.2/ccache/language/cps/split-rec.go +0 -0
  138. data/lib/guile/2.2/ccache/language/cps/type-checks.go +0 -0
  139. data/lib/guile/2.2/ccache/language/cps/type-fold.go +0 -0
  140. data/lib/guile/2.2/ccache/language/cps/types.go +0 -0
  141. data/lib/guile/2.2/ccache/language/cps/utils.go +0 -0
  142. data/lib/guile/2.2/ccache/language/cps/verify.go +0 -0
  143. data/lib/guile/2.2/ccache/language/cps/with-cps.go +0 -0
  144. data/lib/guile/2.2/ccache/language/cps.go +0 -0
  145. data/lib/guile/2.2/ccache/language/ecmascript/array.go +0 -0
  146. data/lib/guile/2.2/ccache/language/ecmascript/base.go +0 -0
  147. data/lib/guile/2.2/ccache/language/ecmascript/compile-tree-il.go +0 -0
  148. data/lib/guile/2.2/ccache/language/ecmascript/function.go +0 -0
  149. data/lib/guile/2.2/ccache/language/ecmascript/impl.go +0 -0
  150. data/lib/guile/2.2/ccache/language/ecmascript/parse.go +0 -0
  151. data/lib/guile/2.2/ccache/language/ecmascript/spec.go +0 -0
  152. data/lib/guile/2.2/ccache/language/ecmascript/tokenize.go +0 -0
  153. data/lib/guile/2.2/ccache/language/elisp/bindings.go +0 -0
  154. data/lib/guile/2.2/ccache/language/elisp/boot.go +0 -0
  155. data/lib/guile/2.2/ccache/language/elisp/compile-tree-il.go +0 -0
  156. data/lib/guile/2.2/ccache/language/elisp/falias.go +0 -0
  157. data/lib/guile/2.2/ccache/language/elisp/lexer.go +0 -0
  158. data/lib/guile/2.2/ccache/language/elisp/parser.go +0 -0
  159. data/lib/guile/2.2/ccache/language/elisp/runtime/function-slot.go +0 -0
  160. data/lib/guile/2.2/ccache/language/elisp/runtime/value-slot.go +0 -0
  161. data/lib/guile/2.2/ccache/language/elisp/runtime.go +0 -0
  162. data/lib/guile/2.2/ccache/language/elisp/spec.go +0 -0
  163. data/lib/guile/2.2/ccache/language/scheme/compile-tree-il.go +0 -0
  164. data/lib/guile/2.2/ccache/language/scheme/decompile-tree-il.go +0 -0
  165. data/lib/guile/2.2/ccache/language/scheme/spec.go +0 -0
  166. data/lib/guile/2.2/ccache/language/tree-il/analyze.go +0 -0
  167. data/lib/guile/2.2/ccache/language/tree-il/canonicalize.go +0 -0
  168. data/lib/guile/2.2/ccache/language/tree-il/compile-cps.go +0 -0
  169. data/lib/guile/2.2/ccache/language/tree-il/debug.go +0 -0
  170. data/lib/guile/2.2/ccache/language/tree-il/effects.go +0 -0
  171. data/lib/guile/2.2/ccache/language/tree-il/fix-letrec.go +0 -0
  172. data/lib/guile/2.2/ccache/language/tree-il/optimize.go +0 -0
  173. data/lib/guile/2.2/ccache/language/tree-il/peval.go +0 -0
  174. data/lib/guile/2.2/ccache/language/tree-il/primitives.go +0 -0
  175. data/lib/guile/2.2/ccache/language/tree-il/spec.go +0 -0
  176. data/lib/guile/2.2/ccache/language/tree-il.go +0 -0
  177. data/lib/guile/2.2/ccache/language/value/spec.go +0 -0
  178. data/lib/guile/2.2/ccache/oop/goops/accessors.go +0 -0
  179. data/lib/guile/2.2/ccache/oop/goops/active-slot.go +0 -0
  180. data/lib/guile/2.2/ccache/oop/goops/composite-slot.go +0 -0
  181. data/lib/guile/2.2/ccache/oop/goops/describe.go +0 -0
  182. data/lib/guile/2.2/ccache/oop/goops/internal.go +0 -0
  183. data/lib/guile/2.2/ccache/oop/goops/save.go +0 -0
  184. data/lib/guile/2.2/ccache/oop/goops/simple.go +0 -0
  185. data/lib/guile/2.2/ccache/oop/goops/stklos.go +0 -0
  186. data/lib/guile/2.2/ccache/oop/goops.go +0 -0
  187. data/lib/guile/2.2/ccache/rnrs/arithmetic/bitwise.go +0 -0
  188. data/lib/guile/2.2/ccache/rnrs/arithmetic/fixnums.go +0 -0
  189. data/lib/guile/2.2/ccache/rnrs/arithmetic/flonums.go +0 -0
  190. data/lib/guile/2.2/ccache/rnrs/base.go +0 -0
  191. data/lib/guile/2.2/ccache/rnrs/bytevectors.go +0 -0
  192. data/lib/guile/2.2/ccache/rnrs/conditions.go +0 -0
  193. data/lib/guile/2.2/ccache/rnrs/control.go +0 -0
  194. data/lib/guile/2.2/ccache/rnrs/enums.go +0 -0
  195. data/lib/guile/2.2/ccache/rnrs/eval.go +0 -0
  196. data/lib/guile/2.2/ccache/rnrs/exceptions.go +0 -0
  197. data/lib/guile/2.2/ccache/rnrs/files.go +0 -0
  198. data/lib/guile/2.2/ccache/rnrs/hashtables.go +0 -0
  199. data/lib/guile/2.2/ccache/rnrs/io/ports.go +0 -0
  200. data/lib/guile/2.2/ccache/rnrs/io/simple.go +0 -0
  201. data/lib/guile/2.2/ccache/rnrs/lists.go +0 -0
  202. data/lib/guile/2.2/ccache/rnrs/mutable-pairs.go +0 -0
  203. data/lib/guile/2.2/ccache/rnrs/mutable-strings.go +0 -0
  204. data/lib/guile/2.2/ccache/rnrs/programs.go +0 -0
  205. data/lib/guile/2.2/ccache/rnrs/r5rs.go +0 -0
  206. data/lib/guile/2.2/ccache/rnrs/records/inspection.go +0 -0
  207. data/lib/guile/2.2/ccache/rnrs/records/procedural.go +0 -0
  208. data/lib/guile/2.2/ccache/rnrs/records/syntactic.go +0 -0
  209. data/lib/guile/2.2/ccache/rnrs/sorting.go +0 -0
  210. data/lib/guile/2.2/ccache/rnrs/syntax-case.go +0 -0
  211. data/lib/guile/2.2/ccache/rnrs/unicode.go +0 -0
  212. data/lib/guile/2.2/ccache/rnrs.go +0 -0
  213. data/lib/guile/2.2/ccache/scripts/api-diff.go +0 -0
  214. data/lib/guile/2.2/ccache/scripts/autofrisk.go +0 -0
  215. data/lib/guile/2.2/ccache/scripts/compile.go +0 -0
  216. data/lib/guile/2.2/ccache/scripts/disassemble.go +0 -0
  217. data/lib/guile/2.2/ccache/scripts/display-commentary.go +0 -0
  218. data/lib/guile/2.2/ccache/scripts/doc-snarf.go +0 -0
  219. data/lib/guile/2.2/ccache/scripts/frisk.go +0 -0
  220. data/lib/guile/2.2/ccache/scripts/generate-autoload.go +0 -0
  221. data/lib/guile/2.2/ccache/scripts/help.go +0 -0
  222. data/lib/guile/2.2/ccache/scripts/lint.go +0 -0
  223. data/lib/guile/2.2/ccache/scripts/list.go +0 -0
  224. data/lib/guile/2.2/ccache/scripts/punify.go +0 -0
  225. data/lib/guile/2.2/ccache/scripts/read-rfc822.go +0 -0
  226. data/lib/guile/2.2/ccache/scripts/read-scheme-source.go +0 -0
  227. data/lib/guile/2.2/ccache/scripts/read-text-outline.go +0 -0
  228. data/lib/guile/2.2/ccache/scripts/scan-api.go +0 -0
  229. data/lib/guile/2.2/ccache/scripts/snarf-check-and-output-texi.go +0 -0
  230. data/lib/guile/2.2/ccache/scripts/snarf-guile-m4-docs.go +0 -0
  231. data/lib/guile/2.2/ccache/scripts/summarize-guile-TODO.go +0 -0
  232. data/lib/guile/2.2/ccache/scripts/use2dot.go +0 -0
  233. data/lib/guile/2.2/ccache/srfi/srfi-1.go +0 -0
  234. data/lib/guile/2.2/ccache/srfi/srfi-10.go +0 -0
  235. data/lib/guile/2.2/ccache/srfi/srfi-11.go +0 -0
  236. data/lib/guile/2.2/ccache/srfi/srfi-111.go +0 -0
  237. data/lib/guile/2.2/ccache/srfi/srfi-13.go +0 -0
  238. data/lib/guile/2.2/ccache/srfi/srfi-14.go +0 -0
  239. data/lib/guile/2.2/ccache/srfi/srfi-16.go +0 -0
  240. data/lib/guile/2.2/ccache/srfi/srfi-17.go +0 -0
  241. data/lib/guile/2.2/ccache/srfi/srfi-18.go +0 -0
  242. data/lib/guile/2.2/ccache/srfi/srfi-19.go +0 -0
  243. data/lib/guile/2.2/ccache/srfi/srfi-2.go +0 -0
  244. data/lib/guile/2.2/ccache/srfi/srfi-26.go +0 -0
  245. data/lib/guile/2.2/ccache/srfi/srfi-27.go +0 -0
  246. data/lib/guile/2.2/ccache/srfi/srfi-28.go +0 -0
  247. data/lib/guile/2.2/ccache/srfi/srfi-31.go +0 -0
  248. data/lib/guile/2.2/ccache/srfi/srfi-34.go +0 -0
  249. data/lib/guile/2.2/ccache/srfi/srfi-35.go +0 -0
  250. data/lib/guile/2.2/ccache/srfi/srfi-37.go +0 -0
  251. data/lib/guile/2.2/ccache/srfi/srfi-38.go +0 -0
  252. data/lib/guile/2.2/ccache/srfi/srfi-39.go +0 -0
  253. data/lib/guile/2.2/ccache/srfi/srfi-4/gnu.go +0 -0
  254. data/lib/guile/2.2/ccache/srfi/srfi-4.go +0 -0
  255. data/lib/guile/2.2/ccache/srfi/srfi-41.go +0 -0
  256. data/lib/guile/2.2/ccache/srfi/srfi-42.go +0 -0
  257. data/lib/guile/2.2/ccache/srfi/srfi-43.go +0 -0
  258. data/lib/guile/2.2/ccache/srfi/srfi-45.go +0 -0
  259. data/lib/guile/2.2/ccache/srfi/srfi-6.go +0 -0
  260. data/lib/guile/2.2/ccache/srfi/srfi-60.go +0 -0
  261. data/lib/guile/2.2/ccache/srfi/srfi-64.go +0 -0
  262. data/lib/guile/2.2/ccache/srfi/srfi-67.go +0 -0
  263. data/lib/guile/2.2/ccache/srfi/srfi-69.go +0 -0
  264. data/lib/guile/2.2/ccache/srfi/srfi-71.go +0 -0
  265. data/lib/guile/2.2/ccache/srfi/srfi-8.go +0 -0
  266. data/lib/guile/2.2/ccache/srfi/srfi-88.go +0 -0
  267. data/lib/guile/2.2/ccache/srfi/srfi-9/gnu.go +0 -0
  268. data/lib/guile/2.2/ccache/srfi/srfi-9.go +0 -0
  269. data/lib/guile/2.2/ccache/srfi/srfi-98.go +0 -0
  270. data/lib/guile/2.2/ccache/statprof.go +0 -0
  271. data/lib/guile/2.2/ccache/sxml/apply-templates.go +0 -0
  272. data/lib/guile/2.2/ccache/sxml/fold.go +0 -0
  273. data/lib/guile/2.2/ccache/sxml/match.go +0 -0
  274. data/lib/guile/2.2/ccache/sxml/simple.go +0 -0
  275. data/lib/guile/2.2/ccache/sxml/ssax/input-parse.go +0 -0
  276. data/lib/guile/2.2/ccache/sxml/ssax.go +0 -0
  277. data/lib/guile/2.2/ccache/sxml/transform.go +0 -0
  278. data/lib/guile/2.2/ccache/sxml/xpath.go +0 -0
  279. data/lib/guile/2.2/ccache/system/base/ck.go +0 -0
  280. data/lib/guile/2.2/ccache/system/base/compile.go +0 -0
  281. data/lib/guile/2.2/ccache/system/base/lalr.go +0 -0
  282. data/lib/guile/2.2/ccache/system/base/language.go +0 -0
  283. data/lib/guile/2.2/ccache/system/base/message.go +0 -0
  284. data/lib/guile/2.2/ccache/system/base/pmatch.go +0 -0
  285. data/lib/guile/2.2/ccache/system/base/syntax.go +0 -0
  286. data/lib/guile/2.2/ccache/system/base/target.go +0 -0
  287. data/lib/guile/2.2/ccache/system/base/types.go +0 -0
  288. data/lib/guile/2.2/ccache/system/foreign-object.go +0 -0
  289. data/lib/guile/2.2/ccache/system/foreign.go +0 -0
  290. data/lib/guile/2.2/ccache/system/repl/command.go +0 -0
  291. data/lib/guile/2.2/ccache/system/repl/common.go +0 -0
  292. data/lib/guile/2.2/ccache/system/repl/coop-server.go +0 -0
  293. data/lib/guile/2.2/ccache/system/repl/debug.go +0 -0
  294. data/lib/guile/2.2/ccache/system/repl/error-handling.go +0 -0
  295. data/lib/guile/2.2/ccache/system/repl/repl.go +0 -0
  296. data/lib/guile/2.2/ccache/system/repl/server.go +0 -0
  297. data/lib/guile/2.2/ccache/system/syntax.go +0 -0
  298. data/lib/guile/2.2/ccache/system/vm/assembler.go +0 -0
  299. data/lib/guile/2.2/ccache/system/vm/coverage.go +0 -0
  300. data/lib/guile/2.2/ccache/system/vm/debug.go +0 -0
  301. data/lib/guile/2.2/ccache/system/vm/disassembler.go +0 -0
  302. data/lib/guile/2.2/ccache/system/vm/dwarf.go +0 -0
  303. data/lib/guile/2.2/ccache/system/vm/elf.go +0 -0
  304. data/lib/guile/2.2/ccache/system/vm/frame.go +0 -0
  305. data/lib/guile/2.2/ccache/system/vm/inspect.go +0 -0
  306. data/lib/guile/2.2/ccache/system/vm/linker.go +0 -0
  307. data/lib/guile/2.2/ccache/system/vm/loader.go +0 -0
  308. data/lib/guile/2.2/ccache/system/vm/program.go +0 -0
  309. data/lib/guile/2.2/ccache/system/vm/trace.go +0 -0
  310. data/lib/guile/2.2/ccache/system/vm/trap-state.go +0 -0
  311. data/lib/guile/2.2/ccache/system/vm/traps.go +0 -0
  312. data/lib/guile/2.2/ccache/system/vm/vm.go +0 -0
  313. data/lib/guile/2.2/ccache/system/xref.go +0 -0
  314. data/lib/guile/2.2/ccache/texinfo/docbook.go +0 -0
  315. data/lib/guile/2.2/ccache/texinfo/html.go +0 -0
  316. data/lib/guile/2.2/ccache/texinfo/indexing.go +0 -0
  317. data/lib/guile/2.2/ccache/texinfo/plain-text.go +0 -0
  318. data/lib/guile/2.2/ccache/texinfo/reflection.go +0 -0
  319. data/lib/guile/2.2/ccache/texinfo/serialize.go +0 -0
  320. data/lib/guile/2.2/ccache/texinfo/string-utils.go +0 -0
  321. data/lib/guile/2.2/ccache/texinfo.go +0 -0
  322. data/lib/guile/2.2/ccache/web/client.go +0 -0
  323. data/lib/guile/2.2/ccache/web/http.go +0 -0
  324. data/lib/guile/2.2/ccache/web/request.go +0 -0
  325. data/lib/guile/2.2/ccache/web/response.go +0 -0
  326. data/lib/guile/2.2/ccache/web/server/http.go +0 -0
  327. data/lib/guile/2.2/ccache/web/server.go +0 -0
  328. data/lib/guile/2.2/ccache/web/uri.go +0 -0
  329. data/lib/lilypond/2.24.1/ccache/lily/accreg.go +0 -0
  330. data/lib/lilypond/2.24.1/ccache/lily/auto-beam.go +0 -0
  331. data/lib/lilypond/2.24.1/ccache/lily/autochange.go +0 -0
  332. data/lib/lilypond/2.24.1/ccache/lily/backend-library.go +0 -0
  333. data/lib/lilypond/2.24.1/ccache/lily/bar-line.go +0 -0
  334. data/lib/lilypond/2.24.1/ccache/lily/breath.go +0 -0
  335. data/lib/lilypond/2.24.1/ccache/lily/c++.go +0 -0
  336. data/lib/lilypond/2.24.1/ccache/lily/chord-entry.go +0 -0
  337. data/lib/lilypond/2.24.1/ccache/lily/chord-ignatzek-names.go +0 -0
  338. data/lib/lilypond/2.24.1/ccache/lily/chord-name.go +0 -0
  339. data/lib/lilypond/2.24.1/ccache/lily/clip-region.go +0 -0
  340. data/lib/lilypond/2.24.1/ccache/lily/color.go +0 -0
  341. data/lib/lilypond/2.24.1/ccache/lily/curried-definitions.go +0 -0
  342. data/lib/lilypond/2.24.1/ccache/lily/define-context-properties.go +0 -0
  343. data/lib/lilypond/2.24.1/ccache/lily/define-event-classes.go +0 -0
  344. data/lib/lilypond/2.24.1/ccache/lily/define-grob-interfaces.go +0 -0
  345. data/lib/lilypond/2.24.1/ccache/lily/define-grob-properties.go +0 -0
  346. data/lib/lilypond/2.24.1/ccache/lily/define-grobs.go +0 -0
  347. data/lib/lilypond/2.24.1/ccache/lily/define-markup-commands.go +0 -0
  348. data/lib/lilypond/2.24.1/ccache/lily/define-music-callbacks.go +0 -0
  349. data/lib/lilypond/2.24.1/ccache/lily/define-music-display-methods.go +0 -0
  350. data/lib/lilypond/2.24.1/ccache/lily/define-music-properties.go +0 -0
  351. data/lib/lilypond/2.24.1/ccache/lily/define-music-types.go +0 -0
  352. data/lib/lilypond/2.24.1/ccache/lily/define-note-names.go +0 -0
  353. data/lib/lilypond/2.24.1/ccache/lily/define-stencil-commands.go +0 -0
  354. data/lib/lilypond/2.24.1/ccache/lily/define-woodwind-diagrams.go +0 -0
  355. data/lib/lilypond/2.24.1/ccache/lily/display-lily.go +0 -0
  356. data/lib/lilypond/2.24.1/ccache/lily/display-woodwind-diagrams.go +0 -0
  357. data/lib/lilypond/2.24.1/ccache/lily/file-cache.go +0 -0
  358. data/lib/lilypond/2.24.1/ccache/lily/flag-styles.go +0 -0
  359. data/lib/lilypond/2.24.1/ccache/lily/font-encodings.go +0 -0
  360. data/lib/lilypond/2.24.1/ccache/lily/font.go +0 -0
  361. data/lib/lilypond/2.24.1/ccache/lily/framework-cairo.go +0 -0
  362. data/lib/lilypond/2.24.1/ccache/lily/framework-ps.go +0 -0
  363. data/lib/lilypond/2.24.1/ccache/lily/framework-svg.go +0 -0
  364. data/lib/lilypond/2.24.1/ccache/lily/fret-diagrams.go +0 -0
  365. data/lib/lilypond/2.24.1/ccache/lily/graphviz.go +0 -0
  366. data/lib/lilypond/2.24.1/ccache/lily/harp-pedals.go +0 -0
  367. data/lib/lilypond/2.24.1/ccache/lily/layout-beam.go +0 -0
  368. data/lib/lilypond/2.24.1/ccache/lily/layout-slur.go +0 -0
  369. data/lib/lilypond/2.24.1/ccache/lily/lily-library.go +0 -0
  370. data/lib/lilypond/2.24.1/ccache/lily/lily.go +0 -0
  371. data/lib/lilypond/2.24.1/ccache/lily/ly-syntax-constructors.go +0 -0
  372. data/lib/lilypond/2.24.1/ccache/lily/markup-macros.go +0 -0
  373. data/lib/lilypond/2.24.1/ccache/lily/markup.go +0 -0
  374. data/lib/lilypond/2.24.1/ccache/lily/midi.go +0 -0
  375. data/lib/lilypond/2.24.1/ccache/lily/modal-transforms.go +0 -0
  376. data/lib/lilypond/2.24.1/ccache/lily/music-functions.go +0 -0
  377. data/lib/lilypond/2.24.1/ccache/lily/output-lib.go +0 -0
  378. data/lib/lilypond/2.24.1/ccache/lily/output-ps.go +0 -0
  379. data/lib/lilypond/2.24.1/ccache/lily/output-svg.go +0 -0
  380. data/lib/lilypond/2.24.1/ccache/lily/page.go +0 -0
  381. data/lib/lilypond/2.24.1/ccache/lily/paper-system.go +0 -0
  382. data/lib/lilypond/2.24.1/ccache/lily/paper.go +0 -0
  383. data/lib/lilypond/2.24.1/ccache/lily/parser-clef.go +0 -0
  384. data/lib/lilypond/2.24.1/ccache/lily/parser-ly-from-scheme.go +0 -0
  385. data/lib/lilypond/2.24.1/ccache/lily/part-combiner.go +0 -0
  386. data/lib/lilypond/2.24.1/ccache/lily/predefined-fretboards.go +0 -0
  387. data/lib/lilypond/2.24.1/ccache/lily/ps-to-png.go +0 -0
  388. data/lib/lilypond/2.24.1/ccache/lily/scheme-engravers.go +0 -0
  389. data/lib/lilypond/2.24.1/ccache/lily/scheme-performers.go +0 -0
  390. data/lib/lilypond/2.24.1/ccache/lily/script.go +0 -0
  391. data/lib/lilypond/2.24.1/ccache/lily/skyline.go +0 -0
  392. data/lib/lilypond/2.24.1/ccache/lily/song-util.go +0 -0
  393. data/lib/lilypond/2.24.1/ccache/lily/song.go +0 -0
  394. data/lib/lilypond/2.24.1/ccache/lily/stencil.go +0 -0
  395. data/lib/lilypond/2.24.1/ccache/lily/tablature.go +0 -0
  396. data/lib/lilypond/2.24.1/ccache/lily/time-signature-settings.go +0 -0
  397. data/lib/lilypond/2.24.1/ccache/lily/time-signature.go +0 -0
  398. data/lib/lilypond/2.24.1/ccache/lily/titling.go +0 -0
  399. data/lib/lilypond/2.24.1/ccache/lily/to-xml.go +0 -0
  400. data/lib/lilypond/2.24.1/ccache/lily/translation-functions.go +0 -0
  401. data/share/emacs/site-lisp/lilypond-font-lock.el +208 -0
  402. data/share/emacs/site-lisp/lilypond-indent.el +605 -0
  403. data/share/emacs/site-lisp/lilypond-init.el +21 -0
  404. data/share/emacs/site-lisp/lilypond-mode.el +1204 -0
  405. data/share/emacs/site-lisp/lilypond-song.el +556 -0
  406. data/share/emacs/site-lisp/lilypond-what-beat.el +279 -0
  407. data/share/emacs/site-lisp/lilypond-words.el +1428 -0
  408. data/share/guile/2.2/guile-procedures.txt +8860 -0
  409. data/share/guile/2.2/ice-9/and-let-star.scm +73 -0
  410. data/share/guile/2.2/ice-9/arrays.scm +70 -0
  411. data/share/guile/2.2/ice-9/atomic.scm +38 -0
  412. data/share/guile/2.2/ice-9/binary-ports.scm +53 -0
  413. data/share/guile/2.2/ice-9/boot-9.scm +4131 -0
  414. data/share/guile/2.2/ice-9/buffered-input.scm +109 -0
  415. data/share/guile/2.2/ice-9/calling.scm +326 -0
  416. data/share/guile/2.2/ice-9/channel.scm +170 -0
  417. data/share/guile/2.2/ice-9/command-line.scm +477 -0
  418. data/share/guile/2.2/ice-9/common-list.scm +278 -0
  419. data/share/guile/2.2/ice-9/control.scm +110 -0
  420. data/share/guile/2.2/ice-9/curried-definitions.scm +57 -0
  421. data/share/guile/2.2/ice-9/debug.scm +25 -0
  422. data/share/guile/2.2/ice-9/deprecated.scm +93 -0
  423. data/share/guile/2.2/ice-9/documentation.scm +203 -0
  424. data/share/guile/2.2/ice-9/eval-string.scm +90 -0
  425. data/share/guile/2.2/ice-9/eval.scm +723 -0
  426. data/share/guile/2.2/ice-9/expect.scm +171 -0
  427. data/share/guile/2.2/ice-9/fdes-finalizers.scm +25 -0
  428. data/share/guile/2.2/ice-9/format.scm +1626 -0
  429. data/share/guile/2.2/ice-9/ftw.scm +564 -0
  430. data/share/guile/2.2/ice-9/futures.scm +308 -0
  431. data/share/guile/2.2/ice-9/gap-buffer.scm +283 -0
  432. data/share/guile/2.2/ice-9/getopt-long.scm +371 -0
  433. data/share/guile/2.2/ice-9/hash-table.scm +45 -0
  434. data/share/guile/2.2/ice-9/hcons.scm +80 -0
  435. data/share/guile/2.2/ice-9/history.scm +65 -0
  436. data/share/guile/2.2/ice-9/i18n.scm +531 -0
  437. data/share/guile/2.2/ice-9/iconv.scm +95 -0
  438. data/share/guile/2.2/ice-9/lineio.scm +115 -0
  439. data/share/guile/2.2/ice-9/list.scm +36 -0
  440. data/share/guile/2.2/ice-9/local-eval.scm +261 -0
  441. data/share/guile/2.2/ice-9/ls.scm +94 -0
  442. data/share/guile/2.2/ice-9/mapping.scm +118 -0
  443. data/share/guile/2.2/ice-9/match.scm +59 -0
  444. data/share/guile/2.2/ice-9/match.upstream.scm +917 -0
  445. data/share/guile/2.2/ice-9/networking.scm +94 -0
  446. data/share/guile/2.2/ice-9/null.scm +34 -0
  447. data/share/guile/2.2/ice-9/occam-channel.scm +261 -0
  448. data/share/guile/2.2/ice-9/optargs.scm +381 -0
  449. data/share/guile/2.2/ice-9/peg/cache.scm +45 -0
  450. data/share/guile/2.2/ice-9/peg/codegen.scm +359 -0
  451. data/share/guile/2.2/ice-9/peg/simplify-tree.scm +97 -0
  452. data/share/guile/2.2/ice-9/peg/string-peg.scm +273 -0
  453. data/share/guile/2.2/ice-9/peg/using-parsers.scm +116 -0
  454. data/share/guile/2.2/ice-9/peg.scm +42 -0
  455. data/share/guile/2.2/ice-9/poe.scm +116 -0
  456. data/share/guile/2.2/ice-9/poll.scm +172 -0
  457. data/share/guile/2.2/ice-9/popen.scm +178 -0
  458. data/share/guile/2.2/ice-9/ports.scm +566 -0
  459. data/share/guile/2.2/ice-9/posix.scm +75 -0
  460. data/share/guile/2.2/ice-9/pretty-print.scm +483 -0
  461. data/share/guile/2.2/ice-9/psyntax-pp.scm +3542 -0
  462. data/share/guile/2.2/ice-9/psyntax.scm +3326 -0
  463. data/share/guile/2.2/ice-9/q.scm +153 -0
  464. data/share/guile/2.2/ice-9/quasisyntax.scm +136 -0
  465. data/share/guile/2.2/ice-9/r5rs.scm +45 -0
  466. data/share/guile/2.2/ice-9/r6rs-libraries.scm +242 -0
  467. data/share/guile/2.2/ice-9/rdelim.scm +208 -0
  468. data/share/guile/2.2/ice-9/receive.scm +26 -0
  469. data/share/guile/2.2/ice-9/regex.scm +229 -0
  470. data/share/guile/2.2/ice-9/runq.scm +241 -0
  471. data/share/guile/2.2/ice-9/rw.scm +27 -0
  472. data/share/guile/2.2/ice-9/safe-r5rs.scm +145 -0
  473. data/share/guile/2.2/ice-9/safe.scm +34 -0
  474. data/share/guile/2.2/ice-9/sandbox.scm +1399 -0
  475. data/share/guile/2.2/ice-9/save-stack.scm +58 -0
  476. data/share/guile/2.2/ice-9/scm-style-repl.scm +279 -0
  477. data/share/guile/2.2/ice-9/serialize.scm +114 -0
  478. data/share/guile/2.2/ice-9/session.scm +530 -0
  479. data/share/guile/2.2/ice-9/slib.scm +33 -0
  480. data/share/guile/2.2/ice-9/stack-catch.scm +47 -0
  481. data/share/guile/2.2/ice-9/streams.scm +168 -0
  482. data/share/guile/2.2/ice-9/string-fun.scm +280 -0
  483. data/share/guile/2.2/ice-9/suspendable-ports.scm +788 -0
  484. data/share/guile/2.2/ice-9/syncase.scm +37 -0
  485. data/share/guile/2.2/ice-9/textual-ports.scm +70 -0
  486. data/share/guile/2.2/ice-9/threads.scm +392 -0
  487. data/share/guile/2.2/ice-9/time.scm +58 -0
  488. data/share/guile/2.2/ice-9/top-repl.scm +78 -0
  489. data/share/guile/2.2/ice-9/unicode.scm +26 -0
  490. data/share/guile/2.2/ice-9/vlist.scm +595 -0
  491. data/share/guile/2.2/ice-9/weak-vector.scm +31 -0
  492. data/share/guile/2.2/language/brainfuck/compile-scheme.scm +123 -0
  493. data/share/guile/2.2/language/brainfuck/compile-tree-il.scm +184 -0
  494. data/share/guile/2.2/language/brainfuck/parse.scm +95 -0
  495. data/share/guile/2.2/language/brainfuck/spec.scm +43 -0
  496. data/share/guile/2.2/language/bytecode/spec.scm +42 -0
  497. data/share/guile/2.2/language/bytecode.scm +104 -0
  498. data/share/guile/2.2/language/cps/closure-conversion.scm +848 -0
  499. data/share/guile/2.2/language/cps/compile-bytecode.scm +610 -0
  500. data/share/guile/2.2/language/cps/constructors.scm +106 -0
  501. data/share/guile/2.2/language/cps/contification.scm +448 -0
  502. data/share/guile/2.2/language/cps/cse.scm +414 -0
  503. data/share/guile/2.2/language/cps/dce.scm +363 -0
  504. data/share/guile/2.2/language/cps/effects-analysis.scm +597 -0
  505. data/share/guile/2.2/language/cps/elide-values.scm +88 -0
  506. data/share/guile/2.2/language/cps/handle-interrupts.scm +69 -0
  507. data/share/guile/2.2/language/cps/intmap.scm +765 -0
  508. data/share/guile/2.2/language/cps/intset.scm +830 -0
  509. data/share/guile/2.2/language/cps/licm.scm +308 -0
  510. data/share/guile/2.2/language/cps/optimize.scm +135 -0
  511. data/share/guile/2.2/language/cps/peel-loops.scm +287 -0
  512. data/share/guile/2.2/language/cps/primitives.scm +141 -0
  513. data/share/guile/2.2/language/cps/prune-bailouts.scm +86 -0
  514. data/share/guile/2.2/language/cps/prune-top-level-scopes.scm +63 -0
  515. data/share/guile/2.2/language/cps/reify-primitives.scm +179 -0
  516. data/share/guile/2.2/language/cps/renumber.scm +217 -0
  517. data/share/guile/2.2/language/cps/rotate-loops.scm +239 -0
  518. data/share/guile/2.2/language/cps/self-references.scm +79 -0
  519. data/share/guile/2.2/language/cps/simplify.scm +274 -0
  520. data/share/guile/2.2/language/cps/slot-allocation.scm +1058 -0
  521. data/share/guile/2.2/language/cps/spec.scm +51 -0
  522. data/share/guile/2.2/language/cps/specialize-numbers.scm +724 -0
  523. data/share/guile/2.2/language/cps/specialize-primcalls.scm +87 -0
  524. data/share/guile/2.2/language/cps/split-rec.scm +174 -0
  525. data/share/guile/2.2/language/cps/type-checks.scm +72 -0
  526. data/share/guile/2.2/language/cps/type-fold.scm +455 -0
  527. data/share/guile/2.2/language/cps/types.scm +1826 -0
  528. data/share/guile/2.2/language/cps/utils.scm +550 -0
  529. data/share/guile/2.2/language/cps/verify.scm +304 -0
  530. data/share/guile/2.2/language/cps/with-cps.scm +145 -0
  531. data/share/guile/2.2/language/cps.scm +358 -0
  532. data/share/guile/2.2/language/ecmascript/array.scm +121 -0
  533. data/share/guile/2.2/language/ecmascript/base.scm +251 -0
  534. data/share/guile/2.2/language/ecmascript/compile-tree-il.scm +576 -0
  535. data/share/guile/2.2/language/ecmascript/function.scm +78 -0
  536. data/share/guile/2.2/language/ecmascript/impl.scm +169 -0
  537. data/share/guile/2.2/language/ecmascript/parse.scm +352 -0
  538. data/share/guile/2.2/language/ecmascript/spec.scm +37 -0
  539. data/share/guile/2.2/language/ecmascript/tokenize.scm +513 -0
  540. data/share/guile/2.2/language/elisp/bindings.scm +107 -0
  541. data/share/guile/2.2/language/elisp/boot.el +617 -0
  542. data/share/guile/2.2/language/elisp/compile-tree-il.scm +812 -0
  543. data/share/guile/2.2/language/elisp/falias.scm +47 -0
  544. data/share/guile/2.2/language/elisp/lexer.scm +430 -0
  545. data/share/guile/2.2/language/elisp/parser.scm +222 -0
  546. data/share/guile/2.2/language/elisp/runtime/function-slot.scm +63 -0
  547. data/share/guile/2.2/language/elisp/runtime/value-slot.scm +24 -0
  548. data/share/guile/2.2/language/elisp/runtime.scm +153 -0
  549. data/share/guile/2.2/language/elisp/spec.scm +43 -0
  550. data/share/guile/2.2/language/scheme/compile-tree-il.scm +33 -0
  551. data/share/guile/2.2/language/scheme/decompile-tree-il.scm +796 -0
  552. data/share/guile/2.2/language/scheme/spec.scm +63 -0
  553. data/share/guile/2.2/language/tree-il/analyze.scm +1568 -0
  554. data/share/guile/2.2/language/tree-il/canonicalize.scm +82 -0
  555. data/share/guile/2.2/language/tree-il/compile-cps.scm +1149 -0
  556. data/share/guile/2.2/language/tree-il/debug.scm +246 -0
  557. data/share/guile/2.2/language/tree-il/effects.scm +591 -0
  558. data/share/guile/2.2/language/tree-il/fix-letrec.scm +314 -0
  559. data/share/guile/2.2/language/tree-il/optimize.scm +43 -0
  560. data/share/guile/2.2/language/tree-il/peval.scm +1669 -0
  561. data/share/guile/2.2/language/tree-il/primitives.scm +630 -0
  562. data/share/guile/2.2/language/tree-il/spec.scm +46 -0
  563. data/share/guile/2.2/language/tree-il.scm +630 -0
  564. data/share/guile/2.2/language/value/spec.scm +30 -0
  565. data/share/guile/2.2/oop/goops/accessors.scm +72 -0
  566. data/share/guile/2.2/oop/goops/active-slot.scm +63 -0
  567. data/share/guile/2.2/oop/goops/composite-slot.scm +83 -0
  568. data/share/guile/2.2/oop/goops/describe.scm +189 -0
  569. data/share/guile/2.2/oop/goops/internal.scm +30 -0
  570. data/share/guile/2.2/oop/goops/save.scm +874 -0
  571. data/share/guile/2.2/oop/goops/simple.scm +30 -0
  572. data/share/guile/2.2/oop/goops/stklos.scm +74 -0
  573. data/share/guile/2.2/oop/goops.scm +3176 -0
  574. data/share/guile/2.2/rnrs/arithmetic/bitwise.scm +92 -0
  575. data/share/guile/2.2/rnrs/arithmetic/fixnums.scm +291 -0
  576. data/share/guile/2.2/rnrs/arithmetic/flonums.scm +203 -0
  577. data/share/guile/2.2/rnrs/base.scm +291 -0
  578. data/share/guile/2.2/rnrs/bytevectors.scm +83 -0
  579. data/share/guile/2.2/rnrs/conditions.scm +225 -0
  580. data/share/guile/2.2/rnrs/control.scm +22 -0
  581. data/share/guile/2.2/rnrs/enums.scm +152 -0
  582. data/share/guile/2.2/rnrs/eval.scm +39 -0
  583. data/share/guile/2.2/rnrs/exceptions.scm +276 -0
  584. data/share/guile/2.2/rnrs/files.scm +96 -0
  585. data/share/guile/2.2/rnrs/hashtables.scm +190 -0
  586. data/share/guile/2.2/rnrs/io/ports.scm +554 -0
  587. data/share/guile/2.2/rnrs/io/simple.scm +167 -0
  588. data/share/guile/2.2/rnrs/lists.scm +55 -0
  589. data/share/guile/2.2/rnrs/mutable-pairs.scm +23 -0
  590. data/share/guile/2.2/rnrs/mutable-strings.scm +23 -0
  591. data/share/guile/2.2/rnrs/programs.scm +22 -0
  592. data/share/guile/2.2/rnrs/r5rs.scm +34 -0
  593. data/share/guile/2.2/rnrs/records/inspection.scm +81 -0
  594. data/share/guile/2.2/rnrs/records/procedural.scm +289 -0
  595. data/share/guile/2.2/rnrs/records/syntactic.scm +248 -0
  596. data/share/guile/2.2/rnrs/sorting.scm +27 -0
  597. data/share/guile/2.2/rnrs/syntax-case.scm +68 -0
  598. data/share/guile/2.2/rnrs/unicode.scm +104 -0
  599. data/share/guile/2.2/rnrs.scm +289 -0
  600. data/share/guile/2.2/scripts/api-diff.scm +179 -0
  601. data/share/guile/2.2/scripts/autofrisk.scm +218 -0
  602. data/share/guile/2.2/scripts/compile.scm +273 -0
  603. data/share/guile/2.2/scripts/disassemble.scm +38 -0
  604. data/share/guile/2.2/scripts/display-commentary.scm +67 -0
  605. data/share/guile/2.2/scripts/doc-snarf.scm +439 -0
  606. data/share/guile/2.2/scripts/frisk.scm +290 -0
  607. data/share/guile/2.2/scripts/generate-autoload.scm +144 -0
  608. data/share/guile/2.2/scripts/help.scm +188 -0
  609. data/share/guile/2.2/scripts/lint.scm +318 -0
  610. data/share/guile/2.2/scripts/list.scm +91 -0
  611. data/share/guile/2.2/scripts/punify.scm +87 -0
  612. data/share/guile/2.2/scripts/read-rfc822.scm +131 -0
  613. data/share/guile/2.2/scripts/read-scheme-source.scm +282 -0
  614. data/share/guile/2.2/scripts/read-text-outline.scm +253 -0
  615. data/share/guile/2.2/scripts/scan-api.scm +223 -0
  616. data/share/guile/2.2/scripts/snarf-check-and-output-texi.scm +303 -0
  617. data/share/guile/2.2/scripts/snarf-guile-m4-docs.scm +86 -0
  618. data/share/guile/2.2/scripts/summarize-guile-TODO.scm +213 -0
  619. data/share/guile/2.2/scripts/use2dot.scm +110 -0
  620. data/share/guile/2.2/srfi/srfi-1.scm +1061 -0
  621. data/share/guile/2.2/srfi/srfi-10.scm +89 -0
  622. data/share/guile/2.2/srfi/srfi-11.scm +146 -0
  623. data/share/guile/2.2/srfi/srfi-111.scm +37 -0
  624. data/share/guile/2.2/srfi/srfi-13.scm +132 -0
  625. data/share/guile/2.2/srfi/srfi-14.scm +99 -0
  626. data/share/guile/2.2/srfi/srfi-16.scm +51 -0
  627. data/share/guile/2.2/srfi/srfi-17.scm +174 -0
  628. data/share/guile/2.2/srfi/srfi-18.scm +382 -0
  629. data/share/guile/2.2/srfi/srfi-19.scm +1470 -0
  630. data/share/guile/2.2/srfi/srfi-2.scm +31 -0
  631. data/share/guile/2.2/srfi/srfi-26.scm +66 -0
  632. data/share/guile/2.2/srfi/srfi-27.scm +96 -0
  633. data/share/guile/2.2/srfi/srfi-28.scm +34 -0
  634. data/share/guile/2.2/srfi/srfi-31.scm +35 -0
  635. data/share/guile/2.2/srfi/srfi-34.scm +84 -0
  636. data/share/guile/2.2/srfi/srfi-35.scm +351 -0
  637. data/share/guile/2.2/srfi/srfi-37.scm +234 -0
  638. data/share/guile/2.2/srfi/srfi-38.scm +207 -0
  639. data/share/guile/2.2/srfi/srfi-39.scm +55 -0
  640. data/share/guile/2.2/srfi/srfi-4/gnu.scm +80 -0
  641. data/share/guile/2.2/srfi/srfi-4.scm +118 -0
  642. data/share/guile/2.2/srfi/srfi-41.scm +505 -0
  643. data/share/guile/2.2/srfi/srfi-42/ec.scm +1053 -0
  644. data/share/guile/2.2/srfi/srfi-42.scm +66 -0
  645. data/share/guile/2.2/srfi/srfi-43.scm +1077 -0
  646. data/share/guile/2.2/srfi/srfi-45.scm +93 -0
  647. data/share/guile/2.2/srfi/srfi-6.scm +29 -0
  648. data/share/guile/2.2/srfi/srfi-60.scm +73 -0
  649. data/share/guile/2.2/srfi/srfi-64/testing.scm +1040 -0
  650. data/share/guile/2.2/srfi/srfi-64.scm +55 -0
  651. data/share/guile/2.2/srfi/srfi-67/compare.scm +686 -0
  652. data/share/guile/2.2/srfi/srfi-67.scm +88 -0
  653. data/share/guile/2.2/srfi/srfi-69.scm +336 -0
  654. data/share/guile/2.2/srfi/srfi-71.scm +267 -0
  655. data/share/guile/2.2/srfi/srfi-8.scm +31 -0
  656. data/share/guile/2.2/srfi/srfi-88.scm +53 -0
  657. data/share/guile/2.2/srfi/srfi-9/gnu.scm +168 -0
  658. data/share/guile/2.2/srfi/srfi-9.scm +351 -0
  659. data/share/guile/2.2/srfi/srfi-98.scm +44 -0
  660. data/share/guile/2.2/statprof.scm +988 -0
  661. data/share/guile/2.2/sxml/apply-templates.scm +102 -0
  662. data/share/guile/2.2/sxml/fold.scm +250 -0
  663. data/share/guile/2.2/sxml/match.scm +75 -0
  664. data/share/guile/2.2/sxml/simple.scm +408 -0
  665. data/share/guile/2.2/sxml/ssax/input-parse.scm +180 -0
  666. data/share/guile/2.2/sxml/ssax.scm +265 -0
  667. data/share/guile/2.2/sxml/sxml-match.ss +1181 -0
  668. data/share/guile/2.2/sxml/transform.scm +298 -0
  669. data/share/guile/2.2/sxml/upstream/SSAX.scm +3235 -0
  670. data/share/guile/2.2/sxml/upstream/SXML-tree-trans.scm +249 -0
  671. data/share/guile/2.2/sxml/upstream/SXPath-old.scm +1216 -0
  672. data/share/guile/2.2/sxml/upstream/assert.scm +35 -0
  673. data/share/guile/2.2/sxml/upstream/input-parse.scm +326 -0
  674. data/share/guile/2.2/sxml/xpath.scm +493 -0
  675. data/share/guile/2.2/system/base/ck.scm +55 -0
  676. data/share/guile/2.2/system/base/compile.scm +282 -0
  677. data/share/guile/2.2/system/base/lalr.scm +51 -0
  678. data/share/guile/2.2/system/base/lalr.upstream.scm +2096 -0
  679. data/share/guile/2.2/system/base/language.scm +119 -0
  680. data/share/guile/2.2/system/base/message.scm +238 -0
  681. data/share/guile/2.2/system/base/pmatch.scm +68 -0
  682. data/share/guile/2.2/system/base/syntax.scm +299 -0
  683. data/share/guile/2.2/system/base/target.scm +152 -0
  684. data/share/guile/2.2/system/base/types.scm +561 -0
  685. data/share/guile/2.2/system/foreign-object.scm +91 -0
  686. data/share/guile/2.2/system/foreign.scm +200 -0
  687. data/share/guile/2.2/system/repl/command.scm +946 -0
  688. data/share/guile/2.2/system/repl/common.scm +263 -0
  689. data/share/guile/2.2/system/repl/coop-server.scm +200 -0
  690. data/share/guile/2.2/system/repl/debug.scm +210 -0
  691. data/share/guile/2.2/system/repl/describe.scm +347 -0
  692. data/share/guile/2.2/system/repl/error-handling.scm +183 -0
  693. data/share/guile/2.2/system/repl/repl.scm +233 -0
  694. data/share/guile/2.2/system/repl/server.scm +332 -0
  695. data/share/guile/2.2/system/syntax.scm +33 -0
  696. data/share/guile/2.2/system/vm/assembler.scm +2614 -0
  697. data/share/guile/2.2/system/vm/coverage.scm +351 -0
  698. data/share/guile/2.2/system/vm/debug.scm +766 -0
  699. data/share/guile/2.2/system/vm/disassembler.scm +658 -0
  700. data/share/guile/2.2/system/vm/dwarf.scm +1852 -0
  701. data/share/guile/2.2/system/vm/elf.scm +1042 -0
  702. data/share/guile/2.2/system/vm/frame.scm +485 -0
  703. data/share/guile/2.2/system/vm/inspect.scm +188 -0
  704. data/share/guile/2.2/system/vm/linker.scm +732 -0
  705. data/share/guile/2.2/system/vm/loader.scm +27 -0
  706. data/share/guile/2.2/system/vm/program.scm +312 -0
  707. data/share/guile/2.2/system/vm/trace.scm +121 -0
  708. data/share/guile/2.2/system/vm/trap-state.scm +302 -0
  709. data/share/guile/2.2/system/vm/traps.scm +608 -0
  710. data/share/guile/2.2/system/vm/vm.scm +32 -0
  711. data/share/guile/2.2/system/xref.scm +369 -0
  712. data/share/guile/2.2/texinfo/docbook.scm +240 -0
  713. data/share/guile/2.2/texinfo/html.scm +279 -0
  714. data/share/guile/2.2/texinfo/indexing.scm +75 -0
  715. data/share/guile/2.2/texinfo/plain-text.scm +322 -0
  716. data/share/guile/2.2/texinfo/reflection.scm +585 -0
  717. data/share/guile/2.2/texinfo/serialize.scm +300 -0
  718. data/share/guile/2.2/texinfo/string-utils.scm +410 -0
  719. data/share/guile/2.2/texinfo.scm +1263 -0
  720. data/share/guile/2.2/web/client.scm +513 -0
  721. data/share/guile/2.2/web/http.scm +2043 -0
  722. data/share/guile/2.2/web/request.scm +326 -0
  723. data/share/guile/2.2/web/response.scm +379 -0
  724. data/share/guile/2.2/web/server/http.scm +183 -0
  725. data/share/guile/2.2/web/server.scm +397 -0
  726. data/share/guile/2.2/web/uri.scm +552 -0
  727. data/share/lilypond/2.24.1/fontconfig/0bd3dc0958fa2205aaaa8ebb13e2872b-le64.cache-8 +0 -0
  728. data/share/lilypond/2.24.1/fontconfig/188ac73a183f12857f63bb60a4a6d603-le64.cache-8 +0 -0
  729. data/share/lilypond/2.24.1/fontconfig/32b6488e5b8292a2e95c79d947e009e8-le64.cache-8 +0 -0
  730. data/share/lilypond/2.24.1/fontconfig/3830d5c3ddfd5cd38a049b759396e72e-le64.cache-8 +0 -0
  731. data/share/lilypond/2.24.1/fontconfig/3f7329c5293ffd510edef78f73874cfd-le64.cache-8 +0 -0
  732. data/share/lilypond/2.24.1/fontconfig/4c599c202bc5c08e2d34565a40eac3b2-le64.cache-8 +0 -0
  733. data/share/lilypond/2.24.1/fontconfig/57e423e26b20ab21d0f2f29c145174c3-le64.cache-8 +0 -0
  734. data/share/lilypond/2.24.1/fontconfig/7ef2298fde41cc6eeb7af42e48b7d293-le64.cache-8 +0 -0
  735. data/share/lilypond/2.24.1/fontconfig/826f6b6ef79022e2eac8af26bf4b62f2-le64.cache-8 +0 -0
  736. data/share/lilypond/2.24.1/fontconfig/945677eb7aeaf62f1d50efc3fb3ec7d8-le64.cache-8 +0 -0
  737. data/share/lilypond/2.24.1/fontconfig/95530828ff6c81d309f8258d8d02a23e-le64.cache-8 +0 -0
  738. data/share/lilypond/2.24.1/fontconfig/CACHEDIR.TAG +4 -0
  739. data/share/lilypond/2.24.1/fontconfig/bf3b770c553c462765856025a94f1ce6-le64.cache-8 +0 -0
  740. data/share/lilypond/2.24.1/fontconfig/c855463f699352c367813e37f3f70ea7-le64.cache-8 +0 -0
  741. data/share/lilypond/2.24.1/fontconfig/d3e5c4ee2ceb1fc347f91d4cefc53bc0-le64.cache-8 +0 -0
  742. data/share/lilypond/2.24.1/fontconfig/d589a48862398ed80a3d6066f4f56f4c-le64.cache-8 +0 -0
  743. data/share/lilypond/2.24.1/fontconfig/d82eb4fd963d448e2fcb7d7b793b5df3-le64.cache-8 +0 -0
  744. data/share/lilypond/2.24.1/fontconfig/e13b20fdb08344e0e664864cc2ede53d-le64.cache-8 +0 -0
  745. data/share/lilypond/2.24.1/fontconfig/e52a45a1c8c8fe895fc0fc8c4e6999b8-le64.cache-8 +0 -0
  746. data/share/lilypond/2.24.1/fontconfig/f1f2465696798768e9653f19e17ccdc8-le64.cache-8 +0 -0
  747. data/share/lilypond/2.24.1/fonts/00-lilypond-fonts.conf +99 -0
  748. data/share/lilypond/2.24.1/fonts/99-lilypond-fonts.conf +28 -0
  749. data/share/lilypond/2.24.1/fonts/otf/C059-BdIta.otf +0 -0
  750. data/share/lilypond/2.24.1/fonts/otf/C059-Bold.otf +0 -0
  751. data/share/lilypond/2.24.1/fonts/otf/C059-Italic.otf +0 -0
  752. data/share/lilypond/2.24.1/fonts/otf/C059-Roman.otf +0 -0
  753. data/share/lilypond/2.24.1/fonts/otf/NimbusMonoPS-Bold.otf +0 -0
  754. data/share/lilypond/2.24.1/fonts/otf/NimbusMonoPS-BoldItalic.otf +0 -0
  755. data/share/lilypond/2.24.1/fonts/otf/NimbusMonoPS-Italic.otf +0 -0
  756. data/share/lilypond/2.24.1/fonts/otf/NimbusMonoPS-Regular.otf +0 -0
  757. data/share/lilypond/2.24.1/fonts/otf/NimbusSans-Bold.otf +0 -0
  758. data/share/lilypond/2.24.1/fonts/otf/NimbusSans-BoldItalic.otf +0 -0
  759. data/share/lilypond/2.24.1/fonts/otf/NimbusSans-Italic.otf +0 -0
  760. data/share/lilypond/2.24.1/fonts/otf/NimbusSans-Regular.otf +0 -0
  761. data/share/lilypond/2.24.1/fonts/otf/emmentaler-11.otf +0 -0
  762. data/share/lilypond/2.24.1/fonts/otf/emmentaler-13.otf +0 -0
  763. data/share/lilypond/2.24.1/fonts/otf/emmentaler-14.otf +0 -0
  764. data/share/lilypond/2.24.1/fonts/otf/emmentaler-16.otf +0 -0
  765. data/share/lilypond/2.24.1/fonts/otf/emmentaler-18.otf +0 -0
  766. data/share/lilypond/2.24.1/fonts/otf/emmentaler-20.otf +0 -0
  767. data/share/lilypond/2.24.1/fonts/otf/emmentaler-23.otf +0 -0
  768. data/share/lilypond/2.24.1/fonts/otf/emmentaler-26.otf +0 -0
  769. data/share/lilypond/2.24.1/fonts/otf/emmentaler-brace.otf +0 -0
  770. data/share/lilypond/2.24.1/fonts/otf/texgyrecursor-bold.otf +0 -0
  771. data/share/lilypond/2.24.1/fonts/otf/texgyrecursor-bolditalic.otf +0 -0
  772. data/share/lilypond/2.24.1/fonts/otf/texgyrecursor-italic.otf +0 -0
  773. data/share/lilypond/2.24.1/fonts/otf/texgyrecursor-regular.otf +0 -0
  774. data/share/lilypond/2.24.1/fonts/otf/texgyreheros-bold.otf +0 -0
  775. data/share/lilypond/2.24.1/fonts/otf/texgyreheros-bolditalic.otf +0 -0
  776. data/share/lilypond/2.24.1/fonts/otf/texgyreheros-italic.otf +0 -0
  777. data/share/lilypond/2.24.1/fonts/otf/texgyreheros-regular.otf +0 -0
  778. data/share/lilypond/2.24.1/fonts/otf/texgyreschola-bold.otf +0 -0
  779. data/share/lilypond/2.24.1/fonts/otf/texgyreschola-bolditalic.otf +0 -0
  780. data/share/lilypond/2.24.1/fonts/otf/texgyreschola-italic.otf +0 -0
  781. data/share/lilypond/2.24.1/fonts/otf/texgyreschola-regular.otf +0 -0
  782. data/share/lilypond/2.24.1/fonts/source/common-modules-and-initialization.mf +26 -0
  783. data/share/lilypond/2.24.1/fonts/source/debugging-settings.mf +14 -0
  784. data/share/lilypond/2.24.1/fonts/source/declare-autometric-parameters.mf +9 -0
  785. data/share/lilypond/2.24.1/fonts/source/feta-accidentals.mf +58 -0
  786. data/share/lilypond/2.24.1/fonts/source/feta-accordion.mf +575 -0
  787. data/share/lilypond/2.24.1/fonts/source/feta-alphabet-generic.mf +16 -0
  788. data/share/lilypond/2.24.1/fonts/source/feta-alphabet11.mf +6 -0
  789. data/share/lilypond/2.24.1/fonts/source/feta-alphabet13.mf +6 -0
  790. data/share/lilypond/2.24.1/fonts/source/feta-alphabet14.mf +6 -0
  791. data/share/lilypond/2.24.1/fonts/source/feta-alphabet16.mf +6 -0
  792. data/share/lilypond/2.24.1/fonts/source/feta-alphabet18.mf +6 -0
  793. data/share/lilypond/2.24.1/fonts/source/feta-alphabet20.mf +6 -0
  794. data/share/lilypond/2.24.1/fonts/source/feta-alphabet23.mf +6 -0
  795. data/share/lilypond/2.24.1/fonts/source/feta-alphabet26.mf +6 -0
  796. data/share/lilypond/2.24.1/fonts/source/feta-arrow.mf +114 -0
  797. data/share/lilypond/2.24.1/fonts/source/feta-arrowheads.mf +171 -0
  798. data/share/lilypond/2.24.1/fonts/source/feta-autometric.mf +303 -0
  799. data/share/lilypond/2.24.1/fonts/source/feta-braces-a.mf +6 -0
  800. data/share/lilypond/2.24.1/fonts/source/feta-braces-b.mf +6 -0
  801. data/share/lilypond/2.24.1/fonts/source/feta-braces-c.mf +6 -0
  802. data/share/lilypond/2.24.1/fonts/source/feta-braces-d.mf +6 -0
  803. data/share/lilypond/2.24.1/fonts/source/feta-braces-e.mf +6 -0
  804. data/share/lilypond/2.24.1/fonts/source/feta-braces-f.mf +6 -0
  805. data/share/lilypond/2.24.1/fonts/source/feta-braces-g.mf +6 -0
  806. data/share/lilypond/2.24.1/fonts/source/feta-braces-generic.mf +47 -0
  807. data/share/lilypond/2.24.1/fonts/source/feta-braces-h.mf +6 -0
  808. data/share/lilypond/2.24.1/fonts/source/feta-braces-i.mf +6 -0
  809. data/share/lilypond/2.24.1/fonts/source/feta-braces.mf +125 -0
  810. data/share/lilypond/2.24.1/fonts/source/feta-brackettips.mf +100 -0
  811. data/share/lilypond/2.24.1/fonts/source/feta-clefs.mf +963 -0
  812. data/share/lilypond/2.24.1/fonts/source/feta-dots.mf +37 -0
  813. data/share/lilypond/2.24.1/fonts/source/feta-dynamics.mf +891 -0
  814. data/share/lilypond/2.24.1/fonts/source/feta-flags-generic.mf +17 -0
  815. data/share/lilypond/2.24.1/fonts/source/feta-flags.mf +926 -0
  816. data/share/lilypond/2.24.1/fonts/source/feta-flags11.mf +6 -0
  817. data/share/lilypond/2.24.1/fonts/source/feta-flags13.mf +6 -0
  818. data/share/lilypond/2.24.1/fonts/source/feta-flags14.mf +6 -0
  819. data/share/lilypond/2.24.1/fonts/source/feta-flags16.mf +6 -0
  820. data/share/lilypond/2.24.1/fonts/source/feta-flags18.mf +6 -0
  821. data/share/lilypond/2.24.1/fonts/source/feta-flags20.mf +6 -0
  822. data/share/lilypond/2.24.1/fonts/source/feta-flags23.mf +6 -0
  823. data/share/lilypond/2.24.1/fonts/source/feta-flags26.mf +6 -0
  824. data/share/lilypond/2.24.1/fonts/source/feta-flats.mf +668 -0
  825. data/share/lilypond/2.24.1/fonts/source/feta-macros.mf +506 -0
  826. data/share/lilypond/2.24.1/fonts/source/feta-naturals.mf +223 -0
  827. data/share/lilypond/2.24.1/fonts/source/feta-noteheads-generic.mf +17 -0
  828. data/share/lilypond/2.24.1/fonts/source/feta-noteheads.mf +2642 -0
  829. data/share/lilypond/2.24.1/fonts/source/feta-noteheads11.mf +6 -0
  830. data/share/lilypond/2.24.1/fonts/source/feta-noteheads13.mf +6 -0
  831. data/share/lilypond/2.24.1/fonts/source/feta-noteheads14.mf +6 -0
  832. data/share/lilypond/2.24.1/fonts/source/feta-noteheads16.mf +6 -0
  833. data/share/lilypond/2.24.1/fonts/source/feta-noteheads18.mf +6 -0
  834. data/share/lilypond/2.24.1/fonts/source/feta-noteheads20.mf +6 -0
  835. data/share/lilypond/2.24.1/fonts/source/feta-noteheads23.mf +6 -0
  836. data/share/lilypond/2.24.1/fonts/source/feta-noteheads26.mf +6 -0
  837. data/share/lilypond/2.24.1/fonts/source/feta-numbers.mf +1677 -0
  838. data/share/lilypond/2.24.1/fonts/source/feta-other-generic.mf +27 -0
  839. data/share/lilypond/2.24.1/fonts/source/feta-params.mf +323 -0
  840. data/share/lilypond/2.24.1/fonts/source/feta-parenthesis.mf +63 -0
  841. data/share/lilypond/2.24.1/fonts/source/feta-pedals.mf +355 -0
  842. data/share/lilypond/2.24.1/fonts/source/feta-rests.mf +890 -0
  843. data/share/lilypond/2.24.1/fonts/source/feta-scripts.mf +2206 -0
  844. data/share/lilypond/2.24.1/fonts/source/feta-sharps.mf +524 -0
  845. data/share/lilypond/2.24.1/fonts/source/feta-sori-koron.mf +325 -0
  846. data/share/lilypond/2.24.1/fonts/source/feta-ties.mf +72 -0
  847. data/share/lilypond/2.24.1/fonts/source/feta-timesignatures.mf +119 -0
  848. data/share/lilypond/2.24.1/fonts/source/feta-trills.mf +321 -0
  849. data/share/lilypond/2.24.1/fonts/source/feta11.mf +6 -0
  850. data/share/lilypond/2.24.1/fonts/source/feta13.mf +6 -0
  851. data/share/lilypond/2.24.1/fonts/source/feta14.mf +6 -0
  852. data/share/lilypond/2.24.1/fonts/source/feta16.mf +6 -0
  853. data/share/lilypond/2.24.1/fonts/source/feta18.mf +6 -0
  854. data/share/lilypond/2.24.1/fonts/source/feta20.mf +7 -0
  855. data/share/lilypond/2.24.1/fonts/source/feta23.mf +6 -0
  856. data/share/lilypond/2.24.1/fonts/source/feta26.mf +6 -0
  857. data/share/lilypond/2.24.1/fonts/source/parmesan-accidentals.mf +483 -0
  858. data/share/lilypond/2.24.1/fonts/source/parmesan-clefs.mf +1636 -0
  859. data/share/lilypond/2.24.1/fonts/source/parmesan-custodes.mf +503 -0
  860. data/share/lilypond/2.24.1/fonts/source/parmesan-dots.mf +62 -0
  861. data/share/lilypond/2.24.1/fonts/source/parmesan-flags.mf +319 -0
  862. data/share/lilypond/2.24.1/fonts/source/parmesan-macros.mf +225 -0
  863. data/share/lilypond/2.24.1/fonts/source/parmesan-noteheads-generic.mf +16 -0
  864. data/share/lilypond/2.24.1/fonts/source/parmesan-noteheads.mf +2191 -0
  865. data/share/lilypond/2.24.1/fonts/source/parmesan-noteheads11.mf +6 -0
  866. data/share/lilypond/2.24.1/fonts/source/parmesan-noteheads13.mf +6 -0
  867. data/share/lilypond/2.24.1/fonts/source/parmesan-noteheads14.mf +6 -0
  868. data/share/lilypond/2.24.1/fonts/source/parmesan-noteheads16.mf +6 -0
  869. data/share/lilypond/2.24.1/fonts/source/parmesan-noteheads18.mf +6 -0
  870. data/share/lilypond/2.24.1/fonts/source/parmesan-noteheads20.mf +6 -0
  871. data/share/lilypond/2.24.1/fonts/source/parmesan-noteheads23.mf +6 -0
  872. data/share/lilypond/2.24.1/fonts/source/parmesan-noteheads26.mf +6 -0
  873. data/share/lilypond/2.24.1/fonts/source/parmesan-other-generic.mf +24 -0
  874. data/share/lilypond/2.24.1/fonts/source/parmesan-rests.mf +428 -0
  875. data/share/lilypond/2.24.1/fonts/source/parmesan-scripts.mf +284 -0
  876. data/share/lilypond/2.24.1/fonts/source/parmesan-timesignatures.mf +402 -0
  877. data/share/lilypond/2.24.1/fonts/source/parmesan11.mf +6 -0
  878. data/share/lilypond/2.24.1/fonts/source/parmesan13.mf +6 -0
  879. data/share/lilypond/2.24.1/fonts/source/parmesan14.mf +6 -0
  880. data/share/lilypond/2.24.1/fonts/source/parmesan16.mf +6 -0
  881. data/share/lilypond/2.24.1/fonts/source/parmesan18.mf +6 -0
  882. data/share/lilypond/2.24.1/fonts/source/parmesan20.mf +6 -0
  883. data/share/lilypond/2.24.1/fonts/source/parmesan23.mf +6 -0
  884. data/share/lilypond/2.24.1/fonts/source/parmesan26.mf +6 -0
  885. data/share/lilypond/2.24.1/fonts/svg/emmentaler-11.svg +2525 -0
  886. data/share/lilypond/2.24.1/fonts/svg/emmentaler-11.woff +0 -0
  887. data/share/lilypond/2.24.1/fonts/svg/emmentaler-13.svg +2530 -0
  888. data/share/lilypond/2.24.1/fonts/svg/emmentaler-13.woff +0 -0
  889. data/share/lilypond/2.24.1/fonts/svg/emmentaler-14.svg +2526 -0
  890. data/share/lilypond/2.24.1/fonts/svg/emmentaler-14.woff +0 -0
  891. data/share/lilypond/2.24.1/fonts/svg/emmentaler-16.svg +2523 -0
  892. data/share/lilypond/2.24.1/fonts/svg/emmentaler-16.woff +0 -0
  893. data/share/lilypond/2.24.1/fonts/svg/emmentaler-18.svg +2519 -0
  894. data/share/lilypond/2.24.1/fonts/svg/emmentaler-18.woff +0 -0
  895. data/share/lilypond/2.24.1/fonts/svg/emmentaler-20.svg +2512 -0
  896. data/share/lilypond/2.24.1/fonts/svg/emmentaler-20.woff +0 -0
  897. data/share/lilypond/2.24.1/fonts/svg/emmentaler-23.svg +2506 -0
  898. data/share/lilypond/2.24.1/fonts/svg/emmentaler-23.woff +0 -0
  899. data/share/lilypond/2.24.1/fonts/svg/emmentaler-26.svg +2510 -0
  900. data/share/lilypond/2.24.1/fonts/svg/emmentaler-26.woff +0 -0
  901. data/share/lilypond/2.24.1/fonts/svg/emmentaler-brace.svg +1757 -0
  902. data/share/lilypond/2.24.1/fonts/svg/emmentaler-brace.woff +0 -0
  903. data/share/lilypond/2.24.1/ly/Welcome_to_LilyPond.ly +45 -0
  904. data/share/lilypond/2.24.1/ly/arabic.ly +185 -0
  905. data/share/lilypond/2.24.1/ly/articulate.ly +1013 -0
  906. data/share/lilypond/2.24.1/ly/bagpipe.ly +368 -0
  907. data/share/lilypond/2.24.1/ly/base-tkit.ly +135 -0
  908. data/share/lilypond/2.24.1/ly/catalan.ly +23 -0
  909. data/share/lilypond/2.24.1/ly/chord-modifiers-init.ly +63 -0
  910. data/share/lilypond/2.24.1/ly/chord-repetition-init.ly +60 -0
  911. data/share/lilypond/2.24.1/ly/context-mods-init.ly +119 -0
  912. data/share/lilypond/2.24.1/ly/declarations-init.ly +167 -0
  913. data/share/lilypond/2.24.1/ly/deutsch.ly +23 -0
  914. data/share/lilypond/2.24.1/ly/drumpitch-init.ly +366 -0
  915. data/share/lilypond/2.24.1/ly/dynamic-scripts-init.ly +54 -0
  916. data/share/lilypond/2.24.1/ly/english.ly +23 -0
  917. data/share/lilypond/2.24.1/ly/engraver-init.ly +1619 -0
  918. data/share/lilypond/2.24.1/ly/espanol.ly +23 -0
  919. data/share/lilypond/2.24.1/ly/event-listener.ly +241 -0
  920. data/share/lilypond/2.24.1/ly/festival.ly +38 -0
  921. data/share/lilypond/2.24.1/ly/generate-documentation.ly +7 -0
  922. data/share/lilypond/2.24.1/ly/grace-init.ly +56 -0
  923. data/share/lilypond/2.24.1/ly/graphviz-init.ly +174 -0
  924. data/share/lilypond/2.24.1/ly/gregorian.ly +268 -0
  925. data/share/lilypond/2.24.1/ly/guile-debugger.ly +55 -0
  926. data/share/lilypond/2.24.1/ly/hel-arabic.ly +307 -0
  927. data/share/lilypond/2.24.1/ly/init.ly +96 -0
  928. data/share/lilypond/2.24.1/ly/italiano.ly +23 -0
  929. data/share/lilypond/2.24.1/ly/lilypond-book-preamble.ly +47 -0
  930. data/share/lilypond/2.24.1/ly/lyrics-tkit.ly +68 -0
  931. data/share/lilypond/2.24.1/ly/makam.ly +166 -0
  932. data/share/lilypond/2.24.1/ly/midi-init.ly +59 -0
  933. data/share/lilypond/2.24.1/ly/music-functions-init.ly +2254 -0
  934. data/share/lilypond/2.24.1/ly/nederlands.ly +23 -0
  935. data/share/lilypond/2.24.1/ly/norsk.ly +23 -0
  936. data/share/lilypond/2.24.1/ly/paper-defaults-init.ly +188 -0
  937. data/share/lilypond/2.24.1/ly/performer-init.ly +398 -0
  938. data/share/lilypond/2.24.1/ly/persian.ly +335 -0
  939. data/share/lilypond/2.24.1/ly/piano-tkit.ly +61 -0
  940. data/share/lilypond/2.24.1/ly/portugues.ly +23 -0
  941. data/share/lilypond/2.24.1/ly/predefined-fretboards-init.ly +78 -0
  942. data/share/lilypond/2.24.1/ly/predefined-guitar-fretboards.ly +506 -0
  943. data/share/lilypond/2.24.1/ly/predefined-guitar-ninth-fretboards.ly +75 -0
  944. data/share/lilypond/2.24.1/ly/predefined-mandolin-fretboards.ly +876 -0
  945. data/share/lilypond/2.24.1/ly/predefined-ukulele-fretboards.ly +1285 -0
  946. data/share/lilypond/2.24.1/ly/property-init.ly +858 -0
  947. data/share/lilypond/2.24.1/ly/satb.ly +214 -0
  948. data/share/lilypond/2.24.1/ly/scale-definitions-init.ly +117 -0
  949. data/share/lilypond/2.24.1/ly/scheme-sandbox.ly +39 -0
  950. data/share/lilypond/2.24.1/ly/script-init.ly +94 -0
  951. data/share/lilypond/2.24.1/ly/spanners-init.ly +146 -0
  952. data/share/lilypond/2.24.1/ly/ssaattbb.ly +335 -0
  953. data/share/lilypond/2.24.1/ly/staff-tkit.ly +182 -0
  954. data/share/lilypond/2.24.1/ly/string-tunings-init.ly +94 -0
  955. data/share/lilypond/2.24.1/ly/suomi.ly +23 -0
  956. data/share/lilypond/2.24.1/ly/svenska.ly +23 -0
  957. data/share/lilypond/2.24.1/ly/swing.ly +362 -0
  958. data/share/lilypond/2.24.1/ly/text-replacements.ly +150 -0
  959. data/share/lilypond/2.24.1/ly/titling-init.ly +150 -0
  960. data/share/lilypond/2.24.1/ly/toc-init.ly +182 -0
  961. data/share/lilypond/2.24.1/ly/turkish-makam.ly +609 -0
  962. data/share/lilypond/2.24.1/ly/vlaams.ly +23 -0
  963. data/share/lilypond/2.24.1/ly/vocal-tkit.ly +103 -0
  964. data/share/lilypond/2.24.1/ly/voice-tkit.ly +34 -0
  965. data/share/lilypond/2.24.1/ps/encodingdefs.ps +2611 -0
  966. data/share/lilypond/2.24.1/ps/lilyponddefs.ps +49 -0
  967. data/share/lilypond/2.24.1/ps/music-drawing-routines.ps +329 -0
  968. data/share/lilypond/2.24.1/python/__pycache__/book_base.cpython-310.pyc +0 -0
  969. data/share/lilypond/2.24.1/python/__pycache__/book_docbook.cpython-310.pyc +0 -0
  970. data/share/lilypond/2.24.1/python/__pycache__/book_html.cpython-310.pyc +0 -0
  971. data/share/lilypond/2.24.1/python/__pycache__/book_latex.cpython-310.pyc +0 -0
  972. data/share/lilypond/2.24.1/python/__pycache__/book_snippets.cpython-310.pyc +0 -0
  973. data/share/lilypond/2.24.1/python/__pycache__/book_texinfo.cpython-310.pyc +0 -0
  974. data/share/lilypond/2.24.1/python/__pycache__/convertrules.cpython-310.pyc +0 -0
  975. data/share/lilypond/2.24.1/python/__pycache__/langdefs.cpython-310.pyc +0 -0
  976. data/share/lilypond/2.24.1/python/__pycache__/lilylib.cpython-310.pyc +0 -0
  977. data/share/lilypond/2.24.1/python/__pycache__/midi.cpython-310.pyc +0 -0
  978. data/share/lilypond/2.24.1/python/__pycache__/musicexp.cpython-310.pyc +0 -0
  979. data/share/lilypond/2.24.1/python/__pycache__/musicxml.cpython-310.pyc +0 -0
  980. data/share/lilypond/2.24.1/python/__pycache__/musicxml2ly_conversion.cpython-310.pyc +0 -0
  981. data/share/lilypond/2.24.1/python/__pycache__/utilities.cpython-310.pyc +0 -0
  982. data/share/lilypond/2.24.1/python/book_base.py +331 -0
  983. data/share/lilypond/2.24.1/python/book_docbook.py +154 -0
  984. data/share/lilypond/2.24.1/python/book_html.py +178 -0
  985. data/share/lilypond/2.24.1/python/book_latex.py +373 -0
  986. data/share/lilypond/2.24.1/python/book_snippets.py +1052 -0
  987. data/share/lilypond/2.24.1/python/book_texinfo.py +437 -0
  988. data/share/lilypond/2.24.1/python/convertrules.py +4764 -0
  989. data/share/lilypond/2.24.1/python/langdefs.py +131 -0
  990. data/share/lilypond/2.24.1/python/lilylib.py +141 -0
  991. data/share/lilypond/2.24.1/python/midi.py +212 -0
  992. data/share/lilypond/2.24.1/python/musicexp.py +2781 -0
  993. data/share/lilypond/2.24.1/python/musicxml.py +1905 -0
  994. data/share/lilypond/2.24.1/python/musicxml2ly_conversion.py +80 -0
  995. data/share/lilypond/2.24.1/python/utilities.py +280 -0
  996. data/share/lilypond/2.24.1/scm/lily/accreg.scm +579 -0
  997. data/share/lilypond/2.24.1/scm/lily/auto-beam.scm +163 -0
  998. data/share/lilypond/2.24.1/scm/lily/autochange.scm +100 -0
  999. data/share/lilypond/2.24.1/scm/lily/backend-library.scm +593 -0
  1000. data/share/lilypond/2.24.1/scm/lily/bar-line.scm +1281 -0
  1001. data/share/lilypond/2.24.1/scm/lily/breath.scm +74 -0
  1002. data/share/lilypond/2.24.1/scm/lily/c++.scm +174 -0
  1003. data/share/lilypond/2.24.1/scm/lily/chord-entry.scm +278 -0
  1004. data/share/lilypond/2.24.1/scm/lily/chord-ignatzek-names.scm +304 -0
  1005. data/share/lilypond/2.24.1/scm/lily/chord-name.scm +217 -0
  1006. data/share/lilypond/2.24.1/scm/lily/clip-region.scm +87 -0
  1007. data/share/lilypond/2.24.1/scm/lily/color.scm +757 -0
  1008. data/share/lilypond/2.24.1/scm/lily/curried-definitions.scm +68 -0
  1009. data/share/lilypond/2.24.1/scm/lily/define-context-properties.scm +939 -0
  1010. data/share/lilypond/2.24.1/scm/lily/define-event-classes.scm +142 -0
  1011. data/share/lilypond/2.24.1/scm/lily/define-grob-interfaces.scm +640 -0
  1012. data/share/lilypond/2.24.1/scm/lily/define-grob-properties.scm +1647 -0
  1013. data/share/lilypond/2.24.1/scm/lily/define-grobs.scm +4027 -0
  1014. data/share/lilypond/2.24.1/scm/lily/define-markup-commands.scm +5737 -0
  1015. data/share/lilypond/2.24.1/scm/lily/define-music-callbacks.scm +257 -0
  1016. data/share/lilypond/2.24.1/scm/lily/define-music-display-methods.scm +1350 -0
  1017. data/share/lilypond/2.24.1/scm/lily/define-music-properties.scm +242 -0
  1018. data/share/lilypond/2.24.1/scm/lily/define-music-types.scm +983 -0
  1019. data/share/lilypond/2.24.1/scm/lily/define-note-names.scm +1421 -0
  1020. data/share/lilypond/2.24.1/scm/lily/define-stencil-commands.scm +71 -0
  1021. data/share/lilypond/2.24.1/scm/lily/define-woodwind-diagrams.scm +1215 -0
  1022. data/share/lilypond/2.24.1/scm/lily/display-lily.scm +315 -0
  1023. data/share/lilypond/2.24.1/scm/lily/display-woodwind-diagrams.scm +1985 -0
  1024. data/share/lilypond/2.24.1/scm/lily/document-backend.scm +307 -0
  1025. data/share/lilypond/2.24.1/scm/lily/document-context-mods.scm +98 -0
  1026. data/share/lilypond/2.24.1/scm/lily/document-functions.scm +169 -0
  1027. data/share/lilypond/2.24.1/scm/lily/document-identifiers.scm +76 -0
  1028. data/share/lilypond/2.24.1/scm/lily/document-markup.scm +158 -0
  1029. data/share/lilypond/2.24.1/scm/lily/document-music.scm +146 -0
  1030. data/share/lilypond/2.24.1/scm/lily/document-outside-staff-priorities.scm +40 -0
  1031. data/share/lilypond/2.24.1/scm/lily/document-paper-sizes.scm +71 -0
  1032. data/share/lilypond/2.24.1/scm/lily/document-translation.scm +318 -0
  1033. data/share/lilypond/2.24.1/scm/lily/document-type-predicates.scm +85 -0
  1034. data/share/lilypond/2.24.1/scm/lily/documentation-generate.scm +259 -0
  1035. data/share/lilypond/2.24.1/scm/lily/documentation-lib.scm +207 -0
  1036. data/share/lilypond/2.24.1/scm/lily/file-cache.scm +28 -0
  1037. data/share/lilypond/2.24.1/scm/lily/flag-styles.scm +249 -0
  1038. data/share/lilypond/2.24.1/scm/lily/font-encodings.scm +1242 -0
  1039. data/share/lilypond/2.24.1/scm/lily/font.scm +303 -0
  1040. data/share/lilypond/2.24.1/scm/lily/framework-cairo.scm +26 -0
  1041. data/share/lilypond/2.24.1/scm/lily/framework-ps.scm +896 -0
  1042. data/share/lilypond/2.24.1/scm/lily/framework-svg.scm +172 -0
  1043. data/share/lilypond/2.24.1/scm/lily/fret-diagrams.scm +1261 -0
  1044. data/share/lilypond/2.24.1/scm/lily/graphviz.scm +78 -0
  1045. data/share/lilypond/2.24.1/scm/lily/guile-debugger.scm +90 -0
  1046. data/share/lilypond/2.24.1/scm/lily/harp-pedals.scm +172 -0
  1047. data/share/lilypond/2.24.1/scm/lily/hyphenate-internal-words.scm +51 -0
  1048. data/share/lilypond/2.24.1/scm/lily/layout-beam.scm +73 -0
  1049. data/share/lilypond/2.24.1/scm/lily/layout-slur.scm +45 -0
  1050. data/share/lilypond/2.24.1/scm/lily/lily-library.scm +1446 -0
  1051. data/share/lilypond/2.24.1/scm/lily/lily-sort.scm +116 -0
  1052. data/share/lilypond/2.24.1/scm/lily/lily.scm +929 -0
  1053. data/share/lilypond/2.24.1/scm/lily/ly-syntax-constructors.scm +374 -0
  1054. data/share/lilypond/2.24.1/scm/lily/markup-macros.scm +493 -0
  1055. data/share/lilypond/2.24.1/scm/lily/markup.scm +126 -0
  1056. data/share/lilypond/2.24.1/scm/lily/midi.scm +258 -0
  1057. data/share/lilypond/2.24.1/scm/lily/modal-transforms.scm +337 -0
  1058. data/share/lilypond/2.24.1/scm/lily/music-functions.scm +2878 -0
  1059. data/share/lilypond/2.24.1/scm/lily/output-lib.scm +3377 -0
  1060. data/share/lilypond/2.24.1/scm/lily/output-ps.scm +335 -0
  1061. data/share/lilypond/2.24.1/scm/lily/output-svg.scm +684 -0
  1062. data/share/lilypond/2.24.1/scm/lily/page.scm +321 -0
  1063. data/share/lilypond/2.24.1/scm/lily/paper-system.scm +271 -0
  1064. data/share/lilypond/2.24.1/scm/lily/paper.scm +376 -0
  1065. data/share/lilypond/2.24.1/scm/lily/parser-clef.scm +205 -0
  1066. data/share/lilypond/2.24.1/scm/lily/parser-ly-from-scheme.scm +170 -0
  1067. data/share/lilypond/2.24.1/scm/lily/part-combiner.scm +998 -0
  1068. data/share/lilypond/2.24.1/scm/lily/predefined-fretboards.scm +54 -0
  1069. data/share/lilypond/2.24.1/scm/lily/ps-to-png.scm +182 -0
  1070. data/share/lilypond/2.24.1/scm/lily/scheme-engravers.scm +1813 -0
  1071. data/share/lilypond/2.24.1/scm/lily/scheme-performers.scm +126 -0
  1072. data/share/lilypond/2.24.1/scm/lily/script.scm +416 -0
  1073. data/share/lilypond/2.24.1/scm/lily/skyline.scm +25 -0
  1074. data/share/lilypond/2.24.1/scm/lily/song-util.scm +191 -0
  1075. data/share/lilypond/2.24.1/scm/lily/song.scm +853 -0
  1076. data/share/lilypond/2.24.1/scm/lily/stencil.scm +998 -0
  1077. data/share/lilypond/2.24.1/scm/lily/tablature.scm +392 -0
  1078. data/share/lilypond/2.24.1/scm/lily/time-signature-settings.scm +473 -0
  1079. data/share/lilypond/2.24.1/scm/lily/time-signature.scm +35 -0
  1080. data/share/lilypond/2.24.1/scm/lily/titling.scm +99 -0
  1081. data/share/lilypond/2.24.1/scm/lily/to-xml.scm +254 -0
  1082. data/share/lilypond/2.24.1/scm/lily/translation-functions.scm +1169 -0
  1083. data/share/lilypond/2.24.1/vim/compiler/lilypond.vim +36 -0
  1084. data/share/lilypond/2.24.1/vim/ftdetect/lilypond.vim +4 -0
  1085. data/share/lilypond/2.24.1/vim/ftplugin/lilypond.vim +91 -0
  1086. data/share/lilypond/2.24.1/vim/indent/lilypond.vim +79 -0
  1087. data/share/lilypond/2.24.1/vim/syntax/lilypond-words +1408 -0
  1088. data/share/lilypond/2.24.1/vim/syntax/lilypond-words.vim +3 -0
  1089. data/share/lilypond/2.24.1/vim/syntax/lilypond.vim +104 -0
  1090. data/share/locale/ca/LC_MESSAGES/lilypond.mo +0 -0
  1091. data/share/locale/cs/LC_MESSAGES/lilypond.mo +0 -0
  1092. data/share/locale/da/LC_MESSAGES/lilypond.mo +0 -0
  1093. data/share/locale/de/LC_MESSAGES/lilypond.mo +0 -0
  1094. data/share/locale/el/LC_MESSAGES/lilypond.mo +0 -0
  1095. data/share/locale/eo/LC_MESSAGES/lilypond.mo +0 -0
  1096. data/share/locale/es/LC_MESSAGES/lilypond.mo +0 -0
  1097. data/share/locale/fi/LC_MESSAGES/lilypond.mo +0 -0
  1098. data/share/locale/fr/LC_MESSAGES/lilypond.mo +0 -0
  1099. data/share/locale/it/LC_MESSAGES/lilypond.mo +0 -0
  1100. data/share/locale/ja/LC_MESSAGES/lilypond.mo +0 -0
  1101. data/share/locale/nl/LC_MESSAGES/lilypond.mo +0 -0
  1102. data/share/locale/ru/LC_MESSAGES/lilypond.mo +0 -0
  1103. data/share/locale/sv/LC_MESSAGES/lilypond.mo +0 -0
  1104. data/share/locale/tr/LC_MESSAGES/lilypond.mo +0 -0
  1105. data/share/locale/uk/LC_MESSAGES/lilypond.mo +0 -0
  1106. data/share/locale/vi/LC_MESSAGES/lilypond.mo +0 -0
  1107. data/share/locale/zh_CN/LC_MESSAGES/lilypond.mo +0 -0
  1108. data/share/locale/zh_TW/LC_MESSAGES/lilypond.mo +0 -0
  1109. metadata +1108 -1
@@ -0,0 +1,4131 @@
1
+ ;;; -*- mode: scheme; coding: utf-8; -*-
2
+
3
+ ;;;; Copyright (C) 1995-2014, 2016-2018 Free Software Foundation, Inc.
4
+ ;;;;
5
+ ;;;; This library is free software; you can redistribute it and/or
6
+ ;;;; modify it under the terms of the GNU Lesser General Public
7
+ ;;;; License as published by the Free Software Foundation; either
8
+ ;;;; version 3 of the License, or (at your option) any later version.
9
+ ;;;;
10
+ ;;;; This library is distributed in the hope that it will be useful,
11
+ ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ ;;;; Lesser General Public License for more details.
14
+ ;;;;
15
+ ;;;; You should have received a copy of the GNU Lesser General Public
16
+ ;;;; License along with this library; if not, write to the Free Software
17
+ ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ ;;;;
19
+
20
+
21
+
22
+ ;;; Commentary:
23
+
24
+ ;;; This file is the first thing loaded into Guile. It adds many mundane
25
+ ;;; definitions and a few that are interesting.
26
+ ;;;
27
+ ;;; The module system (hence the hierarchical namespace) are defined in this
28
+ ;;; file.
29
+ ;;;
30
+
31
+ ;;; Code:
32
+
33
+
34
+
35
+ ;; Before compiling, make sure any symbols are resolved in the (guile)
36
+ ;; module, the primary location of those symbols, rather than in
37
+ ;; (guile-user), the default module that we compile in.
38
+
39
+ (eval-when (compile)
40
+ (set-current-module (resolve-module '(guile))))
41
+
42
+ ;; Prevent this file being loaded more than once in a session. Just
43
+ ;; doesn't make sense!
44
+ (if (current-module)
45
+ (error "re-loading ice-9/boot-9.scm not allowed"))
46
+
47
+
48
+
49
+ ;;; {Language primitives}
50
+ ;;;
51
+
52
+ ;; These are are the procedural wrappers around the primitives of
53
+ ;; Guile's language: apply, call-with-current-continuation, etc.
54
+ ;;
55
+ ;; Usually, a call to a primitive is compiled specially. The compiler
56
+ ;; knows about all these kinds of expressions. But the primitives may
57
+ ;; be referenced not only as operators, but as values as well. These
58
+ ;; stub procedures are the "values" of apply, dynamic-wind, and other
59
+ ;; such primitives.
60
+ ;;
61
+ (define apply
62
+ (case-lambda
63
+ ((fun args)
64
+ ((@@ primitive apply) fun args))
65
+ ((fun arg1 . args)
66
+ (letrec ((append* (lambda (tail)
67
+ (let ((tail (car tail))
68
+ (tail* (cdr tail)))
69
+ (if (null? tail*)
70
+ tail
71
+ (cons tail (append* tail*)))))))
72
+ (apply fun (cons arg1 (append* args)))))))
73
+ (define (call-with-current-continuation proc)
74
+ ((@@ primitive call-with-current-continuation) proc))
75
+ (define (call-with-values producer consumer)
76
+ ((@@ primitive call-with-values) producer consumer))
77
+ (define (dynamic-wind in thunk out)
78
+ "All three arguments must be 0-argument procedures.
79
+ Guard @var{in} is called, then @var{thunk}, then
80
+ guard @var{out}.
81
+
82
+ If, any time during the execution of @var{thunk}, the
83
+ continuation of the @code{dynamic_wind} expression is escaped
84
+ non-locally, @var{out} is called. If the continuation of
85
+ the dynamic-wind is re-entered, @var{in} is called. Thus
86
+ @var{in} and @var{out} may be called any number of
87
+ times.
88
+ @lisp
89
+ (define x 'normal-binding)
90
+ @result{} x
91
+ (define a-cont
92
+ (call-with-current-continuation
93
+ (lambda (escape)
94
+ (let ((old-x x))
95
+ (dynamic-wind
96
+ ;; in-guard:
97
+ ;;
98
+ (lambda () (set! x 'special-binding))
99
+
100
+ ;; thunk
101
+ ;;
102
+ (lambda () (display x) (newline)
103
+ (call-with-current-continuation escape)
104
+ (display x) (newline)
105
+ x)
106
+
107
+ ;; out-guard:
108
+ ;;
109
+ (lambda () (set! x old-x)))))))
110
+
111
+ ;; Prints:
112
+ special-binding
113
+ ;; Evaluates to:
114
+ @result{} a-cont
115
+ x
116
+ @result{} normal-binding
117
+ (a-cont #f)
118
+ ;; Prints:
119
+ special-binding
120
+ ;; Evaluates to:
121
+ @result{} a-cont ;; the value of the (define a-cont...)
122
+ x
123
+ @result{} normal-binding
124
+ a-cont
125
+ @result{} special-binding
126
+ @end lisp"
127
+ ;; FIXME: Here we don't check that the out procedure is a thunk before
128
+ ;; calling the in-guard, as dynamic-wind is called as part of loading
129
+ ;; modules, but thunk? requires loading (system vm debug). This is in
130
+ ;; contrast to the open-coded version of dynamic-wind, which does
131
+ ;; currently insert an eager thunk? check (but often optimizes it
132
+ ;; out). Not sure what the right thing to do is here -- make thunk?
133
+ ;; callable before modules are loaded, live with this inconsistency,
134
+ ;; or remove the thunk? check from the compiler? Questions,
135
+ ;; questions.
136
+ #;
137
+ (unless (thunk? out)
138
+ (scm-error 'wrong-type-arg "dynamic-wind" "Not a thunk: ~S"
139
+ (list out) #f))
140
+ (in)
141
+ ((@@ primitive wind) in out)
142
+ (call-with-values thunk
143
+ (lambda vals
144
+ ((@@ primitive unwind))
145
+ (out)
146
+ (apply values vals))))
147
+
148
+ (define (with-fluid* fluid val thunk)
149
+ "Set @var{fluid} to @var{value} temporarily, and call @var{thunk}.
150
+ @var{thunk} must be a procedure of no arguments."
151
+ ((@@ primitive push-fluid) fluid val)
152
+ (call-with-values thunk
153
+ (lambda vals
154
+ ((@@ primitive pop-fluid))
155
+ (apply values vals))))
156
+
157
+ (define (with-dynamic-state state thunk)
158
+ "Call @var{proc} while @var{state} is the current dynamic state object.
159
+ @var{thunk} must be a procedure of no arguments."
160
+ ((@@ primitive push-dynamic-state) state)
161
+ (call-with-values thunk
162
+ (lambda vals
163
+ ((@@ primitive pop-dynamic-state))
164
+ (apply values vals))))
165
+
166
+
167
+
168
+ ;;; {Simple Debugging Tools}
169
+ ;;;
170
+
171
+ (define (peek . stuff)
172
+ "Write arguments to the current output port, and return the last argument.
173
+
174
+ This is handy for tracing function calls, e.g.:
175
+
176
+ (+ 10 (troublesome-fn))
177
+ => (+ 10 (pk 'troublesome-fn-returned (troublesome-fn)))"
178
+ (newline)
179
+ (display ";;; ")
180
+ (write stuff)
181
+ (newline)
182
+ (car (last-pair stuff)))
183
+
184
+ (define pk peek)
185
+
186
+ (define (warn . stuff)
187
+ (newline (current-warning-port))
188
+ (display ";;; WARNING " (current-warning-port))
189
+ (display stuff (current-warning-port))
190
+ (newline (current-warning-port))
191
+ (car (last-pair stuff)))
192
+
193
+
194
+
195
+ ;;; {Features}
196
+ ;;;
197
+
198
+ (define (provide sym)
199
+ (if (not (memq sym *features*))
200
+ (set! *features* (cons sym *features*))))
201
+
202
+ ;; In SLIB, provided? also checks to see if the module is available. We
203
+ ;; should do that too, but don't.
204
+
205
+ (define (provided? feature)
206
+ "Return #t iff FEATURE is available to this Guile interpreter."
207
+ (and (memq feature *features*) #t))
208
+
209
+
210
+
211
+ ;;; {map and for-each}
212
+ ;;;
213
+
214
+ (define map
215
+ (case-lambda
216
+ ((f l)
217
+ (if (not (list? l))
218
+ (scm-error 'wrong-type-arg "map" "Not a list: ~S"
219
+ (list l) #f))
220
+ (let map1 ((l l))
221
+ (if (pair? l)
222
+ (cons (f (car l)) (map1 (cdr l)))
223
+ '())))
224
+
225
+ ((f l1 l2)
226
+ (if (not (= (length l1) (length l2)))
227
+ (scm-error 'wrong-type-arg "map" "List of wrong length: ~S"
228
+ (list l2) #f))
229
+
230
+ (let map2 ((l1 l1) (l2 l2))
231
+ (if (pair? l1)
232
+ (cons (f (car l1) (car l2))
233
+ (map2 (cdr l1) (cdr l2)))
234
+ '())))
235
+
236
+ ((f l1 . rest)
237
+ (let ((len (length l1)))
238
+ (let mapn ((rest rest))
239
+ (or (null? rest)
240
+ (if (= (length (car rest)) len)
241
+ (mapn (cdr rest))
242
+ (scm-error 'wrong-type-arg "map" "List of wrong length: ~S"
243
+ (list (car rest)) #f)))))
244
+ (let mapn ((l1 l1) (rest rest))
245
+ (if (pair? l1)
246
+ (cons (apply f (car l1) (map car rest))
247
+ (mapn (cdr l1) (map cdr rest)))
248
+ '())))))
249
+
250
+ (define map-in-order map)
251
+
252
+ (define for-each
253
+ (case-lambda
254
+ ((f l)
255
+ (if (not (list? l))
256
+ (scm-error 'wrong-type-arg "for-each" "Not a list: ~S" (list l) #f))
257
+ (let for-each1 ((l l))
258
+ (if (not (null? l))
259
+ (begin
260
+ (f (car l))
261
+ (for-each1 (cdr l))))))
262
+
263
+ ((f l1 l2)
264
+ (if (not (= (length l1) (length l2)))
265
+ (scm-error 'wrong-type-arg "for-each" "List of wrong length: ~S"
266
+ (list l2) #f))
267
+ (let for-each2 ((l1 l1) (l2 l2))
268
+ (if (not (null? l1))
269
+ (begin
270
+ (f (car l1) (car l2))
271
+ (for-each2 (cdr l1) (cdr l2))))))
272
+
273
+ ((f l1 . rest)
274
+ (let ((len (length l1)))
275
+ (let for-eachn ((rest rest))
276
+ (or (null? rest)
277
+ (if (= (length (car rest)) len)
278
+ (for-eachn (cdr rest))
279
+ (scm-error 'wrong-type-arg "for-each" "List of wrong length: ~S"
280
+ (list (car rest)) #f)))))
281
+
282
+ (let for-eachn ((l1 l1) (rest rest))
283
+ (if (pair? l1)
284
+ (begin
285
+ (apply f (car l1) (map car rest))
286
+ (for-eachn (cdr l1) (map cdr rest))))))))
287
+
288
+
289
+ ;; Temporary definitions used by `include'; replaced later.
290
+
291
+ (define (absolute-file-name? file-name) #t)
292
+ (define (open-input-file str) (open-file str "r"))
293
+
294
+ ;; Temporary definition; replaced by a parameter later.
295
+ (define (allow-legacy-syntax-objects?) #f)
296
+
297
+ ;;; {and-map and or-map}
298
+ ;;;
299
+ ;;; (and-map fn lst) is like (and (fn (car lst)) (fn (cadr lst)) (fn...) ...)
300
+ ;;; (or-map fn lst) is like (or (fn (car lst)) (fn (cadr lst)) (fn...) ...)
301
+ ;;;
302
+
303
+ (define (and-map f lst)
304
+ "Apply F to successive elements of LST until exhaustion or F returns #f.
305
+ If returning early, return #f. Otherwise, return the last value returned
306
+ by F. If F has never been called because LST is empty, return #t."
307
+ (let loop ((result #t)
308
+ (l lst))
309
+ (and result
310
+ (or (and (null? l)
311
+ result)
312
+ (loop (f (car l)) (cdr l))))))
313
+
314
+ (define (or-map f lst)
315
+ "Apply F to successive elements of LST until exhaustion or while F returns #f.
316
+ If returning early, return the return value of F."
317
+ (let loop ((result #f)
318
+ (l lst))
319
+ (or result
320
+ (and (not (null? l))
321
+ (loop (f (car l)) (cdr l))))))
322
+
323
+
324
+
325
+ ;; let format alias simple-format until the more complete version is loaded
326
+
327
+ (define format simple-format)
328
+
329
+ ;; this is scheme wrapping the C code so the final pred call is a tail call,
330
+ ;; per SRFI-13 spec
331
+ (define string-any
332
+ (lambda* (char_pred s #:optional (start 0) (end (string-length s)))
333
+ (if (and (procedure? char_pred)
334
+ (> end start)
335
+ (<= end (string-length s))) ;; let c-code handle range error
336
+ (or (string-any-c-code char_pred s start (1- end))
337
+ (char_pred (string-ref s (1- end))))
338
+ (string-any-c-code char_pred s start end))))
339
+
340
+ ;; this is scheme wrapping the C code so the final pred call is a tail call,
341
+ ;; per SRFI-13 spec
342
+ (define string-every
343
+ (lambda* (char_pred s #:optional (start 0) (end (string-length s)))
344
+ (if (and (procedure? char_pred)
345
+ (> end start)
346
+ (<= end (string-length s))) ;; let c-code handle range error
347
+ (and (string-every-c-code char_pred s start (1- end))
348
+ (char_pred (string-ref s (1- end))))
349
+ (string-every-c-code char_pred s start end))))
350
+
351
+ (define (substring-fill! str start end fill)
352
+ "A variant of string-fill! that we keep for compatibility."
353
+ (string-fill! str fill start end))
354
+
355
+
356
+
357
+ ;; Define a minimal stub of the module API for psyntax, before modules
358
+ ;; have booted.
359
+ (define (module-name x)
360
+ '(guile))
361
+ (define (module-add! module sym var)
362
+ (hashq-set! (%get-pre-modules-obarray) sym var))
363
+ (define (module-define! module sym val)
364
+ (let ((v (hashq-ref (%get-pre-modules-obarray) sym)))
365
+ (if v
366
+ (variable-set! v val)
367
+ (module-add! (current-module) sym (make-variable val)))))
368
+ (define (module-ref module sym)
369
+ (let ((v (module-variable module sym)))
370
+ (if v (variable-ref v) (error "badness!" (pk module) (pk sym)))))
371
+ (define module-generate-unique-id!
372
+ (let ((next-id 0))
373
+ (lambda (m)
374
+ (let ((i next-id))
375
+ (set! next-id (+ i 1))
376
+ i))))
377
+ (define module-gensym gensym)
378
+ (define (resolve-module . args)
379
+ #f)
380
+
381
+ ;; API provided by psyntax
382
+ (define syntax-violation #f)
383
+ (define datum->syntax #f)
384
+ (define syntax->datum #f)
385
+ (define syntax-source #f)
386
+ (define identifier? #f)
387
+ (define generate-temporaries #f)
388
+ (define bound-identifier=? #f)
389
+ (define free-identifier=? #f)
390
+
391
+ ;; $sc-dispatch is an implementation detail of psyntax. It is used by
392
+ ;; expanded macros, to dispatch an input against a set of patterns.
393
+ (define $sc-dispatch #f)
394
+
395
+ ;; Load it up!
396
+ (primitive-load-path "ice-9/psyntax-pp")
397
+ ;; The binding for `macroexpand' has now been overridden, making psyntax the
398
+ ;; expander now.
399
+
400
+ (define-syntax and
401
+ (syntax-rules ()
402
+ ((_) #t)
403
+ ((_ x) x)
404
+ ;; Avoid ellipsis, which would lead to quadratic expansion time.
405
+ ((_ x . y) (if x (and . y) #f))))
406
+
407
+ (define-syntax or
408
+ (syntax-rules ()
409
+ ((_) #f)
410
+ ((_ x) x)
411
+ ;; Avoid ellipsis, which would lead to quadratic expansion time.
412
+ ((_ x . y) (let ((t x)) (if t t (or . y))))))
413
+
414
+ (include-from-path "ice-9/quasisyntax")
415
+
416
+ (define-syntax-rule (when test stmt stmt* ...)
417
+ (if test (begin stmt stmt* ...)))
418
+
419
+ (define-syntax-rule (unless test stmt stmt* ...)
420
+ (if (not test) (begin stmt stmt* ...)))
421
+
422
+ (define-syntax cond
423
+ (lambda (whole-expr)
424
+ (define (fold f seed xs)
425
+ (let loop ((xs xs) (seed seed))
426
+ (if (null? xs) seed
427
+ (loop (cdr xs) (f (car xs) seed)))))
428
+ (define (reverse-map f xs)
429
+ (fold (lambda (x seed) (cons (f x) seed))
430
+ '() xs))
431
+ (syntax-case whole-expr ()
432
+ ((_ clause clauses ...)
433
+ #`(begin
434
+ #,@(fold (lambda (clause-builder tail)
435
+ (clause-builder tail))
436
+ #'()
437
+ (reverse-map
438
+ (lambda (clause)
439
+ (define* (bad-clause #:optional (msg "invalid clause"))
440
+ (syntax-violation 'cond msg whole-expr clause))
441
+ (syntax-case clause (=> else)
442
+ ((else e e* ...)
443
+ (lambda (tail)
444
+ (if (null? tail)
445
+ #'((begin e e* ...))
446
+ (bad-clause "else must be the last clause"))))
447
+ ((else . _) (bad-clause))
448
+ ((test => receiver)
449
+ (lambda (tail)
450
+ #`((let ((t test))
451
+ (if t
452
+ (receiver t)
453
+ #,@tail)))))
454
+ ((test => receiver ...)
455
+ (bad-clause "wrong number of receiver expressions"))
456
+ ((generator guard => receiver)
457
+ (lambda (tail)
458
+ #`((call-with-values (lambda () generator)
459
+ (lambda vals
460
+ (if (apply guard vals)
461
+ (apply receiver vals)
462
+ #,@tail))))))
463
+ ((generator guard => receiver ...)
464
+ (bad-clause "wrong number of receiver expressions"))
465
+ ((test)
466
+ (lambda (tail)
467
+ #`((let ((t test))
468
+ (if t t #,@tail)))))
469
+ ((test e e* ...)
470
+ (lambda (tail)
471
+ #`((if test
472
+ (begin e e* ...)
473
+ #,@tail))))
474
+ (_ (bad-clause))))
475
+ #'(clause clauses ...))))))))
476
+
477
+ (define-syntax case
478
+ (lambda (whole-expr)
479
+ (define (fold f seed xs)
480
+ (let loop ((xs xs) (seed seed))
481
+ (if (null? xs) seed
482
+ (loop (cdr xs) (f (car xs) seed)))))
483
+ (define (fold2 f a b xs)
484
+ (let loop ((xs xs) (a a) (b b))
485
+ (if (null? xs) (values a b)
486
+ (call-with-values
487
+ (lambda () (f (car xs) a b))
488
+ (lambda (a b)
489
+ (loop (cdr xs) a b))))))
490
+ (define (reverse-map-with-seed f seed xs)
491
+ (fold2 (lambda (x ys seed)
492
+ (call-with-values
493
+ (lambda () (f x seed))
494
+ (lambda (y seed)
495
+ (values (cons y ys) seed))))
496
+ '() seed xs))
497
+ (syntax-case whole-expr ()
498
+ ((_ expr clause clauses ...)
499
+ (with-syntax ((key #'key))
500
+ #`(let ((key expr))
501
+ #,@(fold
502
+ (lambda (clause-builder tail)
503
+ (clause-builder tail))
504
+ #'()
505
+ (reverse-map-with-seed
506
+ (lambda (clause seen)
507
+ (define* (bad-clause #:optional (msg "invalid clause"))
508
+ (syntax-violation 'case msg whole-expr clause))
509
+ (syntax-case clause ()
510
+ ((test . rest)
511
+ (with-syntax
512
+ ((clause-expr
513
+ (syntax-case #'rest (=>)
514
+ ((=> receiver) #'(receiver key))
515
+ ((=> receiver ...)
516
+ (bad-clause
517
+ "wrong number of receiver expressions"))
518
+ ((e e* ...) #'(begin e e* ...))
519
+ (_ (bad-clause)))))
520
+ (syntax-case #'test (else)
521
+ ((datums ...)
522
+ (let ((seen
523
+ (fold
524
+ (lambda (datum seen)
525
+ (define (warn-datum type)
526
+ ((@ (system base message)
527
+ warning)
528
+ type
529
+ (append (source-properties datum)
530
+ (source-properties
531
+ (syntax->datum #'test)))
532
+ datum
533
+ (syntax->datum clause)
534
+ (syntax->datum whole-expr)))
535
+ (when (memv datum seen)
536
+ (warn-datum 'duplicate-case-datum))
537
+ (when (or (pair? datum) (array? datum))
538
+ (warn-datum 'bad-case-datum))
539
+ (cons datum seen))
540
+ seen
541
+ (map syntax->datum #'(datums ...)))))
542
+ (values (lambda (tail)
543
+ #`((if (memv key '(datums ...))
544
+ clause-expr
545
+ #,@tail)))
546
+ seen)))
547
+ (else (values (lambda (tail)
548
+ (if (null? tail)
549
+ #'(clause-expr)
550
+ (bad-clause
551
+ "else must be the last clause")))
552
+ seen))
553
+ (_ (bad-clause)))))
554
+ (_ (bad-clause))))
555
+ '() #'(clause clauses ...)))))))))
556
+
557
+ (define-syntax do
558
+ (syntax-rules ()
559
+ ((do ((var init step ...) ...)
560
+ (test expr ...)
561
+ command ...)
562
+ (letrec
563
+ ((loop
564
+ (lambda (var ...)
565
+ (if test
566
+ (begin
567
+ (if #f #f)
568
+ expr ...)
569
+ (begin
570
+ command
571
+ ...
572
+ (loop (do "step" var step ...)
573
+ ...))))))
574
+ (loop init ...)))
575
+ ((do "step" x)
576
+ x)
577
+ ((do "step" x y)
578
+ y)))
579
+
580
+ (define-syntax define-values
581
+ (lambda (orig-form)
582
+ (syntax-case orig-form ()
583
+ ((_ () expr)
584
+ ;; XXX Work around the lack of hygienic top-level identifiers
585
+ (with-syntax (((dummy) (generate-temporaries '(dummy))))
586
+ #`(define dummy
587
+ (call-with-values (lambda () expr)
588
+ (lambda () #f)))))
589
+ ((_ (var) expr)
590
+ (identifier? #'var)
591
+ #`(define var
592
+ (call-with-values (lambda () expr)
593
+ (lambda (v) v))))
594
+ ((_ (var0 ... varn) expr)
595
+ (and-map identifier? #'(var0 ... varn))
596
+ ;; XXX Work around the lack of hygienic toplevel identifiers
597
+ (with-syntax (((dummy) (generate-temporaries '(dummy))))
598
+ #`(begin
599
+ ;; Avoid mutating the user-visible variables
600
+ (define dummy
601
+ (call-with-values (lambda () expr)
602
+ (lambda (var0 ... varn)
603
+ (list var0 ... varn))))
604
+ (define var0
605
+ (let ((v (car dummy)))
606
+ (set! dummy (cdr dummy))
607
+ v))
608
+ ...
609
+ (define varn
610
+ (let ((v (car dummy)))
611
+ (set! dummy #f) ; blackhole dummy
612
+ v)))))
613
+ ((_ var expr)
614
+ (identifier? #'var)
615
+ #'(define var
616
+ (call-with-values (lambda () expr)
617
+ list)))
618
+ ((_ (var0 ... . varn) expr)
619
+ (and-map identifier? #'(var0 ... varn))
620
+ ;; XXX Work around the lack of hygienic toplevel identifiers
621
+ (with-syntax (((dummy) (generate-temporaries '(dummy))))
622
+ #`(begin
623
+ ;; Avoid mutating the user-visible variables
624
+ (define dummy
625
+ (call-with-values (lambda () expr)
626
+ (lambda (var0 ... . varn)
627
+ (list var0 ... varn))))
628
+ (define var0
629
+ (let ((v (car dummy)))
630
+ (set! dummy (cdr dummy))
631
+ v))
632
+ ...
633
+ (define varn
634
+ (let ((v (car dummy)))
635
+ (set! dummy #f) ; blackhole dummy
636
+ v))))))))
637
+
638
+ (define-syntax-rule (delay exp)
639
+ (make-promise (lambda () exp)))
640
+
641
+ (define-syntax with-fluids
642
+ (lambda (stx)
643
+ (define (emit-with-fluids bindings body)
644
+ (syntax-case bindings ()
645
+ (()
646
+ body)
647
+ (((f v) . bindings)
648
+ #`(with-fluid* f v
649
+ (lambda ()
650
+ #,(emit-with-fluids #'bindings body))))))
651
+ (syntax-case stx ()
652
+ ((_ ((fluid val) ...) exp exp* ...)
653
+ (with-syntax (((fluid-tmp ...) (generate-temporaries #'(fluid ...)))
654
+ ((val-tmp ...) (generate-temporaries #'(val ...))))
655
+ #`(let ((fluid-tmp fluid) ...)
656
+ (let ((val-tmp val) ...)
657
+ #,(emit-with-fluids #'((fluid-tmp val-tmp) ...)
658
+ #'(begin exp exp* ...)))))))))
659
+
660
+ (define-syntax current-source-location
661
+ (lambda (x)
662
+ (syntax-case x ()
663
+ ((_)
664
+ (with-syntax ((s (datum->syntax x (syntax-source x))))
665
+ #''s)))))
666
+
667
+ ;; We provide this accessor out of convenience. current-line and
668
+ ;; current-column aren't so interesting, because they distort what they
669
+ ;; are measuring; better to use syntax-source from a macro.
670
+ ;;
671
+ (define-syntax current-filename
672
+ (lambda (x)
673
+ "A macro that expands to the current filename: the filename that
674
+ the (current-filename) form appears in. Expands to #f if this
675
+ information is unavailable."
676
+ (false-if-exception
677
+ (canonicalize-path (assq-ref (syntax-source x) 'filename)))))
678
+
679
+ (define-syntax-rule (define-once sym val)
680
+ (define sym
681
+ (if (module-locally-bound? (current-module) 'sym) sym val)))
682
+
683
+
684
+
685
+
686
+ ;;; {Error handling}
687
+ ;;;
688
+
689
+ ;; Define delimited continuation operators, and implement catch and throw in
690
+ ;; terms of them.
691
+
692
+ (define make-prompt-tag
693
+ (lambda* (#:optional (stem "prompt"))
694
+ ;; The only property that prompt tags need have is uniqueness in the
695
+ ;; sense of eq?. A one-element list will serve nicely.
696
+ (list stem)))
697
+
698
+ (define default-prompt-tag
699
+ ;; Redefined later to be a parameter.
700
+ (let ((%default-prompt-tag (make-prompt-tag)))
701
+ (lambda ()
702
+ %default-prompt-tag)))
703
+
704
+ (define (call-with-prompt tag thunk handler)
705
+ ((@@ primitive call-with-prompt) tag thunk handler))
706
+ (define (abort-to-prompt tag . args)
707
+ (abort-to-prompt* tag args))
708
+
709
+ ;; Define catch and with-throw-handler, using some common helper routines and a
710
+ ;; shared fluid. Hide the helpers in a lexical contour.
711
+
712
+ (define with-throw-handler #f)
713
+ (let ((%eh (module-ref (current-module) '%exception-handler)))
714
+ (define (make-exception-handler catch-key prompt-tag pre-unwind)
715
+ (vector catch-key prompt-tag pre-unwind))
716
+ (define (exception-handler-catch-key handler) (vector-ref handler 0))
717
+ (define (exception-handler-prompt-tag handler) (vector-ref handler 1))
718
+ (define (exception-handler-pre-unwind handler) (vector-ref handler 2))
719
+
720
+ (define %running-pre-unwind (make-fluid #f))
721
+ (define (pre-unwind-handler-running? handler)
722
+ (let lp ((depth 0))
723
+ (let ((running (fluid-ref* %running-pre-unwind depth)))
724
+ (and running
725
+ (or (eq? running handler) (lp (1+ depth)))))))
726
+
727
+ (define (dispatch-exception depth key args)
728
+ (cond
729
+ ((fluid-ref* %eh depth)
730
+ => (lambda (handler)
731
+ (let ((catch-key (exception-handler-catch-key handler)))
732
+ (if (or (eqv? catch-key #t) (eq? catch-key key))
733
+ (let ((prompt-tag (exception-handler-prompt-tag handler))
734
+ (pre-unwind (exception-handler-pre-unwind handler)))
735
+ (cond
736
+ ((and pre-unwind
737
+ (not (pre-unwind-handler-running? handler)))
738
+ ;; Prevent errors from within the pre-unwind
739
+ ;; handler's invocation from being handled by this
740
+ ;; handler.
741
+ (with-fluid* %running-pre-unwind handler
742
+ (lambda ()
743
+ ;; FIXME: Currently the "running" flag only
744
+ ;; applies to the pre-unwind handler; the
745
+ ;; post-unwind handler is still called if the
746
+ ;; error is explicitly rethrown. Instead it
747
+ ;; would be better to cause a recursive throw to
748
+ ;; skip all parts of this handler. Unfortunately
749
+ ;; that is incompatible with existing semantics.
750
+ ;; We'll see if we can change that later on.
751
+ (apply pre-unwind key args)
752
+ (dispatch-exception depth key args))))
753
+ (prompt-tag
754
+ (apply abort-to-prompt prompt-tag key args))
755
+ (else
756
+ (dispatch-exception (1+ depth) key args))))
757
+ (dispatch-exception (1+ depth) key args)))))
758
+ ((eq? key 'quit)
759
+ (primitive-exit (cond
760
+ ((not (pair? args)) 0)
761
+ ((integer? (car args)) (car args))
762
+ ((not (car args)) 1)
763
+ (else 0))))
764
+ (else
765
+ (format (current-error-port) "guile: uncaught throw to ~a: ~a\n"
766
+ key args)
767
+ (primitive-exit 1))))
768
+
769
+ (define (throw key . args)
770
+ "Invoke the catch form matching @var{key}, passing @var{args} to the
771
+ @var{handler}.
772
+
773
+ @var{key} is a symbol. It will match catches of the same symbol or of @code{#t}.
774
+
775
+ If there is no handler at all, Guile prints an error and then exits."
776
+ (unless (symbol? key)
777
+ (throw 'wrong-type-arg "throw" "Wrong type argument in position ~a: ~a"
778
+ (list 1 key) (list key)))
779
+ (dispatch-exception 0 key args))
780
+
781
+ (define* (catch k thunk handler #:optional pre-unwind-handler)
782
+ "Invoke @var{thunk} in the dynamic context of @var{handler} for
783
+ exceptions matching @var{key}. If thunk throws to the symbol
784
+ @var{key}, then @var{handler} is invoked this way:
785
+ @lisp
786
+ (handler key args ...)
787
+ @end lisp
788
+
789
+ @var{key} is a symbol or @code{#t}.
790
+
791
+ @var{thunk} takes no arguments. If @var{thunk} returns
792
+ normally, that is the return value of @code{catch}.
793
+
794
+ Handler is invoked outside the scope of its own @code{catch}.
795
+ If @var{handler} again throws to the same key, a new handler
796
+ from further up the call chain is invoked.
797
+
798
+ If the key is @code{#t}, then a throw to @emph{any} symbol will
799
+ match this call to @code{catch}.
800
+
801
+ If a @var{pre-unwind-handler} is given and @var{thunk} throws
802
+ an exception that matches @var{key}, Guile calls the
803
+ @var{pre-unwind-handler} before unwinding the dynamic state and
804
+ invoking the main @var{handler}. @var{pre-unwind-handler} should
805
+ be a procedure with the same signature as @var{handler}, that
806
+ is @code{(lambda (key . args))}. It is typically used to save
807
+ the stack at the point where the exception occurred, but can also
808
+ query other parts of the dynamic state at that point, such as
809
+ fluid values.
810
+
811
+ A @var{pre-unwind-handler} can exit either normally or non-locally.
812
+ If it exits normally, Guile unwinds the stack and dynamic context
813
+ and then calls the normal (third argument) handler. If it exits
814
+ non-locally, that exit determines the continuation."
815
+ (define (wrong-type-arg n val)
816
+ (scm-error 'wrong-type-arg "catch"
817
+ "Wrong type argument in position ~a: ~a"
818
+ (list n val) (list val)))
819
+ (unless (or (symbol? k) (eqv? k #t))
820
+ (wrong-type-arg 1 k))
821
+ (unless (procedure? handler)
822
+ (wrong-type-arg 3 handler))
823
+ (unless (or (not pre-unwind-handler) (procedure? pre-unwind-handler))
824
+ (wrong-type-arg 4 pre-unwind-handler))
825
+ (let ((tag (make-prompt-tag "catch")))
826
+ (call-with-prompt
827
+ tag
828
+ (lambda ()
829
+ (with-fluid* %eh (make-exception-handler k tag pre-unwind-handler)
830
+ thunk))
831
+ (lambda (cont k . args)
832
+ (apply handler k args)))))
833
+
834
+ (define (with-throw-handler k thunk pre-unwind-handler)
835
+ "Add @var{handler} to the dynamic context as a throw handler
836
+ for key @var{k}, then invoke @var{thunk}."
837
+ (if (not (or (symbol? k) (eqv? k #t)))
838
+ (scm-error 'wrong-type-arg "with-throw-handler"
839
+ "Wrong type argument in position ~a: ~a"
840
+ (list 1 k) (list k)))
841
+ (with-fluid* %eh (make-exception-handler k #f pre-unwind-handler)
842
+ thunk))
843
+
844
+ (hashq-remove! (%get-pre-modules-obarray) '%exception-handler)
845
+ (define! 'catch catch)
846
+ (define! 'with-throw-handler with-throw-handler)
847
+ (define! 'throw throw))
848
+
849
+
850
+
851
+
852
+ ;;;
853
+ ;;; Extensible exception printing.
854
+ ;;;
855
+
856
+ (define set-exception-printer! #f)
857
+ ;; There is already a definition of print-exception from backtrace.c
858
+ ;; that we will override.
859
+
860
+ (let ((exception-printers '()))
861
+ (define (print-location frame port)
862
+ (let ((source (and=> frame frame-source)))
863
+ ;; source := (addr . (filename . (line . column)))
864
+ (if source
865
+ (let ((filename (or (cadr source) "<unnamed port>"))
866
+ (line (caddr source))
867
+ (col (cdddr source)))
868
+ (format port "~a:~a:~a: " filename (1+ line) col))
869
+ (format port "ERROR: "))))
870
+
871
+ (set! set-exception-printer!
872
+ (lambda (key proc)
873
+ (set! exception-printers (acons key proc exception-printers))))
874
+
875
+ (set! print-exception
876
+ (lambda (port frame key args)
877
+ (define (default-printer)
878
+ (format port "Throw to key `~a' with args `~s'." key args))
879
+
880
+ (when frame
881
+ (print-location frame port)
882
+ ;; When booting, false-if-exception isn't defined yet.
883
+ (let ((name (catch #t
884
+ (lambda () (frame-procedure-name frame))
885
+ (lambda _ #f))))
886
+ (when name
887
+ (format port "In procedure ~a:\n" name))))
888
+
889
+ (catch #t
890
+ (lambda ()
891
+ (let ((printer (assq-ref exception-printers key)))
892
+ (if printer
893
+ (printer port key args default-printer)
894
+ (default-printer))))
895
+ (lambda (k . args)
896
+ (format port "Error while printing exception.")))
897
+ (newline port)
898
+ (force-output port))))
899
+
900
+ ;;;
901
+ ;;; Printers for those keys thrown by Guile.
902
+ ;;;
903
+ (let ()
904
+ (define (scm-error-printer port key args default-printer)
905
+ ;; Abuse case-lambda as a pattern matcher, given that we don't have
906
+ ;; ice-9 match at this point.
907
+ (apply (case-lambda
908
+ ((subr msg args . rest)
909
+ (if subr
910
+ (format port "In procedure ~a: " subr))
911
+ (apply format port msg (or args '())))
912
+ (_ (default-printer)))
913
+ args))
914
+
915
+ (define (syntax-error-printer port key args default-printer)
916
+ (apply (case-lambda
917
+ ((who what where form subform . extra)
918
+ (format port "Syntax error:\n")
919
+ (if where
920
+ (let ((file (or (assq-ref where 'filename) "unknown file"))
921
+ (line (and=> (assq-ref where 'line) 1+))
922
+ (col (assq-ref where 'column)))
923
+ (format port "~a:~a:~a: " file line col))
924
+ (format port "unknown location: "))
925
+ (if who
926
+ (format port "~a: " who))
927
+ (format port "~a" what)
928
+ (if subform
929
+ (format port " in subform ~s of ~s" subform form)
930
+ (if form
931
+ (format port " in form ~s" form))))
932
+ (_ (default-printer)))
933
+ args))
934
+
935
+ (define (keyword-error-printer port key args default-printer)
936
+ (let ((message (cadr args))
937
+ (faulty (car (cadddr args)))) ; I won't do it again, I promise.
938
+ (format port "~a: ~s" message faulty)))
939
+
940
+ (define (getaddrinfo-error-printer port key args default-printer)
941
+ (format port "In procedure getaddrinfo: ~a" (gai-strerror (car args))))
942
+
943
+ (set-exception-printer! 'goops-error scm-error-printer)
944
+ (set-exception-printer! 'host-not-found scm-error-printer)
945
+ (set-exception-printer! 'keyword-argument-error keyword-error-printer)
946
+ (set-exception-printer! 'misc-error scm-error-printer)
947
+ (set-exception-printer! 'no-data scm-error-printer)
948
+ (set-exception-printer! 'no-recovery scm-error-printer)
949
+ (set-exception-printer! 'null-pointer-error scm-error-printer)
950
+ (set-exception-printer! 'out-of-memory scm-error-printer)
951
+ (set-exception-printer! 'out-of-range scm-error-printer)
952
+ (set-exception-printer! 'program-error scm-error-printer)
953
+ (set-exception-printer! 'read-error scm-error-printer)
954
+ (set-exception-printer! 'regular-expression-syntax scm-error-printer)
955
+ (set-exception-printer! 'signal scm-error-printer)
956
+ (set-exception-printer! 'stack-overflow scm-error-printer)
957
+ (set-exception-printer! 'system-error scm-error-printer)
958
+ (set-exception-printer! 'try-again scm-error-printer)
959
+ (set-exception-printer! 'unbound-variable scm-error-printer)
960
+ (set-exception-printer! 'wrong-number-of-args scm-error-printer)
961
+ (set-exception-printer! 'wrong-type-arg scm-error-printer)
962
+
963
+ (set-exception-printer! 'syntax-error syntax-error-printer)
964
+
965
+ (set-exception-printer! 'getaddrinfo-error getaddrinfo-error-printer))
966
+
967
+
968
+
969
+
970
+ ;;; {Defmacros}
971
+ ;;;
972
+
973
+ (define-syntax define-macro
974
+ (lambda (x)
975
+ "Define a defmacro."
976
+ (syntax-case x ()
977
+ ((_ (macro . args) doc body1 body ...)
978
+ (string? (syntax->datum #'doc))
979
+ #'(define-macro macro doc (lambda args body1 body ...)))
980
+ ((_ (macro . args) body ...)
981
+ #'(define-macro macro #f (lambda args body ...)))
982
+ ((_ macro transformer)
983
+ #'(define-macro macro #f transformer))
984
+ ((_ macro doc transformer)
985
+ (or (string? (syntax->datum #'doc))
986
+ (not (syntax->datum #'doc)))
987
+ #'(define-syntax macro
988
+ (lambda (y)
989
+ doc
990
+ #((macro-type . defmacro)
991
+ (defmacro-args args))
992
+ (syntax-case y ()
993
+ ((_ . args)
994
+ (let ((v (syntax->datum #'args)))
995
+ (datum->syntax y (apply transformer v)))))))))))
996
+
997
+ (define-syntax defmacro
998
+ (lambda (x)
999
+ "Define a defmacro, with the old lispy defun syntax."
1000
+ (syntax-case x ()
1001
+ ((_ macro args doc body1 body ...)
1002
+ (string? (syntax->datum #'doc))
1003
+ #'(define-macro macro doc (lambda args body1 body ...)))
1004
+ ((_ macro args body ...)
1005
+ #'(define-macro macro #f (lambda args body ...))))))
1006
+
1007
+ (provide 'defmacro)
1008
+
1009
+
1010
+
1011
+ ;;; {Deprecation}
1012
+ ;;;
1013
+
1014
+ (define-syntax begin-deprecated
1015
+ (lambda (x)
1016
+ (syntax-case x ()
1017
+ ((_ form form* ...)
1018
+ (if (include-deprecated-features)
1019
+ #'(begin form form* ...)
1020
+ #'(begin))))))
1021
+
1022
+
1023
+
1024
+ ;;; {Trivial Functions}
1025
+ ;;;
1026
+
1027
+ (define (identity x) x)
1028
+
1029
+ (define (compose proc . rest)
1030
+ "Compose PROC with the procedures in REST, such that the last one in
1031
+ REST is applied first and PROC last, and return the resulting procedure.
1032
+ The given procedures must have compatible arity."
1033
+ (if (null? rest)
1034
+ proc
1035
+ (let ((g (apply compose rest)))
1036
+ (lambda args
1037
+ (call-with-values (lambda () (apply g args)) proc)))))
1038
+
1039
+ (define (negate proc)
1040
+ "Return a procedure with the same arity as PROC that returns the `not'
1041
+ of PROC's result."
1042
+ (lambda args
1043
+ (not (apply proc args))))
1044
+
1045
+ (define (const value)
1046
+ "Return a procedure that accepts any number of arguments and returns
1047
+ VALUE."
1048
+ (lambda _
1049
+ value))
1050
+
1051
+ (define (and=> value procedure)
1052
+ "When VALUE is #f, return #f. Otherwise, return (PROC VALUE)."
1053
+ (and value (procedure value)))
1054
+
1055
+ (define call/cc call-with-current-continuation)
1056
+
1057
+ (define-syntax false-if-exception
1058
+ (syntax-rules ()
1059
+ ((false-if-exception expr)
1060
+ (catch #t
1061
+ (lambda () expr)
1062
+ (lambda args #f)))
1063
+ ((false-if-exception expr #:warning template arg ...)
1064
+ (catch #t
1065
+ (lambda () expr)
1066
+ (lambda (key . args)
1067
+ (for-each (lambda (s)
1068
+ (if (not (string-null? s))
1069
+ (format (current-warning-port) ";;; ~a\n" s)))
1070
+ (string-split
1071
+ (call-with-output-string
1072
+ (lambda (port)
1073
+ (format port template arg ...)
1074
+ (print-exception port #f key args)))
1075
+ #\newline))
1076
+ #f)))))
1077
+
1078
+
1079
+
1080
+ ;;; {General Properties}
1081
+ ;;;
1082
+
1083
+ ;; Properties are a lispy way to associate random info with random objects.
1084
+ ;; Traditionally properties are implemented as an alist or a plist actually
1085
+ ;; pertaining to the object in question.
1086
+ ;;
1087
+ ;; These "object properties" have the advantage that they can be associated with
1088
+ ;; any object, even if the object has no plist. Object properties are good when
1089
+ ;; you are extending pre-existing objects in unexpected ways. They also present
1090
+ ;; a pleasing, uniform procedure-with-setter interface. But if you have a data
1091
+ ;; type that always has properties, it's often still best to store those
1092
+ ;; properties within the object itself.
1093
+
1094
+ (define (make-object-property)
1095
+ ;; Weak tables are thread-safe.
1096
+ (let ((prop (make-weak-key-hash-table)))
1097
+ (make-procedure-with-setter
1098
+ (lambda (obj) (hashq-ref prop obj))
1099
+ (lambda (obj val) (hashq-set! prop obj val)))))
1100
+
1101
+
1102
+
1103
+
1104
+ ;;; {Symbol Properties}
1105
+ ;;;
1106
+
1107
+ ;;; Symbol properties are something you see in old Lisp code. In most current
1108
+ ;;; Guile code, symbols are not used as a data structure -- they are used as
1109
+ ;;; keys into other data structures.
1110
+
1111
+ (define (symbol-property sym prop)
1112
+ (let ((pair (assoc prop (symbol-pref sym))))
1113
+ (and pair (cdr pair))))
1114
+
1115
+ (define (set-symbol-property! sym prop val)
1116
+ (let ((pair (assoc prop (symbol-pref sym))))
1117
+ (if pair
1118
+ (set-cdr! pair val)
1119
+ (symbol-pset! sym (acons prop val (symbol-pref sym))))))
1120
+
1121
+ (define (symbol-property-remove! sym prop)
1122
+ (let ((pair (assoc prop (symbol-pref sym))))
1123
+ (if pair
1124
+ (symbol-pset! sym (delq! pair (symbol-pref sym))))))
1125
+
1126
+
1127
+
1128
+ ;;; {Arrays}
1129
+ ;;;
1130
+
1131
+ (define (array-shape a)
1132
+ (map (lambda (ind) (if (number? ind) (list 0 (+ -1 ind)) ind))
1133
+ (array-dimensions a)))
1134
+
1135
+
1136
+
1137
+ ;;; {Keywords}
1138
+ ;;;
1139
+
1140
+ ;;; It's much better if you can use lambda* / define*, of course.
1141
+
1142
+ (define (kw-arg-ref args kw)
1143
+ (let ((rem (member kw args)))
1144
+ (and rem (pair? (cdr rem)) (cadr rem))))
1145
+
1146
+
1147
+
1148
+ ;;; {IOTA functions: generating lists of numbers}
1149
+ ;;;
1150
+
1151
+ (define (iota n)
1152
+ (let loop ((count (1- n)) (result '()))
1153
+ (if (< count 0) result
1154
+ (loop (1- count) (cons count result)))))
1155
+
1156
+
1157
+
1158
+ ;;; {Structs}
1159
+ ;;;
1160
+
1161
+ (define (struct-layout s)
1162
+ (struct-ref (struct-vtable s) vtable-index-layout))
1163
+
1164
+
1165
+
1166
+ ;;; {Records}
1167
+ ;;;
1168
+
1169
+ ;; Printing records: by default, records are printed as
1170
+ ;;
1171
+ ;; #<type-name field1: val1 field2: val2 ...>
1172
+ ;;
1173
+ ;; You can change that by giving a custom printing function to
1174
+ ;; MAKE-RECORD-TYPE (after the list of field symbols). This function
1175
+ ;; will be called like
1176
+ ;;
1177
+ ;; (<printer> object port)
1178
+ ;;
1179
+ ;; It should print OBJECT to PORT.
1180
+
1181
+ ;; 0: type-name, 1: fields, 2: constructor
1182
+ (define record-type-vtable
1183
+ (let ((s (make-vtable (string-append standard-vtable-fields "prprpw")
1184
+ (lambda (s p)
1185
+ (display "#<record-type " p)
1186
+ (display (record-type-name s) p)
1187
+ (display ">" p)))))
1188
+ (set-struct-vtable-name! s 'record-type)
1189
+ s))
1190
+
1191
+ (define (record-type? obj)
1192
+ (and (struct? obj) (eq? record-type-vtable (struct-vtable obj))))
1193
+
1194
+ (define* (make-record-type type-name fields #:optional printer)
1195
+ ;; Pre-generate constructors for nfields < 20.
1196
+ (define-syntax make-constructor
1197
+ (lambda (x)
1198
+ (define *max-static-argument-count* 20)
1199
+ (define (make-formals n)
1200
+ (let lp ((i 0))
1201
+ (if (< i n)
1202
+ (cons (datum->syntax
1203
+ x
1204
+ (string->symbol
1205
+ (string (integer->char (+ (char->integer #\a) i)))))
1206
+ (lp (1+ i)))
1207
+ '())))
1208
+ (syntax-case x ()
1209
+ ((_ rtd exp) (not (identifier? #'exp))
1210
+ #'(let ((n exp))
1211
+ (make-constructor rtd n)))
1212
+ ((_ rtd nfields)
1213
+ #`(case nfields
1214
+ #,@(let lp ((n 0))
1215
+ (if (< n *max-static-argument-count*)
1216
+ (cons (with-syntax (((formal ...) (make-formals n))
1217
+ ((idx ...) (iota n))
1218
+ (n n))
1219
+ #'((n)
1220
+ (lambda (formal ...)
1221
+ (let ((s (allocate-struct rtd n)))
1222
+ (struct-set! s idx formal)
1223
+ ...
1224
+ s))))
1225
+ (lp (1+ n)))
1226
+ '()))
1227
+ (else
1228
+ (lambda args
1229
+ (if (= (length args) nfields)
1230
+ (apply make-struct/no-tail rtd args)
1231
+ (scm-error 'wrong-number-of-args
1232
+ (format #f "make-~a" type-name)
1233
+ "Wrong number of arguments" '() #f)))))))))
1234
+
1235
+ (define (default-record-printer s p)
1236
+ (display "#<" p)
1237
+ (display (record-type-name (record-type-descriptor s)) p)
1238
+ (let loop ((fields (record-type-fields (record-type-descriptor s)))
1239
+ (off 0))
1240
+ (cond
1241
+ ((not (null? fields))
1242
+ (display " " p)
1243
+ (display (car fields) p)
1244
+ (display ": " p)
1245
+ (display (struct-ref s off) p)
1246
+ (loop (cdr fields) (+ 1 off)))))
1247
+ (display ">" p))
1248
+
1249
+ (let ((rtd (make-struct/no-tail
1250
+ record-type-vtable
1251
+ (make-struct-layout
1252
+ (apply string-append
1253
+ (map (lambda (f) "pw") fields)))
1254
+ (or printer default-record-printer)
1255
+ type-name
1256
+ (copy-tree fields))))
1257
+ (struct-set! rtd (+ vtable-offset-user 2)
1258
+ (make-constructor rtd (length fields)))
1259
+ ;; Temporary solution: Associate a name to the record type descriptor
1260
+ ;; so that the object system can create a wrapper class for it.
1261
+ (set-struct-vtable-name! rtd (if (symbol? type-name)
1262
+ type-name
1263
+ (string->symbol type-name)))
1264
+ rtd))
1265
+
1266
+ (define (record-type-name obj)
1267
+ (if (record-type? obj)
1268
+ (struct-ref obj vtable-offset-user)
1269
+ (error 'not-a-record-type obj)))
1270
+
1271
+ (define (record-type-fields obj)
1272
+ (if (record-type? obj)
1273
+ (struct-ref obj (+ 1 vtable-offset-user))
1274
+ (error 'not-a-record-type obj)))
1275
+
1276
+ (define* (record-constructor rtd #:optional field-names)
1277
+ (if (not field-names)
1278
+ (struct-ref rtd (+ 2 vtable-offset-user))
1279
+ (primitive-eval
1280
+ `(lambda ,field-names
1281
+ (make-struct/no-tail ',rtd
1282
+ ,@(map (lambda (f)
1283
+ (if (memq f field-names)
1284
+ f
1285
+ #f))
1286
+ (record-type-fields rtd)))))))
1287
+
1288
+ (define (record-predicate rtd)
1289
+ (lambda (obj) (and (struct? obj) (eq? rtd (struct-vtable obj)))))
1290
+
1291
+ (define (%record-type-error rtd obj) ;; private helper
1292
+ (or (eq? rtd (record-type-descriptor obj))
1293
+ (scm-error 'wrong-type-arg "%record-type-check"
1294
+ "Wrong type record (want `~S'): ~S"
1295
+ (list (record-type-name rtd) obj)
1296
+ #f)))
1297
+
1298
+ (define (record-accessor rtd field-name)
1299
+ (let ((pos (list-index (record-type-fields rtd) field-name)))
1300
+ (if (not pos)
1301
+ (error 'no-such-field field-name))
1302
+ (lambda (obj)
1303
+ (if (eq? (struct-vtable obj) rtd)
1304
+ (struct-ref obj pos)
1305
+ (%record-type-error rtd obj)))))
1306
+
1307
+ (define (record-modifier rtd field-name)
1308
+ (let ((pos (list-index (record-type-fields rtd) field-name)))
1309
+ (if (not pos)
1310
+ (error 'no-such-field field-name))
1311
+ (lambda (obj val)
1312
+ (if (eq? (struct-vtable obj) rtd)
1313
+ (struct-set! obj pos val)
1314
+ (%record-type-error rtd obj)))))
1315
+
1316
+ (define (record? obj)
1317
+ (and (struct? obj) (record-type? (struct-vtable obj))))
1318
+
1319
+ (define (record-type-descriptor obj)
1320
+ (if (struct? obj)
1321
+ (struct-vtable obj)
1322
+ (error 'not-a-record obj)))
1323
+
1324
+ (provide 'record)
1325
+
1326
+
1327
+
1328
+ ;;; {Parameters}
1329
+ ;;;
1330
+
1331
+ (define <parameter>
1332
+ ;; Three fields: the procedure itself, the fluid, and the converter.
1333
+ (make-struct/no-tail <applicable-struct-vtable> 'pwprpr))
1334
+ (set-struct-vtable-name! <parameter> '<parameter>)
1335
+
1336
+ (define* (make-parameter init #:optional (conv (lambda (x) x)))
1337
+ "Make a new parameter.
1338
+
1339
+ A parameter is a dynamically bound value, accessed through a procedure.
1340
+ To access the current value, apply the procedure with no arguments:
1341
+
1342
+ (define p (make-parameter 10))
1343
+ (p) => 10
1344
+
1345
+ To provide a new value for the parameter in a dynamic extent, use
1346
+ `parameterize':
1347
+
1348
+ (parameterize ((p 20))
1349
+ (p)) => 20
1350
+ (p) => 10
1351
+
1352
+ The value outside of the dynamic extent of the body is unaffected. To
1353
+ update the current value, apply it to one argument:
1354
+
1355
+ (p 20) => 10
1356
+ (p) => 20
1357
+
1358
+ As you can see, the call that updates a parameter returns its previous
1359
+ value.
1360
+
1361
+ All values for the parameter are first run through the CONV procedure,
1362
+ including INIT, the initial value. The default CONV procedure is the
1363
+ identity procedure. CONV is commonly used to ensure some set of
1364
+ invariants on the values that a parameter may have."
1365
+ (let ((fluid (make-fluid (conv init))))
1366
+ (make-struct/no-tail
1367
+ <parameter>
1368
+ (case-lambda
1369
+ (() (fluid-ref fluid))
1370
+ ((x) (let ((prev (fluid-ref fluid)))
1371
+ (fluid-set! fluid (conv x))
1372
+ prev)))
1373
+ fluid conv)))
1374
+
1375
+ (define (parameter? x)
1376
+ (and (struct? x) (eq? (struct-vtable x) <parameter>)))
1377
+
1378
+ (define (parameter-fluid p)
1379
+ (if (parameter? p)
1380
+ (struct-ref p 1)
1381
+ (scm-error 'wrong-type-arg "parameter-fluid"
1382
+ "Not a parameter: ~S" (list p) #f)))
1383
+
1384
+ (define (parameter-converter p)
1385
+ (if (parameter? p)
1386
+ (struct-ref p 2)
1387
+ (scm-error 'wrong-type-arg "parameter-fluid"
1388
+ "Not a parameter: ~S" (list p) #f)))
1389
+
1390
+ (define-syntax parameterize
1391
+ (lambda (x)
1392
+ (syntax-case x ()
1393
+ ((_ ((param value) ...) body body* ...)
1394
+ (with-syntax (((p ...) (generate-temporaries #'(param ...))))
1395
+ #'(let ((p param) ...)
1396
+ (if (not (parameter? p))
1397
+ (scm-error 'wrong-type-arg "parameterize"
1398
+ "Not a parameter: ~S" (list p) #f))
1399
+ ...
1400
+ (with-fluids (((struct-ref p 1) ((struct-ref p 2) value))
1401
+ ...)
1402
+ body body* ...)))))))
1403
+
1404
+ (define* (fluid->parameter fluid #:optional (conv (lambda (x) x)))
1405
+ "Make a parameter that wraps a fluid.
1406
+
1407
+ The value of the parameter will be the same as the value of the fluid.
1408
+ If the parameter is rebound in some dynamic extent, perhaps via
1409
+ `parameterize', the new value will be run through the optional CONV
1410
+ procedure, as with any parameter. Note that unlike `make-parameter',
1411
+ CONV is not applied to the initial value."
1412
+ (make-struct/no-tail
1413
+ <parameter>
1414
+ (case-lambda
1415
+ (() (fluid-ref fluid))
1416
+ ((x) (let ((prev (fluid-ref fluid)))
1417
+ (fluid-set! fluid (conv x))
1418
+ prev)))
1419
+ fluid conv))
1420
+
1421
+
1422
+
1423
+ ;;; Once parameters have booted, define the default prompt tag as being
1424
+ ;;; a parameter, and make allow-legacy-syntax-objects? a parameter.
1425
+ ;;;
1426
+
1427
+ (set! default-prompt-tag (make-parameter (default-prompt-tag)))
1428
+
1429
+ ;; Because code compiled with Guile 2.2.0 embeds legacy syntax objects
1430
+ ;; into its compiled macros, we have to default to true, sadly.
1431
+ (set! allow-legacy-syntax-objects? (make-parameter #t))
1432
+
1433
+
1434
+
1435
+ ;;; {Languages}
1436
+ ;;;
1437
+
1438
+ ;; The language can be a symbolic name or a <language> object from
1439
+ ;; (system base language).
1440
+ ;;
1441
+ (define current-language (make-parameter 'scheme))
1442
+
1443
+
1444
+
1445
+
1446
+ ;;; {High-Level Port Routines}
1447
+ ;;;
1448
+
1449
+ (define (call-with-output-string proc)
1450
+ "Calls the one-argument procedure @var{proc} with a newly created output
1451
+ port. When the function returns, the string composed of the characters
1452
+ written into the port is returned."
1453
+ (let ((port (open-output-string)))
1454
+ (proc port)
1455
+ (get-output-string port)))
1456
+
1457
+
1458
+
1459
+ ;;; {Booleans}
1460
+ ;;;
1461
+
1462
+ (define (->bool x) (not (not x)))
1463
+
1464
+
1465
+
1466
+ ;;; {Symbols}
1467
+ ;;;
1468
+
1469
+ (define (symbol-append . args)
1470
+ (string->symbol (apply string-append (map symbol->string args))))
1471
+
1472
+ (define (list->symbol . args)
1473
+ (string->symbol (apply list->string args)))
1474
+
1475
+ (define (symbol . args)
1476
+ (string->symbol (apply string args)))
1477
+
1478
+
1479
+
1480
+ ;;; {Lists}
1481
+ ;;;
1482
+
1483
+ (define (list-index l k)
1484
+ (let loop ((n 0)
1485
+ (l l))
1486
+ (and (not (null? l))
1487
+ (if (eq? (car l) k)
1488
+ n
1489
+ (loop (+ n 1) (cdr l))))))
1490
+
1491
+
1492
+
1493
+ ;; Load `posix.scm' even when not (provided? 'posix) so that we get the
1494
+ ;; `stat' accessors.
1495
+ (primitive-load-path "ice-9/posix")
1496
+
1497
+ (if (provided? 'socket)
1498
+ (primitive-load-path "ice-9/networking"))
1499
+
1500
+ ;; For reference, Emacs file-exists-p uses stat in this same way.
1501
+ (define file-exists?
1502
+ (if (provided? 'posix)
1503
+ (lambda (str)
1504
+ (->bool (stat str #f)))
1505
+ (lambda (str)
1506
+ (let ((port (catch 'system-error (lambda () (open-input-file str))
1507
+ (lambda args #f))))
1508
+ (if port (begin (close-port port) #t)
1509
+ #f)))))
1510
+
1511
+ (define file-is-directory?
1512
+ (if (provided? 'posix)
1513
+ (lambda (str)
1514
+ (eq? (stat:type (stat str)) 'directory))
1515
+ (lambda (str)
1516
+ (let ((port (catch 'system-error
1517
+ (lambda ()
1518
+ (open-input-file (string-append str "/.")))
1519
+ (lambda args #f))))
1520
+ (if port (begin (close-port port) #t)
1521
+ #f)))))
1522
+
1523
+ (define (system-error-errno args)
1524
+ (if (eq? (car args) 'system-error)
1525
+ (car (list-ref args 4))
1526
+ #f))
1527
+
1528
+
1529
+
1530
+ ;;; {Error Handling}
1531
+ ;;;
1532
+
1533
+ (define error
1534
+ (case-lambda
1535
+ (()
1536
+ (scm-error 'misc-error #f "?" #f #f))
1537
+ ((message . args)
1538
+ (let ((msg (string-join (cons "~A" (make-list (length args) "~S")))))
1539
+ (scm-error 'misc-error #f msg (cons message args) #f)))))
1540
+
1541
+
1542
+
1543
+ ;;; {Time Structures}
1544
+ ;;;
1545
+
1546
+ (define (tm:sec obj) (vector-ref obj 0))
1547
+ (define (tm:min obj) (vector-ref obj 1))
1548
+ (define (tm:hour obj) (vector-ref obj 2))
1549
+ (define (tm:mday obj) (vector-ref obj 3))
1550
+ (define (tm:mon obj) (vector-ref obj 4))
1551
+ (define (tm:year obj) (vector-ref obj 5))
1552
+ (define (tm:wday obj) (vector-ref obj 6))
1553
+ (define (tm:yday obj) (vector-ref obj 7))
1554
+ (define (tm:isdst obj) (vector-ref obj 8))
1555
+ (define (tm:gmtoff obj) (vector-ref obj 9))
1556
+ (define (tm:zone obj) (vector-ref obj 10))
1557
+
1558
+ (define (set-tm:sec obj val) (vector-set! obj 0 val))
1559
+ (define (set-tm:min obj val) (vector-set! obj 1 val))
1560
+ (define (set-tm:hour obj val) (vector-set! obj 2 val))
1561
+ (define (set-tm:mday obj val) (vector-set! obj 3 val))
1562
+ (define (set-tm:mon obj val) (vector-set! obj 4 val))
1563
+ (define (set-tm:year obj val) (vector-set! obj 5 val))
1564
+ (define (set-tm:wday obj val) (vector-set! obj 6 val))
1565
+ (define (set-tm:yday obj val) (vector-set! obj 7 val))
1566
+ (define (set-tm:isdst obj val) (vector-set! obj 8 val))
1567
+ (define (set-tm:gmtoff obj val) (vector-set! obj 9 val))
1568
+ (define (set-tm:zone obj val) (vector-set! obj 10 val))
1569
+
1570
+ (define (tms:clock obj) (vector-ref obj 0))
1571
+ (define (tms:utime obj) (vector-ref obj 1))
1572
+ (define (tms:stime obj) (vector-ref obj 2))
1573
+ (define (tms:cutime obj) (vector-ref obj 3))
1574
+ (define (tms:cstime obj) (vector-ref obj 4))
1575
+
1576
+
1577
+
1578
+ ;;; {C Environment}
1579
+ ;;;
1580
+
1581
+ (define (setenv name value)
1582
+ (if value
1583
+ (putenv (string-append name "=" value))
1584
+ (putenv name)))
1585
+
1586
+ (define (unsetenv name)
1587
+ "Remove the entry for NAME from the environment."
1588
+ (putenv name))
1589
+
1590
+
1591
+
1592
+ ;;; {Load Paths}
1593
+ ;;;
1594
+
1595
+ (let-syntax ((compile-time-case
1596
+ (lambda (stx)
1597
+ (syntax-case stx ()
1598
+ ((_ exp clauses ...)
1599
+ (let ((val (primitive-eval (syntax->datum #'exp))))
1600
+ (let next-clause ((clauses #'(clauses ...)))
1601
+ (syntax-case clauses (else)
1602
+ (()
1603
+ (syntax-violation 'compile-time-case
1604
+ "all clauses failed to match" stx))
1605
+ (((else form ...))
1606
+ #'(begin form ...))
1607
+ ((((k ...) form ...) clauses ...)
1608
+ (if (memv val (syntax->datum #'(k ...)))
1609
+ #'(begin form ...)
1610
+ (next-clause #'(clauses ...))))))))))))
1611
+ ;; emacs: (put 'compile-time-case 'scheme-indent-function 1)
1612
+ (compile-time-case (system-file-name-convention)
1613
+ ((posix)
1614
+ (define (file-name-separator? c)
1615
+ (char=? c #\/))
1616
+
1617
+ (define file-name-separator-string "/")
1618
+
1619
+ (define (absolute-file-name? file-name)
1620
+ (string-prefix? "/" file-name)))
1621
+
1622
+ ((windows)
1623
+ (define (file-name-separator? c)
1624
+ (or (char=? c #\/)
1625
+ (char=? c #\\)))
1626
+
1627
+ (define file-name-separator-string "/")
1628
+
1629
+ (define (absolute-file-name? file-name)
1630
+ (define (file-name-separator-at-index? idx)
1631
+ (and (> (string-length file-name) idx)
1632
+ (file-name-separator? (string-ref file-name idx))))
1633
+ (define (unc-file-name?)
1634
+ ;; Universal Naming Convention (UNC) file-names start with \\,
1635
+ ;; and are always absolute. See:
1636
+ ;; http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#fully_qualified_vs._relative_paths
1637
+ (and (file-name-separator-at-index? 0)
1638
+ (file-name-separator-at-index? 1)))
1639
+ (define (has-drive-specifier?)
1640
+ (and (>= (string-length file-name) 2)
1641
+ (let ((drive (string-ref file-name 0)))
1642
+ (or (char<=? #\a drive #\z)
1643
+ (char<=? #\A drive #\Z)))
1644
+ (eqv? (string-ref file-name 1) #\:)))
1645
+ (or (unc-file-name?)
1646
+ (if (has-drive-specifier?)
1647
+ (file-name-separator-at-index? 2)
1648
+ (file-name-separator-at-index? 0)))))))
1649
+
1650
+ (define (in-vicinity vicinity file)
1651
+ (let ((tail (let ((len (string-length vicinity)))
1652
+ (if (zero? len)
1653
+ #f
1654
+ (string-ref vicinity (- len 1))))))
1655
+ (string-append vicinity
1656
+ (if (or (not tail) (file-name-separator? tail))
1657
+ ""
1658
+ file-name-separator-string)
1659
+ file)))
1660
+
1661
+
1662
+
1663
+ ;;; {Help for scm_shell}
1664
+ ;;;
1665
+ ;;; The argument-processing code used by Guile-based shells generates
1666
+ ;;; Scheme code based on the argument list. This page contains help
1667
+ ;;; functions for the code it generates.
1668
+ ;;;
1669
+
1670
+ (define (command-line) (program-arguments))
1671
+
1672
+ ;; This is mostly for the internal use of the code generated by
1673
+ ;; scm_compile_shell_switches.
1674
+
1675
+ (define (load-user-init)
1676
+ (let* ((home (or (getenv "HOME")
1677
+ (false-if-exception (passwd:dir (getpwuid (getuid))))
1678
+ file-name-separator-string)) ;; fallback for cygwin etc.
1679
+ (init-file (in-vicinity home ".guile")))
1680
+ (if (file-exists? init-file)
1681
+ (primitive-load init-file))))
1682
+
1683
+
1684
+
1685
+ ;;; {The interpreter stack}
1686
+ ;;;
1687
+
1688
+ ;; %stacks defined in stacks.c
1689
+ (define (%start-stack tag thunk)
1690
+ (let ((prompt-tag (make-prompt-tag "start-stack")))
1691
+ (call-with-prompt
1692
+ prompt-tag
1693
+ (lambda ()
1694
+ (with-fluids ((%stacks (cons tag prompt-tag)))
1695
+ (thunk)))
1696
+ (lambda (k . args)
1697
+ (%start-stack tag (lambda () (apply k args)))))))
1698
+
1699
+ (define-syntax-rule (start-stack tag exp)
1700
+ (%start-stack tag (lambda () exp)))
1701
+
1702
+
1703
+
1704
+ ;;; {Loading by paths}
1705
+ ;;;
1706
+
1707
+ (define (load-from-path name)
1708
+ "Load a Scheme source file named NAME, searching for it in the
1709
+ directories listed in %load-path, and applying each of the file
1710
+ name extensions listed in %load-extensions."
1711
+ (start-stack 'load-stack
1712
+ (primitive-load-path name)))
1713
+
1714
+ (define-syntax-rule (add-to-load-path elt)
1715
+ "Add ELT to Guile's load path, at compile-time and at run-time."
1716
+ (eval-when (expand load eval)
1717
+ (set! %load-path (cons elt (delete elt %load-path)))))
1718
+
1719
+ (define %load-verbosely #f)
1720
+ (define (assert-load-verbosity v) (set! %load-verbosely v))
1721
+
1722
+ (define (%load-announce file)
1723
+ (if %load-verbosely
1724
+ (with-output-to-port (current-warning-port)
1725
+ (lambda ()
1726
+ (display ";;; ")
1727
+ (display "loading ")
1728
+ (display file)
1729
+ (newline)
1730
+ (force-output)))))
1731
+
1732
+ (set! %load-hook %load-announce)
1733
+
1734
+
1735
+
1736
+ ;;; {Reader Extensions}
1737
+ ;;;
1738
+ ;;; Reader code for various "#c" forms.
1739
+ ;;;
1740
+
1741
+ (define read-eval? (make-fluid #f))
1742
+ (read-hash-extend #\.
1743
+ (lambda (c port)
1744
+ (if (fluid-ref read-eval?)
1745
+ (eval (read port) (interaction-environment))
1746
+ (error
1747
+ "#. read expansion found and read-eval? is #f."))))
1748
+
1749
+
1750
+
1751
+ ;;; {Low Level Modules}
1752
+ ;;;
1753
+ ;;; These are the low level data structures for modules.
1754
+ ;;;
1755
+ ;;; Every module object is of the type 'module-type', which is a record
1756
+ ;;; consisting of the following members:
1757
+ ;;;
1758
+ ;;; - eval-closure: A deprecated field, to be removed in Guile 2.2.
1759
+ ;;;
1760
+ ;;; - obarray: a hash table that maps symbols to variable objects. In this
1761
+ ;;; hash table, the definitions are found that are local to the module (that
1762
+ ;;; is, not imported from other modules). When looking up bindings in the
1763
+ ;;; module, this hash table is searched first.
1764
+ ;;;
1765
+ ;;; - binder: either #f or a function taking a module and a symbol argument.
1766
+ ;;; If it is a function it is called after the obarray has been
1767
+ ;;; unsuccessfully searched for a binding. It then can provide bindings
1768
+ ;;; that would otherwise not be found locally in the module.
1769
+ ;;;
1770
+ ;;; - uses: a list of modules from which non-local bindings can be inherited.
1771
+ ;;; These modules are the third place queried for bindings after the obarray
1772
+ ;;; has been unsuccessfully searched and the binder function did not deliver
1773
+ ;;; a result either.
1774
+ ;;;
1775
+ ;;; - transformer: either #f or a function taking a scheme expression as
1776
+ ;;; delivered by read. If it is a function, it will be called to perform
1777
+ ;;; syntax transformations (e. g. makro expansion) on the given scheme
1778
+ ;;; expression. The output of the transformer function will then be passed
1779
+ ;;; to Guile's internal memoizer. This means that the output must be valid
1780
+ ;;; scheme code. The only exception is, that the output may make use of the
1781
+ ;;; syntax extensions provided to identify the modules that a binding
1782
+ ;;; belongs to.
1783
+ ;;;
1784
+ ;;; - name: the name of the module. This is used for all kinds of printing
1785
+ ;;; outputs. In certain places the module name also serves as a way of
1786
+ ;;; identification. When adding a module to the uses list of another
1787
+ ;;; module, it is made sure that the new uses list will not contain two
1788
+ ;;; modules of the same name.
1789
+ ;;;
1790
+ ;;; - kind: classification of the kind of module. The value is (currently?)
1791
+ ;;; only used for printing. It has no influence on how a module is treated.
1792
+ ;;; Currently the following values are used when setting the module kind:
1793
+ ;;; 'module, 'directory, 'interface, 'custom-interface. If no explicit kind
1794
+ ;;; is set, it defaults to 'module.
1795
+ ;;;
1796
+ ;;; - duplicates-handlers: a list of procedures that get called to make a
1797
+ ;;; choice between two duplicate bindings when name clashes occur. See the
1798
+ ;;; `duplicate-handlers' global variable below.
1799
+ ;;;
1800
+ ;;; - observers: a list of procedures that get called when the module is
1801
+ ;;; modified.
1802
+ ;;;
1803
+ ;;; - weak-observers: a weak-key hash table of procedures that get called
1804
+ ;;; when the module is modified. See `module-observe-weak' for details.
1805
+ ;;;
1806
+ ;;; In addition, the module may (must?) contain a binding for
1807
+ ;;; `%module-public-interface'. This variable should be bound to a module
1808
+ ;;; representing the exported interface of a module. See the
1809
+ ;;; `module-public-interface' and `module-export!' procedures.
1810
+ ;;;
1811
+ ;;; !!! warning: The interface to lazy binder procedures is going
1812
+ ;;; to be changed in an incompatible way to permit all the basic
1813
+ ;;; module ops to be virtualized.
1814
+ ;;;
1815
+ ;;; (make-module size use-list lazy-binding-proc) => module
1816
+ ;;; module-{obarray,uses,binder}[|-set!]
1817
+ ;;; (module? obj) => [#t|#f]
1818
+ ;;; (module-locally-bound? module symbol) => [#t|#f]
1819
+ ;;; (module-bound? module symbol) => [#t|#f]
1820
+ ;;; (module-symbol-locally-interned? module symbol) => [#t|#f]
1821
+ ;;; (module-symbol-interned? module symbol) => [#t|#f]
1822
+ ;;; (module-local-variable module symbol) => [#<variable ...> | #f]
1823
+ ;;; (module-variable module symbol) => [#<variable ...> | #f]
1824
+ ;;; (module-symbol-binding module symbol opt-value)
1825
+ ;;; => [ <obj> | opt-value | an error occurs ]
1826
+ ;;; (module-make-local-var! module symbol) => #<variable...>
1827
+ ;;; (module-add! module symbol var) => unspecified
1828
+ ;;; (module-remove! module symbol) => unspecified
1829
+ ;;; (module-for-each proc module) => unspecified
1830
+ ;;; (make-scm-module) => module ; a lazy copy of the symhash module
1831
+ ;;; (set-current-module module) => unspecified
1832
+ ;;; (current-module) => #<module...>
1833
+ ;;;
1834
+ ;;;
1835
+
1836
+
1837
+
1838
+ ;;; {Printing Modules}
1839
+ ;;;
1840
+
1841
+ ;; This is how modules are printed. You can re-define it.
1842
+ (define (%print-module mod port)
1843
+ (display "#<" port)
1844
+ (display (or (module-kind mod) "module") port)
1845
+ (display " " port)
1846
+ (display (module-name mod) port)
1847
+ (display " " port)
1848
+ (display (number->string (object-address mod) 16) port)
1849
+ (display ">" port))
1850
+
1851
+ (letrec-syntax
1852
+ ;; Locally extend the syntax to allow record accessors to be defined at
1853
+ ;; compile-time. Cache the rtd locally to the constructor, the getters and
1854
+ ;; the setters, in order to allow for redefinition of the record type; not
1855
+ ;; relevant in the case of modules, but perhaps if we make this public, it
1856
+ ;; could matter.
1857
+
1858
+ ((define-record-type
1859
+ (lambda (x)
1860
+ (define (make-id scope . fragments)
1861
+ (datum->syntax scope
1862
+ (apply symbol-append
1863
+ (map (lambda (x)
1864
+ (if (symbol? x) x (syntax->datum x)))
1865
+ fragments))))
1866
+
1867
+ (define (getter rtd type-name field slot)
1868
+ #`(define #,(make-id rtd type-name '- field)
1869
+ (let ((rtd #,rtd))
1870
+ (lambda (#,type-name)
1871
+ (if (eq? (struct-vtable #,type-name) rtd)
1872
+ (struct-ref #,type-name #,slot)
1873
+ (%record-type-error rtd #,type-name))))))
1874
+
1875
+ (define (setter rtd type-name field slot)
1876
+ #`(define #,(make-id rtd 'set- type-name '- field '!)
1877
+ (let ((rtd #,rtd))
1878
+ (lambda (#,type-name val)
1879
+ (if (eq? (struct-vtable #,type-name) rtd)
1880
+ (struct-set! #,type-name #,slot val)
1881
+ (%record-type-error rtd #,type-name))))))
1882
+
1883
+ (define (accessors rtd type-name fields n exp)
1884
+ (syntax-case fields ()
1885
+ (() exp)
1886
+ (((field #:no-accessors) field* ...) (identifier? #'field)
1887
+ (accessors rtd type-name #'(field* ...) (1+ n)
1888
+ exp))
1889
+ (((field #:no-setter) field* ...) (identifier? #'field)
1890
+ (accessors rtd type-name #'(field* ...) (1+ n)
1891
+ #`(begin #,exp
1892
+ #,(getter rtd type-name #'field n))))
1893
+ (((field #:no-getter) field* ...) (identifier? #'field)
1894
+ (accessors rtd type-name #'(field* ...) (1+ n)
1895
+ #`(begin #,exp
1896
+ #,(setter rtd type-name #'field n))))
1897
+ ((field field* ...) (identifier? #'field)
1898
+ (accessors rtd type-name #'(field* ...) (1+ n)
1899
+ #`(begin #,exp
1900
+ #,(getter rtd type-name #'field n)
1901
+ #,(setter rtd type-name #'field n))))))
1902
+
1903
+ (define (predicate rtd type-name fields exp)
1904
+ (accessors
1905
+ rtd type-name fields 0
1906
+ #`(begin
1907
+ #,exp
1908
+ (define (#,(make-id rtd type-name '?) obj)
1909
+ (and (struct? obj) (eq? (struct-vtable obj) #,rtd))))))
1910
+
1911
+ (define (field-list fields)
1912
+ (syntax-case fields ()
1913
+ (() '())
1914
+ (((f . opts) . rest) (identifier? #'f)
1915
+ (cons #'f (field-list #'rest)))
1916
+ ((f . rest) (identifier? #'f)
1917
+ (cons #'f (field-list #'rest)))))
1918
+
1919
+ (define (constructor rtd type-name fields exp)
1920
+ (let* ((ctor (make-id rtd type-name '-constructor))
1921
+ (args (field-list fields))
1922
+ (n (length fields))
1923
+ (slots (iota n)))
1924
+ (predicate rtd type-name fields
1925
+ #`(begin #,exp
1926
+ (define #,ctor
1927
+ (let ((rtd #,rtd))
1928
+ (lambda #,args
1929
+ (let ((s (allocate-struct rtd #,n)))
1930
+ #,@(map
1931
+ (lambda (arg slot)
1932
+ #`(struct-set! s #,slot #,arg))
1933
+ args slots)
1934
+ s))))
1935
+ (struct-set! #,rtd (+ vtable-offset-user 2)
1936
+ #,ctor)))))
1937
+
1938
+ (define (type type-name printer fields)
1939
+ (define (make-layout)
1940
+ (let lp ((fields fields) (slots '()))
1941
+ (syntax-case fields ()
1942
+ (() (datum->syntax #'here
1943
+ (make-struct-layout
1944
+ (apply string-append slots))))
1945
+ ((_ . rest) (lp #'rest (cons "pw" slots))))))
1946
+
1947
+ (let ((rtd (make-id type-name type-name '-type)))
1948
+ (constructor rtd type-name fields
1949
+ #`(begin
1950
+ (define #,rtd
1951
+ (make-struct/no-tail
1952
+ record-type-vtable
1953
+ '#,(make-layout)
1954
+ #,printer
1955
+ '#,type-name
1956
+ '#,(field-list fields)))
1957
+ (set-struct-vtable-name! #,rtd '#,type-name)))))
1958
+
1959
+ (syntax-case x ()
1960
+ ((_ type-name printer (field ...))
1961
+ (type #'type-name #'printer #'(field ...)))))))
1962
+
1963
+ ;; module-type
1964
+ ;;
1965
+ ;; A module is characterized by an obarray in which local symbols
1966
+ ;; are interned, a list of modules, "uses", from which non-local
1967
+ ;; bindings can be inherited, and an optional lazy-binder which
1968
+ ;; is a (CLOSURE module symbol) which, as a last resort, can provide
1969
+ ;; bindings that would otherwise not be found locally in the module.
1970
+ ;;
1971
+ ;; NOTE: If you change the set of fields or their order, you also need to
1972
+ ;; change the constants in libguile/modules.h.
1973
+ ;;
1974
+ ;; NOTE: The getter `module-transformer' is defined libguile/modules.c.
1975
+ ;; NOTE: The getter `module-name' is defined later, due to boot reasons.
1976
+ ;; NOTE: The getter `module-public-interface' is used in libguile/modules.c.
1977
+ ;;
1978
+ (define-record-type module
1979
+ (lambda (obj port) (%print-module obj port))
1980
+ (obarray
1981
+ uses
1982
+ binder
1983
+ eval-closure
1984
+ (transformer #:no-getter)
1985
+ (name #:no-getter)
1986
+ kind
1987
+ duplicates-handlers
1988
+ (import-obarray #:no-setter)
1989
+ observers
1990
+ (weak-observers #:no-setter)
1991
+ version
1992
+ submodules
1993
+ submodule-binder
1994
+ public-interface
1995
+ filename
1996
+ next-unique-id)))
1997
+
1998
+
1999
+ ;; make-module &opt size uses binder
2000
+ ;;
2001
+ (define* (make-module #:optional (size 31) (uses '()) (binder #f))
2002
+ "Create a new module, perhaps with a particular size of obarray,
2003
+ initial uses list, or binding procedure."
2004
+ (if (not (integer? size))
2005
+ (error "Illegal size to make-module." size))
2006
+ (if (not (and (list? uses)
2007
+ (and-map module? uses)))
2008
+ (error "Incorrect use list." uses))
2009
+ (if (and binder (not (procedure? binder)))
2010
+ (error
2011
+ "Lazy-binder expected to be a procedure or #f." binder))
2012
+
2013
+ (module-constructor (make-hash-table size)
2014
+ uses binder #f macroexpand
2015
+ #f #f #f
2016
+ (make-hash-table)
2017
+ '()
2018
+ (make-weak-key-hash-table 31) #f
2019
+ (make-hash-table 7) #f #f #f 0))
2020
+
2021
+
2022
+
2023
+
2024
+ ;;; {Observer protocol}
2025
+ ;;;
2026
+
2027
+ (define (module-observe module proc)
2028
+ (set-module-observers! module (cons proc (module-observers module)))
2029
+ (cons module proc))
2030
+
2031
+ (define* (module-observe-weak module observer-id #:optional (proc observer-id))
2032
+ "Register PROC as an observer of MODULE under name OBSERVER-ID (which can
2033
+ be any Scheme object). PROC is invoked and passed MODULE any time
2034
+ MODULE is modified. PROC gets unregistered when OBSERVER-ID gets GC'd
2035
+ (thus, it is never unregistered if OBSERVER-ID is an immediate value,
2036
+ for instance).
2037
+
2038
+ The two-argument version is kept for backward compatibility: when called
2039
+ with two arguments, the observer gets unregistered when closure PROC
2040
+ gets GC'd (making it impossible to use an anonymous lambda for PROC)."
2041
+ (hashq-set! (module-weak-observers module) observer-id proc))
2042
+
2043
+ (define (module-unobserve token)
2044
+ (let ((module (car token))
2045
+ (id (cdr token)))
2046
+ (if (integer? id)
2047
+ (hash-remove! (module-weak-observers module) id)
2048
+ (set-module-observers! module (delq1! id (module-observers module)))))
2049
+ *unspecified*)
2050
+
2051
+ ;; Hash table of module -> #t indicating modules that changed while
2052
+ ;; observers were deferred, or #f if observers are not being deferred.
2053
+ (define module-defer-observers (make-parameter #f))
2054
+
2055
+ (define (module-modified m)
2056
+ (cond
2057
+ ((module-defer-observers) => (lambda (tab) (hashq-set! tab m #t)))
2058
+ (else (module-call-observers m))))
2059
+
2060
+ ;;; This function can be used to delay calls to observers so that they
2061
+ ;;; can be called once only in the face of massive updating of modules.
2062
+ ;;;
2063
+ (define (call-with-deferred-observers thunk)
2064
+ (cond
2065
+ ((module-defer-observers) (thunk))
2066
+ (else
2067
+ (let ((modules (make-hash-table)))
2068
+ (dynamic-wind (lambda () #t)
2069
+ (lambda ()
2070
+ (parameterize ((module-defer-observers modules))
2071
+ (thunk)))
2072
+ (lambda ()
2073
+ (let ((changed (hash-map->list cons modules)))
2074
+ (hash-clear! modules)
2075
+ (for-each (lambda (pair)
2076
+ (module-call-observers (car pair)))
2077
+ changed))))))))
2078
+
2079
+ (define (module-call-observers m)
2080
+ (for-each (lambda (proc) (proc m)) (module-observers m))
2081
+
2082
+ ;; We assume that weak observers don't (un)register themselves as they are
2083
+ ;; called since this would preclude proper iteration over the hash table
2084
+ ;; elements.
2085
+ (hash-for-each (lambda (id proc) (proc m)) (module-weak-observers m)))
2086
+
2087
+
2088
+
2089
+ ;;; {Module Searching in General}
2090
+ ;;;
2091
+ ;;; We sometimes want to look for properties of a symbol
2092
+ ;;; just within the obarray of one module. If the property
2093
+ ;;; holds, then it is said to hold ``locally'' as in, ``The symbol
2094
+ ;;; DISPLAY is locally rebound in the module `safe-guile'.''
2095
+ ;;;
2096
+ ;;;
2097
+ ;;; Other times, we want to test for a symbol property in the obarray
2098
+ ;;; of M and, if it is not found there, try each of the modules in the
2099
+ ;;; uses list of M. This is the normal way of testing for some
2100
+ ;;; property, so we state these properties without qualification as
2101
+ ;;; in: ``The symbol 'fnord is interned in module M because it is
2102
+ ;;; interned locally in module M2 which is a member of the uses list
2103
+ ;;; of M.''
2104
+ ;;;
2105
+
2106
+ (define (module-search fn m v)
2107
+ "Return the first non-#f result of FN applied to M and then to
2108
+ the modules in the uses of M, and so on recursively. If all applications
2109
+ return #f, then so does this function."
2110
+ (define (loop pos)
2111
+ (and (pair? pos)
2112
+ (or (module-search fn (car pos) v)
2113
+ (loop (cdr pos)))))
2114
+ (or (fn m v)
2115
+ (loop (module-uses m))))
2116
+
2117
+
2118
+ ;;; {Is a symbol bound in a module?}
2119
+ ;;;
2120
+ ;;; Symbol S in Module M is bound if S is interned in M and if the binding
2121
+ ;;; of S in M has been set to some well-defined value.
2122
+ ;;;
2123
+
2124
+ (define (module-locally-bound? m v)
2125
+ "Is symbol V bound (interned and defined) locally in module M?"
2126
+ (let ((var (module-local-variable m v)))
2127
+ (and var
2128
+ (variable-bound? var))))
2129
+
2130
+ (define (module-bound? m v)
2131
+ "Is symbol V bound (interned and defined) anywhere in module M or its
2132
+ uses?"
2133
+ (let ((var (module-variable m v)))
2134
+ (and var
2135
+ (variable-bound? var))))
2136
+
2137
+ ;;; {Is a symbol interned in a module?}
2138
+ ;;;
2139
+ ;;; Symbol S in Module M is interned if S occurs in
2140
+ ;;; of S in M has been set to some well-defined value.
2141
+ ;;;
2142
+ ;;; It is possible to intern a symbol in a module without providing
2143
+ ;;; an initial binding for the corresponding variable. This is done
2144
+ ;;; with:
2145
+ ;;; (module-add! module symbol (make-undefined-variable))
2146
+ ;;;
2147
+ ;;; In that case, the symbol is interned in the module, but not
2148
+ ;;; bound there. The unbound symbol shadows any binding for that
2149
+ ;;; symbol that might otherwise be inherited from a member of the uses list.
2150
+ ;;;
2151
+
2152
+ (define (module-obarray-get-handle ob key)
2153
+ ((if (symbol? key) hashq-get-handle hash-get-handle) ob key))
2154
+
2155
+ (define (module-obarray-ref ob key)
2156
+ ((if (symbol? key) hashq-ref hash-ref) ob key))
2157
+
2158
+ (define (module-obarray-set! ob key val)
2159
+ ((if (symbol? key) hashq-set! hash-set!) ob key val))
2160
+
2161
+ (define (module-obarray-remove! ob key)
2162
+ ((if (symbol? key) hashq-remove! hash-remove!) ob key))
2163
+
2164
+ (define (module-symbol-locally-interned? m v)
2165
+ "Is symbol V interned (not neccessarily defined) locally in module M
2166
+ or its uses? Interned symbols shadow inherited bindings even if they
2167
+ are not themselves bound to a defined value."
2168
+ (not (not (module-obarray-get-handle (module-obarray m) v))))
2169
+
2170
+ (define (module-symbol-interned? m v)
2171
+ "Is symbol V interned (not neccessarily defined) anywhere in module M
2172
+ or its uses? Interned symbols shadow inherited bindings even if they
2173
+ are not themselves bound to a defined value."
2174
+ (module-search module-symbol-locally-interned? m v))
2175
+
2176
+
2177
+ ;;; {Mapping modules x symbols --> variables}
2178
+ ;;;
2179
+
2180
+ ;; module-local-variable module symbol
2181
+ ;; return the local variable associated with a MODULE and SYMBOL.
2182
+ ;;
2183
+ ;;; This function is very important. It is the only function that can
2184
+ ;;; return a variable from a module other than the mutators that store
2185
+ ;;; new variables in modules. Therefore, this function is the location
2186
+ ;;; of the "lazy binder" hack.
2187
+ ;;;
2188
+ ;;; If symbol is defined in MODULE, and if the definition binds symbol
2189
+ ;;; to a variable, return that variable object.
2190
+ ;;;
2191
+ ;;; If the symbols is not found at first, but the module has a lazy binder,
2192
+ ;;; then try the binder.
2193
+ ;;;
2194
+ ;;; If the symbol is not found at all, return #f.
2195
+ ;;;
2196
+ ;;; (This is now written in C, see `modules.c'.)
2197
+ ;;;
2198
+
2199
+ ;;; {Mapping modules x symbols --> bindings}
2200
+ ;;;
2201
+ ;;; These are similar to the mapping to variables, except that the
2202
+ ;;; variable is dereferenced.
2203
+ ;;;
2204
+
2205
+ (define (module-symbol-local-binding m v . opt-val)
2206
+ "Return the binding of variable V specified by name within module M,
2207
+ signalling an error if the variable is unbound. If the OPT-VALUE is
2208
+ passed, then instead of signalling an error, return OPT-VALUE."
2209
+ (let ((var (module-local-variable m v)))
2210
+ (if (and var (variable-bound? var))
2211
+ (variable-ref var)
2212
+ (if (not (null? opt-val))
2213
+ (car opt-val)
2214
+ (error "Locally unbound variable." v)))))
2215
+
2216
+ (define (module-symbol-binding m v . opt-val)
2217
+ "Return the binding of variable V specified by name within module M,
2218
+ signalling an error if the variable is unbound. If the OPT-VALUE is
2219
+ passed, then instead of signalling an error, return OPT-VALUE."
2220
+ (let ((var (module-variable m v)))
2221
+ (if (and var (variable-bound? var))
2222
+ (variable-ref var)
2223
+ (if (not (null? opt-val))
2224
+ (car opt-val)
2225
+ (error "Unbound variable." v)))))
2226
+
2227
+
2228
+
2229
+
2230
+ ;;; {Adding Variables to Modules}
2231
+ ;;;
2232
+
2233
+ ;; This function is used in modules.c.
2234
+ ;;
2235
+ (define (module-make-local-var! m v)
2236
+ "Ensure a variable for V in the local namespace of M.
2237
+ If no variable was already there, then create a new and uninitialized
2238
+ variable."
2239
+ (or (let ((b (module-obarray-ref (module-obarray m) v)))
2240
+ (and (variable? b)
2241
+ (begin
2242
+ ;; Mark as modified since this function is called when
2243
+ ;; the standard eval closure defines a binding
2244
+ (module-modified m)
2245
+ b)))
2246
+
2247
+ ;; Create a new local variable.
2248
+ (let ((local-var (make-undefined-variable)))
2249
+ (module-add! m v local-var)
2250
+ local-var)))
2251
+
2252
+ (define (module-ensure-local-variable! module symbol)
2253
+ "Ensure that there is a local variable in MODULE for SYMBOL. If
2254
+ there is no binding for SYMBOL, create a new uninitialized
2255
+ variable. Return the local variable."
2256
+ (or (module-local-variable module symbol)
2257
+ (let ((var (make-undefined-variable)))
2258
+ (module-add! module symbol var)
2259
+ var)))
2260
+
2261
+ ;; module-add! module symbol var
2262
+ ;;
2263
+ (define (module-add! m v var)
2264
+ "Ensure a particular variable for V in the local namespace of M."
2265
+ (if (not (variable? var))
2266
+ (error "Bad variable to module-add!" var))
2267
+ (if (not (symbol? v))
2268
+ (error "Bad symbol to module-add!" v))
2269
+ (module-obarray-set! (module-obarray m) v var)
2270
+ (module-modified m))
2271
+
2272
+ (define (module-remove! m v)
2273
+ "Make sure that symbol V is undefined in the local namespace of M."
2274
+ (module-obarray-remove! (module-obarray m) v)
2275
+ (module-modified m))
2276
+
2277
+ (define (module-clear! m)
2278
+ (hash-clear! (module-obarray m))
2279
+ (module-modified m))
2280
+
2281
+ ;; MODULE-FOR-EACH -- exported
2282
+ ;;
2283
+ (define (module-for-each proc module)
2284
+ "Call PROC on each symbol in MODULE, with arguments of (SYMBOL VARIABLE)."
2285
+ (hash-for-each proc (module-obarray module)))
2286
+
2287
+ (define (module-map proc module)
2288
+ (hash-map->list proc (module-obarray module)))
2289
+
2290
+ ;; Submodules
2291
+ ;;
2292
+ ;; Modules exist in a separate namespace from values, because you generally do
2293
+ ;; not want the name of a submodule, which you might not even use, to collide
2294
+ ;; with local variables that happen to be named the same as the submodule.
2295
+ ;;
2296
+ (define (module-ref-submodule module name)
2297
+ (or (hashq-ref (module-submodules module) name)
2298
+ (and (module-submodule-binder module)
2299
+ ((module-submodule-binder module) module name))))
2300
+
2301
+ (define (module-define-submodule! module name submodule)
2302
+ (hashq-set! (module-submodules module) name submodule))
2303
+
2304
+
2305
+
2306
+ ;;; {Module-based Loading}
2307
+ ;;;
2308
+
2309
+ (define (save-module-excursion thunk)
2310
+ (let ((inner-module (current-module))
2311
+ (outer-module #f))
2312
+ (dynamic-wind (lambda ()
2313
+ (set! outer-module (current-module))
2314
+ (set-current-module inner-module)
2315
+ (set! inner-module #f))
2316
+ thunk
2317
+ (lambda ()
2318
+ (set! inner-module (current-module))
2319
+ (set-current-module outer-module)
2320
+ (set! outer-module #f)))))
2321
+
2322
+
2323
+
2324
+ ;;; {MODULE-REF -- exported}
2325
+ ;;;
2326
+ (define (module-ref module name . rest)
2327
+ "Returns the value of a variable called NAME in MODULE or any of its
2328
+ used modules. If there is no such variable, then if the optional third
2329
+ argument DEFAULT is present, it is returned; otherwise an error is signaled."
2330
+ (let ((variable (module-variable module name)))
2331
+ (if (and variable (variable-bound? variable))
2332
+ (variable-ref variable)
2333
+ (if (null? rest)
2334
+ (error "No variable named" name 'in module)
2335
+ (car rest) ; default value
2336
+ ))))
2337
+
2338
+ ;; MODULE-SET! -- exported
2339
+ ;;
2340
+ (define (module-set! module name value)
2341
+ "Sets the variable called NAME in MODULE (or in a module that MODULE uses)
2342
+ to VALUE; if there is no such variable, an error is signaled."
2343
+ (let ((variable (module-variable module name)))
2344
+ (if variable
2345
+ (variable-set! variable value)
2346
+ (error "No variable named" name 'in module))))
2347
+
2348
+ ;; MODULE-DEFINE! -- exported
2349
+ ;;
2350
+ (define (module-define! module name value)
2351
+ "Sets the variable called NAME in MODULE to VALUE; if there is no such
2352
+ variable, it is added first."
2353
+ (let ((variable (module-local-variable module name)))
2354
+ (if variable
2355
+ (begin
2356
+ (variable-set! variable value)
2357
+ (module-modified module))
2358
+ (let ((variable (make-variable value)))
2359
+ (module-add! module name variable)))))
2360
+
2361
+ ;; MODULE-DEFINED? -- exported
2362
+ ;;
2363
+ (define (module-defined? module name)
2364
+ "Return #t iff NAME is defined in MODULE (or in a module that MODULE
2365
+ uses)."
2366
+ (let ((variable (module-variable module name)))
2367
+ (and variable (variable-bound? variable))))
2368
+
2369
+ (define (module-use! module interface)
2370
+ "Add INTERFACE to the list of interfaces used by MODULE."
2371
+ (if (not (or (eq? module interface)
2372
+ (memq interface (module-uses module))))
2373
+ (begin
2374
+ ;; Newly used modules must be appended rather than consed, so that
2375
+ ;; `module-variable' traverses the use list starting from the first
2376
+ ;; used module.
2377
+ (set-module-uses! module (append (module-uses module)
2378
+ (list interface)))
2379
+ (hash-clear! (module-import-obarray module))
2380
+ (module-modified module))))
2381
+
2382
+ (define (module-use-interfaces! module interfaces)
2383
+ "Same as MODULE-USE!, but only notifies module observers after all
2384
+ interfaces are added to the inports list."
2385
+ (let* ((cur (module-uses module))
2386
+ (new (let lp ((in interfaces) (out '()))
2387
+ (if (null? in)
2388
+ (reverse out)
2389
+ (lp (cdr in)
2390
+ (let ((iface (car in)))
2391
+ (if (or (memq iface cur) (memq iface out))
2392
+ out
2393
+ (cons iface out))))))))
2394
+ (set-module-uses! module (append cur new))
2395
+ (hash-clear! (module-import-obarray module))
2396
+ (module-modified module)))
2397
+
2398
+
2399
+
2400
+ ;;; {Recursive Namespaces}
2401
+ ;;;
2402
+ ;;; A hierarchical namespace emerges if we consider some module to be
2403
+ ;;; root, and submodules of that module to be nested namespaces.
2404
+ ;;;
2405
+ ;;; The routines here manage variable names in hierarchical namespace.
2406
+ ;;; Each variable name is a list of elements, looked up in successively nested
2407
+ ;;; modules.
2408
+ ;;;
2409
+ ;;; (nested-ref some-root-module '(foo bar baz))
2410
+ ;;; => <value of a variable named baz in the submodule bar of
2411
+ ;;; the submodule foo of some-root-module>
2412
+ ;;;
2413
+ ;;;
2414
+ ;;; There are:
2415
+ ;;;
2416
+ ;;; ;; a-root is a module
2417
+ ;;; ;; name is a list of symbols
2418
+ ;;;
2419
+ ;;; nested-ref a-root name
2420
+ ;;; nested-set! a-root name val
2421
+ ;;; nested-define! a-root name val
2422
+ ;;; nested-remove! a-root name
2423
+ ;;;
2424
+ ;;; These functions manipulate values in namespaces. For referencing the
2425
+ ;;; namespaces themselves, use the following:
2426
+ ;;;
2427
+ ;;; nested-ref-module a-root name
2428
+ ;;; nested-define-module! a-root name mod
2429
+ ;;;
2430
+ ;;; (current-module) is a natural choice for a root so for convenience there are
2431
+ ;;; also:
2432
+ ;;;
2433
+ ;;; local-ref name == nested-ref (current-module) name
2434
+ ;;; local-set! name val == nested-set! (current-module) name val
2435
+ ;;; local-define name val == nested-define! (current-module) name val
2436
+ ;;; local-remove name == nested-remove! (current-module) name
2437
+ ;;; local-ref-module name == nested-ref-module (current-module) name
2438
+ ;;; local-define-module! name m == nested-define-module! (current-module) name m
2439
+ ;;;
2440
+
2441
+
2442
+ (define (nested-ref root names)
2443
+ (if (null? names)
2444
+ root
2445
+ (let loop ((cur root)
2446
+ (head (car names))
2447
+ (tail (cdr names)))
2448
+ (if (null? tail)
2449
+ (module-ref cur head #f)
2450
+ (let ((cur (module-ref-submodule cur head)))
2451
+ (and cur
2452
+ (loop cur (car tail) (cdr tail))))))))
2453
+
2454
+ (define (nested-set! root names val)
2455
+ (let loop ((cur root)
2456
+ (head (car names))
2457
+ (tail (cdr names)))
2458
+ (if (null? tail)
2459
+ (module-set! cur head val)
2460
+ (let ((cur (module-ref-submodule cur head)))
2461
+ (if (not cur)
2462
+ (error "failed to resolve module" names)
2463
+ (loop cur (car tail) (cdr tail)))))))
2464
+
2465
+ (define (nested-define! root names val)
2466
+ (let loop ((cur root)
2467
+ (head (car names))
2468
+ (tail (cdr names)))
2469
+ (if (null? tail)
2470
+ (module-define! cur head val)
2471
+ (let ((cur (module-ref-submodule cur head)))
2472
+ (if (not cur)
2473
+ (error "failed to resolve module" names)
2474
+ (loop cur (car tail) (cdr tail)))))))
2475
+
2476
+ (define (nested-remove! root names)
2477
+ (let loop ((cur root)
2478
+ (head (car names))
2479
+ (tail (cdr names)))
2480
+ (if (null? tail)
2481
+ (module-remove! cur head)
2482
+ (let ((cur (module-ref-submodule cur head)))
2483
+ (if (not cur)
2484
+ (error "failed to resolve module" names)
2485
+ (loop cur (car tail) (cdr tail)))))))
2486
+
2487
+
2488
+ (define (nested-ref-module root names)
2489
+ (let loop ((cur root)
2490
+ (names names))
2491
+ (if (null? names)
2492
+ cur
2493
+ (let ((cur (module-ref-submodule cur (car names))))
2494
+ (and cur
2495
+ (loop cur (cdr names)))))))
2496
+
2497
+ (define (nested-define-module! root names module)
2498
+ (if (null? names)
2499
+ (error "can't redefine root module" root module)
2500
+ (let loop ((cur root)
2501
+ (head (car names))
2502
+ (tail (cdr names)))
2503
+ (if (null? tail)
2504
+ (module-define-submodule! cur head module)
2505
+ (let ((cur (or (module-ref-submodule cur head)
2506
+ (let ((m (make-module 31)))
2507
+ (set-module-kind! m 'directory)
2508
+ (set-module-name! m (append (module-name cur)
2509
+ (list head)))
2510
+ (module-define-submodule! cur head m)
2511
+ m))))
2512
+ (loop cur (car tail) (cdr tail)))))))
2513
+
2514
+
2515
+ (define (local-ref names)
2516
+ (nested-ref (current-module) names))
2517
+
2518
+ (define (local-set! names val)
2519
+ (nested-set! (current-module) names val))
2520
+
2521
+ (define (local-define names val)
2522
+ (nested-define! (current-module) names val))
2523
+
2524
+ (define (local-remove names)
2525
+ (nested-remove! (current-module) names))
2526
+
2527
+ (define (local-ref-module names)
2528
+ (nested-ref-module (current-module) names))
2529
+
2530
+ (define (local-define-module names mod)
2531
+ (nested-define-module! (current-module) names mod))
2532
+
2533
+
2534
+
2535
+
2536
+
2537
+ ;;; {The (guile) module}
2538
+ ;;;
2539
+ ;;; The standard module, which has the core Guile bindings. Also called the
2540
+ ;;; "root module", as it is imported by many other modules, but it is not
2541
+ ;;; necessarily the root of anything; and indeed, the module named '() might be
2542
+ ;;; better thought of as a root.
2543
+ ;;;
2544
+
2545
+ ;; The root module uses the pre-modules-obarray as its obarray. This
2546
+ ;; special obarray accumulates all bindings that have been established
2547
+ ;; before the module system is fully booted.
2548
+ ;;
2549
+ ;; (The obarray continues to be used by code that has been closed over
2550
+ ;; before the module system has been booted.)
2551
+ ;;
2552
+ (define the-root-module
2553
+ (let ((m (make-module 0)))
2554
+ (set-module-obarray! m (%get-pre-modules-obarray))
2555
+ (set-module-name! m '(guile))
2556
+
2557
+ ;; Inherit next-unique-id from preliminary stub of
2558
+ ;; %module-get-next-unique-id! defined above.
2559
+ (set-module-next-unique-id! m (module-generate-unique-id! #f))
2560
+
2561
+ m))
2562
+
2563
+ ;; The root interface is a module that uses the same obarray as the
2564
+ ;; root module. It does not allow new definitions, tho.
2565
+ ;;
2566
+ (define the-scm-module
2567
+ (let ((m (make-module 0)))
2568
+ (set-module-obarray! m (%get-pre-modules-obarray))
2569
+ (set-module-name! m '(guile))
2570
+ (set-module-kind! m 'interface)
2571
+
2572
+ ;; In Guile 1.8 and earlier M was its own public interface.
2573
+ (set-module-public-interface! m m)
2574
+
2575
+ m))
2576
+
2577
+ (set-module-public-interface! the-root-module the-scm-module)
2578
+
2579
+
2580
+
2581
+ ;; Now that we have a root module, even though modules aren't fully booted,
2582
+ ;; expand the definition of resolve-module.
2583
+ ;;
2584
+ (define (resolve-module name . args)
2585
+ (if (equal? name '(guile))
2586
+ the-root-module
2587
+ (error "unexpected module to resolve during module boot" name)))
2588
+
2589
+ (define (module-generate-unique-id! m)
2590
+ (let ((i (module-next-unique-id m)))
2591
+ (set-module-next-unique-id! m (+ i 1))
2592
+ i))
2593
+
2594
+ ;; Cheat. These bindings are needed by modules.c, but we don't want
2595
+ ;; to move their real definition here because that would be unnatural.
2596
+ ;;
2597
+ (define define-module* #f)
2598
+ (define process-use-modules #f)
2599
+ (define module-export! #f)
2600
+ (define default-duplicate-binding-procedures #f)
2601
+
2602
+ ;; This boots the module system. All bindings needed by modules.c
2603
+ ;; must have been defined by now.
2604
+ ;;
2605
+ (set-current-module the-root-module)
2606
+
2607
+
2608
+
2609
+
2610
+ (define (call-with-module-autoload-lock thunk)
2611
+ ;; This binding is overridden when (ice-9 threads) is available to
2612
+ ;; implement a critical section around the call to THUNK. It must be
2613
+ ;; used anytime 'autoloads-done' and related variables are accessed
2614
+ ;; and whenever submodules are accessed (via the 'nested-'
2615
+ ;; procedures.)
2616
+ (thunk))
2617
+
2618
+ ;; Now that modules are booted, give module-name its final definition.
2619
+ ;;
2620
+ (define module-name
2621
+ (let ((accessor (record-accessor module-type 'name)))
2622
+ (lambda (mod)
2623
+ (or (accessor mod)
2624
+ (let ((name (list (gensym))))
2625
+ ;; Name MOD and bind it in the module root so that it's visible to
2626
+ ;; `resolve-module'. This is important as `psyntax' stores module
2627
+ ;; names and relies on being able to `resolve-module' them.
2628
+ (set-module-name! mod name)
2629
+ (call-with-module-autoload-lock
2630
+ (lambda ()
2631
+ (nested-define-module! (resolve-module '() #f) name mod)))
2632
+ (accessor mod))))))
2633
+
2634
+ (define* (module-gensym #:optional (id " mg") (m (current-module)))
2635
+ "Return a fresh symbol in the context of module M, based on ID (a
2636
+ string or symbol). As long as M is a valid module, this procedure is
2637
+ deterministic."
2638
+ (define (->string number)
2639
+ (number->string number 16))
2640
+
2641
+ (if m
2642
+ (string->symbol
2643
+ (string-append id "-"
2644
+ (->string (hash (module-name m) most-positive-fixnum))
2645
+ "-"
2646
+ (->string (module-generate-unique-id! m))))
2647
+ (gensym id)))
2648
+
2649
+ (define (make-modules-in module name)
2650
+ (or (nested-ref-module module name)
2651
+ (let ((m (make-module 31)))
2652
+ (set-module-kind! m 'directory)
2653
+ (set-module-name! m (append (module-name module) name))
2654
+ (nested-define-module! module name m)
2655
+ m)))
2656
+
2657
+ (define (beautify-user-module! module)
2658
+ (let ((interface (module-public-interface module)))
2659
+ (if (or (not interface)
2660
+ (eq? interface module))
2661
+ (let ((interface (make-module 31)))
2662
+ (set-module-name! interface (module-name module))
2663
+ (set-module-version! interface (module-version module))
2664
+ (set-module-kind! interface 'interface)
2665
+ (set-module-public-interface! module interface))))
2666
+ (if (and (not (memq the-scm-module (module-uses module)))
2667
+ (not (eq? module the-root-module)))
2668
+ ;; Import the default set of bindings (from the SCM module) in MODULE.
2669
+ (module-use! module the-scm-module)))
2670
+
2671
+ (define (version-matches? version-ref target)
2672
+ (define (sub-versions-match? v-refs t)
2673
+ (define (sub-version-matches? v-ref t)
2674
+ (let ((matches? (lambda (v) (sub-version-matches? v t))))
2675
+ (cond
2676
+ ((number? v-ref) (eqv? v-ref t))
2677
+ ((list? v-ref)
2678
+ (case (car v-ref)
2679
+ ((>=) (>= t (cadr v-ref)))
2680
+ ((<=) (<= t (cadr v-ref)))
2681
+ ((and) (and-map matches? (cdr v-ref)))
2682
+ ((or) (or-map matches? (cdr v-ref)))
2683
+ ((not) (not (matches? (cadr v-ref))))
2684
+ (else (error "Invalid sub-version reference" v-ref))))
2685
+ (else (error "Invalid sub-version reference" v-ref)))))
2686
+ (or (null? v-refs)
2687
+ (and (not (null? t))
2688
+ (sub-version-matches? (car v-refs) (car t))
2689
+ (sub-versions-match? (cdr v-refs) (cdr t)))))
2690
+
2691
+ (let ((matches? (lambda (v) (version-matches? v target))))
2692
+ (or (null? version-ref)
2693
+ (case (car version-ref)
2694
+ ((and) (and-map matches? (cdr version-ref)))
2695
+ ((or) (or-map matches? (cdr version-ref)))
2696
+ ((not) (not (matches? (cadr version-ref))))
2697
+ (else (sub-versions-match? version-ref target))))))
2698
+
2699
+ (define (make-fresh-user-module)
2700
+ (let ((m (make-module)))
2701
+ (beautify-user-module! m)
2702
+ m))
2703
+
2704
+ ;; NOTE: This binding is used in libguile/modules.c.
2705
+ ;;
2706
+ (define resolve-module
2707
+ (let ((root (make-module)))
2708
+ (set-module-name! root '())
2709
+ ;; Define the-root-module as '(guile).
2710
+ (module-define-submodule! root 'guile the-root-module)
2711
+
2712
+ (lambda* (name #:optional (autoload #t) (version #f) #:key (ensure #t))
2713
+ (call-with-module-autoload-lock
2714
+ (lambda ()
2715
+ (let ((already (nested-ref-module root name)))
2716
+ (cond
2717
+ ((and already
2718
+ (or (not autoload) (module-public-interface already)))
2719
+ ;; A hit, a palpable hit.
2720
+ (if (and version
2721
+ (not (version-matches? version (module-version already))))
2722
+ (error "incompatible module version already loaded" name))
2723
+ already)
2724
+ (autoload
2725
+ ;; Try to autoload the module, and recurse.
2726
+ (try-load-module name version)
2727
+ (resolve-module name #f #:ensure ensure))
2728
+ (else
2729
+ ;; No module found (or if one was, it had no public interface), and
2730
+ ;; we're not autoloading. Make an empty module if #:ensure is true.
2731
+ (or already
2732
+ (and ensure
2733
+ (make-modules-in root name)))))))))))
2734
+
2735
+
2736
+ (define (try-load-module name version)
2737
+ (try-module-autoload name version))
2738
+
2739
+ (define (reload-module m)
2740
+ "Revisit the source file corresponding to the module @var{m}."
2741
+ (let ((f (module-filename m)))
2742
+ (if f
2743
+ (save-module-excursion
2744
+ (lambda ()
2745
+ ;; Re-set the initial environment, as in try-module-autoload.
2746
+ (set-current-module (make-fresh-user-module))
2747
+ (primitive-load-path f)
2748
+ m))
2749
+ ;; Though we could guess, we *should* know it.
2750
+ (error "unknown file name for module" m))))
2751
+
2752
+ (define (purify-module! module)
2753
+ "Removes bindings in MODULE which are inherited from the (guile) module."
2754
+ (let ((use-list (module-uses module)))
2755
+ (if (and (pair? use-list)
2756
+ (eq? (car (last-pair use-list)) the-scm-module))
2757
+ (set-module-uses! module (reverse (cdr (reverse use-list)))))))
2758
+
2759
+ (define* (resolve-interface name #:key
2760
+ (select #f)
2761
+ (hide '())
2762
+ (prefix #f)
2763
+ (renamer (if prefix
2764
+ (symbol-prefix-proc prefix)
2765
+ identity))
2766
+ version)
2767
+ "Return a module that is an interface to the module designated by
2768
+ NAME.
2769
+
2770
+ `resolve-interface' takes four keyword arguments:
2771
+
2772
+ #:select SELECTION
2773
+
2774
+ SELECTION is a list of binding-specs to be imported; A binding-spec
2775
+ is either a symbol or a pair of symbols (ORIG . SEEN), where ORIG
2776
+ is the name in the used module and SEEN is the name in the using
2777
+ module. Note that SEEN is also passed through RENAMER, below. The
2778
+ default is to select all bindings. If you specify no selection but
2779
+ a renamer, only the bindings that already exist in the used module
2780
+ are made available in the interface. Bindings that are added later
2781
+ are not picked up.
2782
+
2783
+ #:hide BINDINGS
2784
+
2785
+ BINDINGS is a list of bindings which should not be imported.
2786
+
2787
+ #:prefix PREFIX
2788
+
2789
+ PREFIX is a symbol that will be appended to each exported name.
2790
+ The default is to not perform any renaming.
2791
+
2792
+ #:renamer RENAMER
2793
+
2794
+ RENAMER is a procedure that takes a symbol and returns its new
2795
+ name. The default is not perform any renaming.
2796
+
2797
+ Signal \"no code for module\" error if module name is not resolvable
2798
+ or its public interface is not available. Signal \"no binding\"
2799
+ error if selected binding does not exist in the used module."
2800
+ (let* ((module (resolve-module name #t version #:ensure #f))
2801
+ (public-i (and module (module-public-interface module))))
2802
+ (unless public-i
2803
+ (error "no code for module" name))
2804
+ (if (and (not select) (null? hide) (eq? renamer identity))
2805
+ public-i
2806
+ (let ((selection (or select (module-map (lambda (sym var) sym)
2807
+ public-i)))
2808
+ (custom-i (make-module 31)))
2809
+ (set-module-kind! custom-i 'custom-interface)
2810
+ (set-module-name! custom-i name)
2811
+ ;; XXX - should use a lazy binder so that changes to the
2812
+ ;; used module are picked up automatically.
2813
+ (for-each (lambda (bspec)
2814
+ (let* ((direct? (symbol? bspec))
2815
+ (orig (if direct? bspec (car bspec)))
2816
+ (seen (if direct? bspec (cdr bspec)))
2817
+ (var (or (module-local-variable public-i orig)
2818
+ (error
2819
+ ;; fixme: format manually for now
2820
+ (simple-format
2821
+ #f "no binding `~A' in module ~A"
2822
+ orig name)))))
2823
+ (if (memq orig hide)
2824
+ (set! hide (delq! orig hide))
2825
+ (module-add! custom-i
2826
+ (renamer seen)
2827
+ var))))
2828
+ selection)
2829
+ ;; Check that we are not hiding bindings which don't exist
2830
+ (for-each (lambda (binding)
2831
+ (if (not (module-local-variable public-i binding))
2832
+ (error
2833
+ (simple-format
2834
+ #f "no binding `~A' to hide in module ~A"
2835
+ binding name))))
2836
+ hide)
2837
+ custom-i))))
2838
+
2839
+ (define (symbol-prefix-proc prefix)
2840
+ (lambda (symbol)
2841
+ (symbol-append prefix symbol)))
2842
+
2843
+ ;; This function is called from "modules.c". If you change it, be
2844
+ ;; sure to update "modules.c" as well.
2845
+
2846
+ (define* (define-module* name
2847
+ #:key filename pure version (imports '()) (exports '())
2848
+ (replacements '()) (re-exports '()) (autoloads '())
2849
+ (duplicates #f) transformer)
2850
+ (define (list-of pred l)
2851
+ (or (null? l)
2852
+ (and (pair? l) (pred (car l)) (list-of pred (cdr l)))))
2853
+ (define (valid-import? x)
2854
+ (list? x))
2855
+ (define (valid-export? x)
2856
+ (or (symbol? x) (and (pair? x) (symbol? (car x)) (symbol? (cdr x)))))
2857
+ (define (valid-autoload? x)
2858
+ (and (pair? x) (list-of symbol? (car x)) (list-of symbol? (cdr x))))
2859
+
2860
+ ;; We could add a #:no-check arg, set by the define-module macro, if
2861
+ ;; these checks are taking too much time.
2862
+ ;;
2863
+ (let ((module (resolve-module name #f)))
2864
+ (beautify-user-module! module)
2865
+ (when filename
2866
+ (set-module-filename! module filename))
2867
+ (when pure
2868
+ (purify-module! module))
2869
+ (when version
2870
+ (unless (list-of integer? version)
2871
+ (error "expected list of integers for version"))
2872
+ (set-module-version! module version)
2873
+ (set-module-version! (module-public-interface module) version))
2874
+ (call-with-deferred-observers
2875
+ (lambda ()
2876
+ (unless (list-of valid-import? imports)
2877
+ (error "expected imports to be a list of import specifications"))
2878
+ (unless (list-of valid-export? exports)
2879
+ (error "expected exports to be a list of symbols or symbol pairs"))
2880
+ (unless (list-of valid-export? replacements)
2881
+ (error "expected replacements to be a list of symbols or symbol pairs"))
2882
+ (unless (list-of valid-export? re-exports)
2883
+ (error "expected re-exports to be a list of symbols or symbol pairs"))
2884
+ (module-export! module exports)
2885
+ (module-replace! module replacements)
2886
+ (unless (null? imports)
2887
+ (let ((imports (map (lambda (import-spec)
2888
+ (apply resolve-interface import-spec))
2889
+ imports)))
2890
+ (module-use-interfaces! module imports)))
2891
+ (module-re-export! module re-exports)
2892
+ ;; FIXME: Avoid use of `apply'.
2893
+ (apply module-autoload! module autoloads)
2894
+ (let ((duplicates (or duplicates
2895
+ ;; Avoid stompling a previously installed
2896
+ ;; duplicates handlers if possible.
2897
+ (and (not (module-duplicates-handlers module))
2898
+ ;; Note: If you change this default,
2899
+ ;; change it also in
2900
+ ;; `default-duplicate-binding-procedures'.
2901
+ '(replace warn-override-core warn last)))))
2902
+ (when duplicates
2903
+ (let ((handlers (lookup-duplicates-handlers duplicates)))
2904
+ (set-module-duplicates-handlers! module handlers))))))
2905
+
2906
+ (when transformer
2907
+ (unless (and (pair? transformer) (list-of symbol? transformer))
2908
+ (error "expected transformer to be a module name" transformer))
2909
+ (let ((iface (resolve-interface transformer))
2910
+ (sym (car (last-pair transformer))))
2911
+ (set-module-transformer! module (module-ref iface sym))))
2912
+
2913
+ (run-hook module-defined-hook module)
2914
+ module))
2915
+
2916
+ ;; `module-defined-hook' is a hook that is run whenever a new module
2917
+ ;; is defined. Its members are called with one argument, the new
2918
+ ;; module.
2919
+ (define module-defined-hook (make-hook 1))
2920
+
2921
+
2922
+
2923
+ ;;; {Autoload}
2924
+ ;;;
2925
+
2926
+ (define (make-autoload-interface module name bindings)
2927
+ (let ((b (lambda (a sym definep)
2928
+ (false-if-exception
2929
+ (and (memq sym bindings)
2930
+ (let ((i (module-public-interface (resolve-module name))))
2931
+ (if (not i)
2932
+ (error "missing interface for module" name))
2933
+ (let ((autoload (memq a (module-uses module))))
2934
+ ;; Replace autoload-interface with actual interface if
2935
+ ;; that has not happened yet.
2936
+ (if (pair? autoload)
2937
+ (set-car! autoload i)))
2938
+ (module-local-variable i sym)))
2939
+ #:warning "Failed to autoload ~a in ~a:\n" sym name))))
2940
+ (module-constructor (make-hash-table 0) '() b #f #f name 'autoload #f
2941
+ (make-hash-table 0) '() (make-weak-value-hash-table 31) #f
2942
+ (make-hash-table 0) #f #f #f 0)))
2943
+
2944
+ (define (module-autoload! module . args)
2945
+ "Have @var{module} automatically load the module named @var{name} when one
2946
+ of the symbols listed in @var{bindings} is looked up. @var{args} should be a
2947
+ list of module-name/binding-list pairs, e.g., as in @code{(module-autoload!
2948
+ module '(ice-9 q) '(make-q q-length))}."
2949
+ (let loop ((args args))
2950
+ (cond ((null? args)
2951
+ #t)
2952
+ ((null? (cdr args))
2953
+ (error "invalid name+binding autoload list" args))
2954
+ (else
2955
+ (let ((name (car args))
2956
+ (bindings (cadr args)))
2957
+ (module-use! module (make-autoload-interface module
2958
+ name bindings))
2959
+ (loop (cddr args)))))))
2960
+
2961
+
2962
+
2963
+
2964
+ ;;; {Autoloading modules}
2965
+ ;;;
2966
+
2967
+ (define autoloads-in-progress '())
2968
+
2969
+ ;; This function is called from scm_load_scheme_module in
2970
+ ;; "deprecated.c". Please do not change its interface.
2971
+ ;;
2972
+ (define* (try-module-autoload module-name #:optional version)
2973
+ "Try to load a module of the given name. If it is not found, return
2974
+ #f. Otherwise return #t. May raise an exception if a file is found,
2975
+ but it fails to load."
2976
+ (let* ((reverse-name (reverse module-name))
2977
+ (name (symbol->string (car reverse-name)))
2978
+ (dir-hint-module-name (reverse (cdr reverse-name)))
2979
+ (dir-hint (apply string-append
2980
+ (map (lambda (elt)
2981
+ (string-append (symbol->string elt)
2982
+ file-name-separator-string))
2983
+ dir-hint-module-name))))
2984
+ (resolve-module dir-hint-module-name #f)
2985
+
2986
+ (call-with-module-autoload-lock
2987
+ (lambda ()
2988
+ (and (not (autoload-done-or-in-progress? dir-hint name))
2989
+ (let ((didit #f))
2990
+ (dynamic-wind
2991
+ (lambda () (autoload-in-progress! dir-hint name))
2992
+ (lambda ()
2993
+ (with-fluids ((current-reader #f))
2994
+ (save-module-excursion
2995
+ (lambda ()
2996
+ (define (call/ec proc)
2997
+ (let ((tag (make-prompt-tag)))
2998
+ (call-with-prompt
2999
+ tag
3000
+ (lambda ()
3001
+ (proc (lambda () (abort-to-prompt tag))))
3002
+ (lambda (k) (values)))))
3003
+ ;; The initial environment when loading a module is a fresh
3004
+ ;; user module.
3005
+ (set-current-module (make-fresh-user-module))
3006
+ ;; Here we could allow some other search strategy (other than
3007
+ ;; primitive-load-path), for example using versions encoded
3008
+ ;; into the file system -- but then we would have to figure
3009
+ ;; out how to locate the compiled file, do auto-compilation,
3010
+ ;; etc. Punt for now, and don't use versions when locating
3011
+ ;; the file.
3012
+ (call/ec
3013
+ (lambda (abort)
3014
+ (primitive-load-path (in-vicinity dir-hint name)
3015
+ abort)
3016
+ (set! didit #t)))))))
3017
+ (lambda () (set-autoloaded! dir-hint name didit)))
3018
+ didit))))))
3019
+
3020
+
3021
+
3022
+ ;;; {Dynamic linking of modules}
3023
+ ;;;
3024
+
3025
+ (define autoloads-done '((guile . guile)))
3026
+
3027
+ (define (autoload-done-or-in-progress? p m)
3028
+ (let ((n (cons p m)))
3029
+ (->bool (or (member n autoloads-done)
3030
+ (member n autoloads-in-progress)))))
3031
+
3032
+ (define (autoload-done! p m)
3033
+ (let ((n (cons p m)))
3034
+ (set! autoloads-in-progress
3035
+ (delete! n autoloads-in-progress))
3036
+ (or (member n autoloads-done)
3037
+ (set! autoloads-done (cons n autoloads-done)))))
3038
+
3039
+ (define (autoload-in-progress! p m)
3040
+ (let ((n (cons p m)))
3041
+ (set! autoloads-done
3042
+ (delete! n autoloads-done))
3043
+ (set! autoloads-in-progress (cons n autoloads-in-progress))))
3044
+
3045
+ (define (set-autoloaded! p m done?)
3046
+ (if done?
3047
+ (autoload-done! p m)
3048
+ (let ((n (cons p m)))
3049
+ (set! autoloads-done (delete! n autoloads-done))
3050
+ (set! autoloads-in-progress (delete! n autoloads-in-progress)))))
3051
+
3052
+
3053
+
3054
+ ;;; {Run-time options}
3055
+ ;;;
3056
+
3057
+ (define-syntax define-option-interface
3058
+ (syntax-rules ()
3059
+ ((_ (interface (options enable disable) (option-set!)))
3060
+ (begin
3061
+ (define options
3062
+ (case-lambda
3063
+ (() (interface))
3064
+ ((arg)
3065
+ (if (list? arg)
3066
+ (begin (interface arg) (interface))
3067
+ (for-each
3068
+ (lambda (option)
3069
+ (apply (lambda (name value documentation)
3070
+ (display name)
3071
+ (let ((len (string-length (symbol->string name))))
3072
+ (when (< len 16)
3073
+ (display #\tab)
3074
+ (when (< len 8)
3075
+ (display #\tab))))
3076
+ (display #\tab)
3077
+ (display value)
3078
+ (display #\tab)
3079
+ (display documentation)
3080
+ (newline))
3081
+ option))
3082
+ (interface #t))))))
3083
+ (define (enable . flags)
3084
+ (interface (append flags (interface)))
3085
+ (interface))
3086
+ (define (disable . flags)
3087
+ (let ((options (interface)))
3088
+ (for-each (lambda (flag) (set! options (delq! flag options)))
3089
+ flags)
3090
+ (interface options)
3091
+ (interface)))
3092
+ (define-syntax-rule (option-set! opt val)
3093
+ (eval-when (expand load eval)
3094
+ (options (append (options) (list 'opt val)))))))))
3095
+
3096
+ (define-option-interface
3097
+ (debug-options-interface
3098
+ (debug-options debug-enable debug-disable)
3099
+ (debug-set!)))
3100
+
3101
+ (define-option-interface
3102
+ (read-options-interface
3103
+ (read-options read-enable read-disable)
3104
+ (read-set!)))
3105
+
3106
+ (define-option-interface
3107
+ (print-options-interface
3108
+ (print-options print-enable print-disable)
3109
+ (print-set!)))
3110
+
3111
+
3112
+
3113
+ ;;; {The Unspecified Value}
3114
+ ;;;
3115
+ ;;; Currently Guile represents unspecified values via one particular value,
3116
+ ;;; which may be obtained by evaluating (if #f #f). It would be nice in the
3117
+ ;;; future if we could replace this with a return of 0 values, though.
3118
+ ;;;
3119
+
3120
+ (define-syntax *unspecified*
3121
+ (identifier-syntax (if #f #f)))
3122
+
3123
+ (define (unspecified? v) (eq? v *unspecified*))
3124
+
3125
+
3126
+
3127
+
3128
+ ;;; {Running Repls}
3129
+ ;;;
3130
+
3131
+ (define *repl-stack* (make-fluid '()))
3132
+
3133
+ ;; Programs can call `batch-mode?' to see if they are running as part of a
3134
+ ;; script or if they are running interactively. REPL implementations ensure that
3135
+ ;; `batch-mode?' returns #f during their extent.
3136
+ ;;
3137
+ (define (batch-mode?)
3138
+ (null? (fluid-ref *repl-stack*)))
3139
+
3140
+ ;; Programs can re-enter batch mode, for example after a fork, by calling
3141
+ ;; `ensure-batch-mode!'. It's not a great interface, though; it would be better
3142
+ ;; to abort to the outermost prompt, and call a thunk there.
3143
+ ;;
3144
+ (define (ensure-batch-mode!)
3145
+ (set! batch-mode? (lambda () #t)))
3146
+
3147
+ (define (quit . args)
3148
+ (apply throw 'quit args))
3149
+
3150
+ (define exit quit)
3151
+
3152
+ (define (gc-run-time)
3153
+ (cdr (assq 'gc-time-taken (gc-stats))))
3154
+
3155
+ (define abort-hook (make-hook))
3156
+ (define before-error-hook (make-hook))
3157
+ (define after-error-hook (make-hook))
3158
+ (define before-backtrace-hook (make-hook))
3159
+ (define after-backtrace-hook (make-hook))
3160
+
3161
+ (define before-read-hook (make-hook))
3162
+ (define after-read-hook (make-hook))
3163
+ (define before-eval-hook (make-hook 1))
3164
+ (define after-eval-hook (make-hook 1))
3165
+ (define before-print-hook (make-hook 1))
3166
+ (define after-print-hook (make-hook 1))
3167
+
3168
+ ;;; This hook is run at the very end of an interactive session.
3169
+ ;;;
3170
+ (define exit-hook (make-hook))
3171
+
3172
+ ;;; The default repl-reader function. We may override this if we've
3173
+ ;;; the readline library.
3174
+ (define repl-reader
3175
+ (lambda* (prompt #:optional (reader (fluid-ref current-reader)))
3176
+ (if (not (char-ready?))
3177
+ (begin
3178
+ (display (if (string? prompt) prompt (prompt)))
3179
+ ;; An interesting situation. The printer resets the column to
3180
+ ;; 0 by printing a newline, but we then advance it by printing
3181
+ ;; the prompt. However the port-column of the output port
3182
+ ;; does not typically correspond with the actual column on the
3183
+ ;; screen, because the input is echoed back! Since the
3184
+ ;; input is line-buffered and thus ends with a newline, the
3185
+ ;; output will really start on column zero. So, here we zero
3186
+ ;; it out. See bug 9664.
3187
+ ;;
3188
+ ;; Note that for similar reasons, the output-line will not
3189
+ ;; reflect the actual line on the screen. But given the
3190
+ ;; possibility of multiline input, the fix is not as
3191
+ ;; straightforward, so we don't bother.
3192
+ ;;
3193
+ ;; Also note that the readline implementation papers over
3194
+ ;; these concerns, because it's readline itself printing the
3195
+ ;; prompt, and not Guile.
3196
+ (set-port-column! (current-output-port) 0)))
3197
+ (force-output)
3198
+ (run-hook before-read-hook)
3199
+ ((or reader read) (current-input-port))))
3200
+
3201
+
3202
+
3203
+
3204
+ ;;; {While}
3205
+ ;;;
3206
+ ;;; with `continue' and `break'.
3207
+ ;;;
3208
+
3209
+ ;; The inliner will remove the prompts at compile-time if it finds that
3210
+ ;; `continue' or `break' are not used.
3211
+ ;;
3212
+ (define-syntax while
3213
+ (lambda (x)
3214
+ (syntax-case x ()
3215
+ ((while cond body ...)
3216
+ #`(let ((break-tag (make-prompt-tag "break"))
3217
+ (continue-tag (make-prompt-tag "continue")))
3218
+ (call-with-prompt
3219
+ break-tag
3220
+ (lambda ()
3221
+ (define-syntax #,(datum->syntax #'while 'break)
3222
+ (lambda (x)
3223
+ (syntax-case x ()
3224
+ ((_ arg (... ...))
3225
+ #'(abort-to-prompt break-tag arg (... ...)))
3226
+ (_
3227
+ #'(lambda args
3228
+ (apply abort-to-prompt break-tag args))))))
3229
+ (let lp ()
3230
+ (call-with-prompt
3231
+ continue-tag
3232
+ (lambda ()
3233
+ (define-syntax #,(datum->syntax #'while 'continue)
3234
+ (lambda (x)
3235
+ (syntax-case x ()
3236
+ ((_)
3237
+ #'(abort-to-prompt continue-tag))
3238
+ ((_ . args)
3239
+ (syntax-violation 'continue "too many arguments" x))
3240
+ (_
3241
+ #'(lambda ()
3242
+ (abort-to-prompt continue-tag))))))
3243
+ (do () ((not cond) #f) body ...))
3244
+ (lambda (k) (lp)))))
3245
+ (lambda (k . args)
3246
+ (if (null? args)
3247
+ #t
3248
+ (apply values args)))))))))
3249
+
3250
+
3251
+
3252
+
3253
+ ;;; {Module System Macros}
3254
+ ;;;
3255
+
3256
+ ;; Return a list of expressions that evaluate to the appropriate
3257
+ ;; arguments for resolve-interface according to SPEC.
3258
+
3259
+ (eval-when (expand)
3260
+ (if (memq 'prefix (read-options))
3261
+ (error "boot-9 must be compiled with #:kw, not :kw")))
3262
+
3263
+ (define (keyword-like-symbol->keyword sym)
3264
+ (symbol->keyword (string->symbol (substring (symbol->string sym) 1))))
3265
+
3266
+ (define-syntax define-module
3267
+ (lambda (x)
3268
+ (define (keyword-like? stx)
3269
+ (let ((dat (syntax->datum stx)))
3270
+ (and (symbol? dat)
3271
+ (eqv? (string-ref (symbol->string dat) 0) #\:))))
3272
+ (define (->keyword sym)
3273
+ (symbol->keyword (string->symbol (substring (symbol->string sym) 1))))
3274
+
3275
+ (define (parse-iface args)
3276
+ (let loop ((in args) (out '()))
3277
+ (syntax-case in ()
3278
+ (() (reverse! out))
3279
+ ;; The user wanted #:foo, but wrote :foo. Fix it.
3280
+ ((sym . in) (keyword-like? #'sym)
3281
+ (loop #`(#,(->keyword (syntax->datum #'sym)) . in) out))
3282
+ ((kw . in) (not (keyword? (syntax->datum #'kw)))
3283
+ (syntax-violation 'define-module "expected keyword arg" x #'kw))
3284
+ ((#:renamer renamer . in)
3285
+ (loop #'in (cons* #',renamer #:renamer out)))
3286
+ ((kw val . in)
3287
+ (loop #'in (cons* #'val #'kw out))))))
3288
+
3289
+ (define (parse args imp exp rex rep aut)
3290
+ ;; Just quote everything except #:use-module and #:use-syntax. We
3291
+ ;; need to know about all arguments regardless since we want to turn
3292
+ ;; symbols that look like keywords into real keywords, and the
3293
+ ;; keyword args in a define-module form are not regular
3294
+ ;; (i.e. no-backtrace doesn't take a value).
3295
+ (syntax-case args ()
3296
+ (()
3297
+ (let ((imp (if (null? imp) '() #`(#:imports `#,imp)))
3298
+ (exp (if (null? exp) '() #`(#:exports '#,exp)))
3299
+ (rex (if (null? rex) '() #`(#:re-exports '#,rex)))
3300
+ (rep (if (null? rep) '() #`(#:replacements '#,rep)))
3301
+ (aut (if (null? aut) '() #`(#:autoloads '#,aut))))
3302
+ #`(#,@imp #,@exp #,@rex #,@rep #,@aut)))
3303
+ ;; The user wanted #:foo, but wrote :foo. Fix it.
3304
+ ((sym . args) (keyword-like? #'sym)
3305
+ (parse #`(#,(->keyword (syntax->datum #'sym)) . args)
3306
+ imp exp rex rep aut))
3307
+ ((kw . args) (not (keyword? (syntax->datum #'kw)))
3308
+ (syntax-violation 'define-module "expected keyword arg" x #'kw))
3309
+ ((#:no-backtrace . args)
3310
+ ;; Ignore this one.
3311
+ (parse #'args imp exp rex rep aut))
3312
+ ((#:pure . args)
3313
+ #`(#:pure #t . #,(parse #'args imp exp rex rep aut)))
3314
+ ((kw)
3315
+ (syntax-violation 'define-module "keyword arg without value" x #'kw))
3316
+ ((#:version (v ...) . args)
3317
+ #`(#:version '(v ...) . #,(parse #'args imp exp rex rep aut)))
3318
+ ((#:duplicates (d ...) . args)
3319
+ #`(#:duplicates '(d ...) . #,(parse #'args imp exp rex rep aut)))
3320
+ ((#:filename f . args)
3321
+ #`(#:filename 'f . #,(parse #'args imp exp rex rep aut)))
3322
+ ((#:use-module (name name* ...) . args)
3323
+ (and (and-map symbol? (syntax->datum #'(name name* ...))))
3324
+ (parse #'args #`(#,@imp ((name name* ...))) exp rex rep aut))
3325
+ ((#:use-syntax (name name* ...) . args)
3326
+ (and (and-map symbol? (syntax->datum #'(name name* ...))))
3327
+ #`(#:transformer '(name name* ...)
3328
+ . #,(parse #'args #`(#,@imp ((name name* ...))) exp rex rep aut)))
3329
+ ((#:use-module ((name name* ...) arg ...) . args)
3330
+ (and (and-map symbol? (syntax->datum #'(name name* ...))))
3331
+ (parse #'args
3332
+ #`(#,@imp ((name name* ...) #,@(parse-iface #'(arg ...))))
3333
+ exp rex rep aut))
3334
+ ((#:export (ex ...) . args)
3335
+ (parse #'args imp #`(#,@exp ex ...) rex rep aut))
3336
+ ((#:export-syntax (ex ...) . args)
3337
+ (parse #'args imp #`(#,@exp ex ...) rex rep aut))
3338
+ ((#:re-export (re ...) . args)
3339
+ (parse #'args imp exp #`(#,@rex re ...) rep aut))
3340
+ ((#:re-export-syntax (re ...) . args)
3341
+ (parse #'args imp exp #`(#,@rex re ...) rep aut))
3342
+ ((#:replace (r ...) . args)
3343
+ (parse #'args imp exp rex #`(#,@rep r ...) aut))
3344
+ ((#:replace-syntax (r ...) . args)
3345
+ (parse #'args imp exp rex #`(#,@rep r ...) aut))
3346
+ ((#:autoload name bindings . args)
3347
+ (parse #'args imp exp rex rep #`(#,@aut name bindings)))
3348
+ ((kw val . args)
3349
+ (syntax-violation 'define-module "unknown keyword or bad argument"
3350
+ #'kw #'val))))
3351
+
3352
+ (syntax-case x ()
3353
+ ((_ (name name* ...) arg ...)
3354
+ (and-map symbol? (syntax->datum #'(name name* ...)))
3355
+ (with-syntax (((quoted-arg ...)
3356
+ (parse #'(arg ...) '() '() '() '() '()))
3357
+ ;; Ideally the filename is either a string or #f;
3358
+ ;; this hack is to work around a case in which
3359
+ ;; port-filename returns a symbol (`socket') for
3360
+ ;; sockets.
3361
+ (filename (let ((f (assq-ref (or (syntax-source x) '())
3362
+ 'filename)))
3363
+ (and (string? f) f))))
3364
+ #'(eval-when (expand load eval)
3365
+ (let ((m (define-module* '(name name* ...)
3366
+ #:filename filename quoted-arg ...)))
3367
+ (set-current-module m)
3368
+ m)))))))
3369
+
3370
+ ;; The guts of the use-modules macro. Add the interfaces of the named
3371
+ ;; modules to the use-list of the current module, in order.
3372
+
3373
+ ;; This function is called by "modules.c". If you change it, be sure
3374
+ ;; to change scm_c_use_module as well.
3375
+
3376
+ (define (process-use-modules module-interface-args)
3377
+ (let ((interfaces (map (lambda (mif-args)
3378
+ (or (apply resolve-interface mif-args)
3379
+ (error "no such module" mif-args)))
3380
+ module-interface-args)))
3381
+ (call-with-deferred-observers
3382
+ (lambda ()
3383
+ (module-use-interfaces! (current-module) interfaces)))))
3384
+
3385
+ (define-syntax use-modules
3386
+ (lambda (x)
3387
+ (define (keyword-like? stx)
3388
+ (let ((dat (syntax->datum stx)))
3389
+ (and (symbol? dat)
3390
+ (eqv? (string-ref (symbol->string dat) 0) #\:))))
3391
+ (define (->keyword sym)
3392
+ (symbol->keyword (string->symbol (substring (symbol->string sym) 1))))
3393
+
3394
+ (define (quotify-iface args)
3395
+ (let loop ((in args) (out '()))
3396
+ (syntax-case in ()
3397
+ (() (reverse! out))
3398
+ ;; The user wanted #:foo, but wrote :foo. Fix it.
3399
+ ((sym . in) (keyword-like? #'sym)
3400
+ (loop #`(#,(->keyword (syntax->datum #'sym)) . in) out))
3401
+ ((kw . in) (not (keyword? (syntax->datum #'kw)))
3402
+ (syntax-violation 'define-module "expected keyword arg" x #'kw))
3403
+ ((#:renamer renamer . in)
3404
+ (loop #'in (cons* #'renamer #:renamer out)))
3405
+ ((kw val . in)
3406
+ (loop #'in (cons* #''val #'kw out))))))
3407
+
3408
+ (define (quotify specs)
3409
+ (let lp ((in specs) (out '()))
3410
+ (syntax-case in ()
3411
+ (() (reverse out))
3412
+ (((name name* ...) . in)
3413
+ (and-map symbol? (syntax->datum #'(name name* ...)))
3414
+ (lp #'in (cons #''((name name* ...)) out)))
3415
+ ((((name name* ...) arg ...) . in)
3416
+ (and-map symbol? (syntax->datum #'(name name* ...)))
3417
+ (with-syntax (((quoted-arg ...) (quotify-iface #'(arg ...))))
3418
+ (lp #'in (cons #`(list '(name name* ...) quoted-arg ...)
3419
+ out)))))))
3420
+
3421
+ (syntax-case x ()
3422
+ ((_ spec ...)
3423
+ (with-syntax (((quoted-args ...) (quotify #'(spec ...))))
3424
+ #'(eval-when (expand load eval)
3425
+ (process-use-modules (list quoted-args ...))
3426
+ *unspecified*))))))
3427
+
3428
+ (include-from-path "ice-9/r6rs-libraries")
3429
+
3430
+ (define-syntax-rule (define-private foo bar)
3431
+ (define foo bar))
3432
+
3433
+ (define-syntax define-public
3434
+ (syntax-rules ()
3435
+ ((_ (name . args) . body)
3436
+ (begin
3437
+ (define (name . args) . body)
3438
+ (export name)))
3439
+ ((_ name val)
3440
+ (begin
3441
+ (define name val)
3442
+ (export name)))))
3443
+
3444
+ (define-syntax-rule (defmacro-public name args body ...)
3445
+ (begin
3446
+ (defmacro name args body ...)
3447
+ (export-syntax name)))
3448
+
3449
+ ;; And now for the most important macro.
3450
+ (define-syntax-rule (λ formals body ...)
3451
+ (lambda formals body ...))
3452
+
3453
+
3454
+ ;; This function is called from "modules.c". If you change it, be
3455
+ ;; sure to update "modules.c" as well.
3456
+
3457
+ (define (module-export! m names)
3458
+ "Export a local variable."
3459
+ (let ((public-i (module-public-interface m)))
3460
+ (for-each (lambda (name)
3461
+ (let* ((internal-name (if (pair? name) (car name) name))
3462
+ (external-name (if (pair? name) (cdr name) name))
3463
+ (var (module-ensure-local-variable! m internal-name)))
3464
+ (module-add! public-i external-name var)))
3465
+ names)))
3466
+
3467
+ (define (module-replace! m names)
3468
+ (let ((public-i (module-public-interface m)))
3469
+ (for-each (lambda (name)
3470
+ (let* ((internal-name (if (pair? name) (car name) name))
3471
+ (external-name (if (pair? name) (cdr name) name))
3472
+ (var (module-ensure-local-variable! m internal-name)))
3473
+ ;; FIXME: use a bit on variables instead of object
3474
+ ;; properties.
3475
+ (set-object-property! var 'replace #t)
3476
+ (module-add! public-i external-name var)))
3477
+ names)))
3478
+
3479
+ (define (module-export-all! mod)
3480
+ "Export all local variables from a module."
3481
+ (define (fresh-interface!)
3482
+ (let ((iface (make-module)))
3483
+ (set-module-name! iface (module-name mod))
3484
+ (set-module-version! iface (module-version mod))
3485
+ (set-module-kind! iface 'interface)
3486
+ (set-module-public-interface! mod iface)
3487
+ iface))
3488
+ (let ((iface (or (module-public-interface mod)
3489
+ (fresh-interface!))))
3490
+ (set-module-obarray! iface (module-obarray mod))))
3491
+
3492
+ (define (module-re-export! m names)
3493
+ "Re-export an imported variable."
3494
+ (let ((public-i (module-public-interface m)))
3495
+ (for-each (lambda (name)
3496
+ (let* ((internal-name (if (pair? name) (car name) name))
3497
+ (external-name (if (pair? name) (cdr name) name))
3498
+ (var (module-variable m internal-name)))
3499
+ (cond ((not var)
3500
+ (error "Undefined variable:" internal-name))
3501
+ ((eq? var (module-local-variable m internal-name))
3502
+ (error "re-exporting local variable:" internal-name))
3503
+ (else
3504
+ (module-add! public-i external-name var)))))
3505
+ names)))
3506
+
3507
+ (define-syntax-rule (export name ...)
3508
+ (eval-when (expand load eval)
3509
+ (call-with-deferred-observers
3510
+ (lambda ()
3511
+ (module-export! (current-module) '(name ...))))))
3512
+
3513
+ (define-syntax-rule (re-export name ...)
3514
+ (eval-when (expand load eval)
3515
+ (call-with-deferred-observers
3516
+ (lambda ()
3517
+ (module-re-export! (current-module) '(name ...))))))
3518
+
3519
+ (define-syntax-rule (export! name ...)
3520
+ (eval-when (expand load eval)
3521
+ (call-with-deferred-observers
3522
+ (lambda ()
3523
+ (module-replace! (current-module) '(name ...))))))
3524
+
3525
+ (define-syntax-rule (export-syntax name ...)
3526
+ (export name ...))
3527
+
3528
+ (define-syntax-rule (re-export-syntax name ...)
3529
+ (re-export name ...))
3530
+
3531
+
3532
+
3533
+ ;;; {Parameters}
3534
+ ;;;
3535
+
3536
+ (define* (make-mutable-parameter init #:optional (converter identity))
3537
+ (let ((fluid (make-fluid (converter init))))
3538
+ (case-lambda
3539
+ (() (fluid-ref fluid))
3540
+ ((val) (fluid-set! fluid (converter val))))))
3541
+
3542
+
3543
+
3544
+
3545
+ ;;; {Handling of duplicate imported bindings}
3546
+ ;;;
3547
+
3548
+ ;; Duplicate handlers take the following arguments:
3549
+ ;;
3550
+ ;; module importing module
3551
+ ;; name conflicting name
3552
+ ;; int1 old interface where name occurs
3553
+ ;; val1 value of binding in old interface
3554
+ ;; int2 new interface where name occurs
3555
+ ;; val2 value of binding in new interface
3556
+ ;; var previous resolution or #f
3557
+ ;; val value of previous resolution
3558
+ ;;
3559
+ ;; A duplicate handler can take three alternative actions:
3560
+ ;;
3561
+ ;; 1. return #f => leave responsibility to next handler
3562
+ ;; 2. exit with an error
3563
+ ;; 3. return a variable resolving the conflict
3564
+ ;;
3565
+
3566
+ (define duplicate-handlers
3567
+ (let ((m (make-module 7)))
3568
+
3569
+ (define (check module name int1 val1 int2 val2 var val)
3570
+ (scm-error 'misc-error
3571
+ #f
3572
+ "~A: `~A' imported from both ~A and ~A"
3573
+ (list (module-name module)
3574
+ name
3575
+ (module-name int1)
3576
+ (module-name int2))
3577
+ #f))
3578
+
3579
+ (define (warn module name int1 val1 int2 val2 var val)
3580
+ (format (current-warning-port)
3581
+ "WARNING: ~A: `~A' imported from both ~A and ~A\n"
3582
+ (module-name module)
3583
+ name
3584
+ (module-name int1)
3585
+ (module-name int2))
3586
+ #f)
3587
+
3588
+ (define (replace module name int1 val1 int2 val2 var val)
3589
+ (let ((old (or (and var (object-property var 'replace) var)
3590
+ (module-variable int1 name)))
3591
+ (new (module-variable int2 name)))
3592
+ (if (object-property old 'replace)
3593
+ (and (or (eq? old new)
3594
+ (not (object-property new 'replace)))
3595
+ old)
3596
+ (and (object-property new 'replace)
3597
+ new))))
3598
+
3599
+ (define (warn-override-core module name int1 val1 int2 val2 var val)
3600
+ (and (eq? int1 the-scm-module)
3601
+ (begin
3602
+ (format (current-warning-port)
3603
+ "WARNING: ~A: imported module ~A overrides core binding `~A'\n"
3604
+ (module-name module)
3605
+ (module-name int2)
3606
+ name)
3607
+ (module-local-variable int2 name))))
3608
+
3609
+ (define (first module name int1 val1 int2 val2 var val)
3610
+ (or var (module-local-variable int1 name)))
3611
+
3612
+ (define (last module name int1 val1 int2 val2 var val)
3613
+ (module-local-variable int2 name))
3614
+
3615
+ (define (noop module name int1 val1 int2 val2 var val)
3616
+ #f)
3617
+
3618
+ (set-module-name! m 'duplicate-handlers)
3619
+ (set-module-kind! m 'interface)
3620
+ (module-define! m 'check check)
3621
+ (module-define! m 'warn warn)
3622
+ (module-define! m 'replace replace)
3623
+ (module-define! m 'warn-override-core warn-override-core)
3624
+ (module-define! m 'first first)
3625
+ (module-define! m 'last last)
3626
+ (module-define! m 'merge-generics noop)
3627
+ (module-define! m 'merge-accessors noop)
3628
+ m))
3629
+
3630
+ (define (lookup-duplicates-handlers handler-names)
3631
+ (and handler-names
3632
+ (map (lambda (handler-name)
3633
+ (or (module-symbol-local-binding
3634
+ duplicate-handlers handler-name #f)
3635
+ (error "invalid duplicate handler name:"
3636
+ handler-name)))
3637
+ (if (list? handler-names)
3638
+ handler-names
3639
+ (list handler-names)))))
3640
+
3641
+ (define default-duplicate-binding-procedures
3642
+ (case-lambda
3643
+ (()
3644
+ (or (module-duplicates-handlers (current-module))
3645
+ ;; Note: If you change this default, change it also in
3646
+ ;; `define-module*'.
3647
+ (lookup-duplicates-handlers
3648
+ '(replace warn-override-core warn last))))
3649
+ ((procs)
3650
+ (set-module-duplicates-handlers! (current-module) procs))))
3651
+
3652
+ (define default-duplicate-binding-handler
3653
+ (case-lambda
3654
+ (()
3655
+ (map procedure-name (default-duplicate-binding-procedures)))
3656
+ ((handlers)
3657
+ (default-duplicate-binding-procedures
3658
+ (lookup-duplicates-handlers handlers)))))
3659
+
3660
+
3661
+
3662
+ ;;; {`load'.}
3663
+ ;;;
3664
+ ;;; Load is tricky when combined with relative file names, compilation,
3665
+ ;;; and the file system. If a file name is relative, what is it
3666
+ ;;; relative to? The name of the source file at the time it was
3667
+ ;;; compiled? The name of the compiled file? What if both or either
3668
+ ;;; were installed? And how do you get that information? Tricky, I
3669
+ ;;; say.
3670
+ ;;;
3671
+ ;;; To get around all of this, we're going to do something nasty, and
3672
+ ;;; turn `load' into a macro. That way it can know the name of the
3673
+ ;;; source file with respect to which it was invoked, so it can resolve
3674
+ ;;; relative file names with respect to the original source file.
3675
+ ;;;
3676
+ ;;; There is an exception, and that is that if the source file was in
3677
+ ;;; the load path when it was compiled, instead of looking up against
3678
+ ;;; the absolute source location, we load-from-path against the relative
3679
+ ;;; source location.
3680
+ ;;;
3681
+
3682
+ (define %auto-compilation-options
3683
+ ;; Default `compile-file' option when auto-compiling.
3684
+ '(#:warnings (unbound-variable shadowed-toplevel
3685
+ macro-use-before-definition arity-mismatch
3686
+ format duplicate-case-datum bad-case-datum)))
3687
+
3688
+ (define* (load-in-vicinity dir file-name #:optional reader)
3689
+ "Load source file FILE-NAME in vicinity of directory DIR. Use a
3690
+ pre-compiled version of FILE-NAME when available, and auto-compile one
3691
+ when none is available, reading FILE-NAME with READER."
3692
+
3693
+ ;; The auto-compilation code will residualize a .go file in the cache
3694
+ ;; dir: by default, $HOME/.cache/guile/2.0/ccache/PATH.go. This
3695
+ ;; function determines the PATH to use as a key into the compilation
3696
+ ;; cache.
3697
+ (define (canonical->suffix canon)
3698
+ (cond
3699
+ ((and (not (string-null? canon))
3700
+ (file-name-separator? (string-ref canon 0)))
3701
+ canon)
3702
+ ((and (eq? (system-file-name-convention) 'windows)
3703
+ (absolute-file-name? canon))
3704
+ ;; An absolute file name that doesn't start with a separator
3705
+ ;; starts with a drive component. Transform the drive component
3706
+ ;; to a file name element: c:\foo -> \c\foo.
3707
+ (string-append file-name-separator-string
3708
+ (substring canon 0 1)
3709
+ (substring canon 2)))
3710
+ (else canon)))
3711
+
3712
+ (define compiled-extension
3713
+ ;; File name extension of compiled files.
3714
+ (cond ((or (null? %load-compiled-extensions)
3715
+ (string-null? (car %load-compiled-extensions)))
3716
+ (warn "invalid %load-compiled-extensions"
3717
+ %load-compiled-extensions)
3718
+ ".go")
3719
+ (else (car %load-compiled-extensions))))
3720
+
3721
+ (define (more-recent? stat1 stat2)
3722
+ ;; Return #t when STAT1 has an mtime greater than that of STAT2.
3723
+ (or (> (stat:mtime stat1) (stat:mtime stat2))
3724
+ (and (= (stat:mtime stat1) (stat:mtime stat2))
3725
+ (>= (stat:mtimensec stat1)
3726
+ (stat:mtimensec stat2)))))
3727
+
3728
+ (define (fallback-file-name canon-file-name)
3729
+ ;; Return the in-cache compiled file name for source file
3730
+ ;; CANON-FILE-NAME.
3731
+
3732
+ ;; FIXME: would probably be better just to append
3733
+ ;; SHA1(canon-file-name) to the %compile-fallback-path, to avoid
3734
+ ;; deep directory stats.
3735
+ (and %compile-fallback-path
3736
+ (string-append %compile-fallback-path
3737
+ (canonical->suffix canon-file-name)
3738
+ compiled-extension)))
3739
+
3740
+ (define (compile file)
3741
+ ;; Compile source FILE, lazily loading the compiler.
3742
+ ((module-ref (resolve-interface '(system base compile))
3743
+ 'compile-file)
3744
+ file
3745
+ #:opts %auto-compilation-options
3746
+ #:env (current-module)))
3747
+
3748
+ (define (load-thunk-from-file file)
3749
+ (let ((loader (resolve-interface '(system vm loader))))
3750
+ ((module-ref loader 'load-thunk-from-file) file)))
3751
+
3752
+ ;; Returns a thunk loaded from the .go file corresponding to `name'.
3753
+ ;; Does not search load paths, only the fallback path. If the .go
3754
+ ;; file is missing or out of date, and auto-compilation is enabled,
3755
+ ;; will try auto-compilation, just as primitive-load-path does
3756
+ ;; internally. primitive-load is unaffected. Returns #f if
3757
+ ;; auto-compilation failed or was disabled.
3758
+ ;;
3759
+ ;; NB: Unless we need to compile the file, this function should not
3760
+ ;; cause (system base compile) to be loaded up. For that reason
3761
+ ;; compiled-file-name partially duplicates functionality from (system
3762
+ ;; base compile).
3763
+
3764
+ (define (fresh-compiled-thunk name scmstat go-file-name)
3765
+ ;; Return GO-FILE-NAME after making sure that it contains a freshly
3766
+ ;; compiled version of source file NAME with stat SCMSTAT; return #f
3767
+ ;; on failure.
3768
+ (false-if-exception
3769
+ (let ((gostat (and (not %fresh-auto-compile)
3770
+ (stat go-file-name #f))))
3771
+ (if (and gostat (more-recent? gostat scmstat))
3772
+ (load-thunk-from-file go-file-name)
3773
+ (begin
3774
+ (when gostat
3775
+ (format (current-warning-port)
3776
+ ";;; note: source file ~a\n;;; newer than compiled ~a\n"
3777
+ name go-file-name))
3778
+ (cond
3779
+ (%load-should-auto-compile
3780
+ (%warn-auto-compilation-enabled)
3781
+ (format (current-warning-port) ";;; compiling ~a\n" name)
3782
+ (let ((cfn (compile name)))
3783
+ (format (current-warning-port) ";;; compiled ~a\n" cfn)
3784
+ (load-thunk-from-file cfn)))
3785
+ (else #f)))))
3786
+ #:warning "WARNING: compilation of ~a failed:\n" name))
3787
+
3788
+ (define (sans-extension file)
3789
+ (let ((dot (string-rindex file #\.)))
3790
+ (if dot
3791
+ (substring file 0 dot)
3792
+ file)))
3793
+
3794
+ (define (load-absolute abs-file-name)
3795
+ ;; Load from ABS-FILE-NAME, using a compiled file or auto-compiling
3796
+ ;; if needed.
3797
+ (define scmstat
3798
+ (false-if-exception
3799
+ (stat abs-file-name)
3800
+ #:warning "Stat of ~a failed:\n" abs-file-name))
3801
+
3802
+ (define (pre-compiled)
3803
+ (or-map
3804
+ (lambda (dir)
3805
+ (or-map
3806
+ (lambda (ext)
3807
+ (let ((candidate (string-append (in-vicinity dir file-name) ext)))
3808
+ (let ((gostat (stat candidate #f)))
3809
+ (and gostat
3810
+ (more-recent? gostat scmstat)
3811
+ (false-if-exception
3812
+ (load-thunk-from-file candidate)
3813
+ #:warning "WARNING: failed to load compiled file ~a:\n"
3814
+ candidate)))))
3815
+ %load-compiled-extensions))
3816
+ %load-compiled-path))
3817
+
3818
+ (define (fallback)
3819
+ (and=> (false-if-exception (canonicalize-path abs-file-name))
3820
+ (lambda (canon)
3821
+ (and=> (fallback-file-name canon)
3822
+ (lambda (go-file-name)
3823
+ (fresh-compiled-thunk abs-file-name
3824
+ scmstat
3825
+ go-file-name))))))
3826
+
3827
+ (let ((compiled (and scmstat (or (pre-compiled) (fallback)))))
3828
+ (if compiled
3829
+ (begin
3830
+ (if %load-hook
3831
+ (%load-hook abs-file-name))
3832
+ (compiled))
3833
+ (start-stack 'load-stack
3834
+ (primitive-load abs-file-name)))))
3835
+
3836
+ (save-module-excursion
3837
+ (lambda ()
3838
+ (with-fluids ((current-reader reader)
3839
+ (%file-port-name-canonicalization 'relative))
3840
+ (cond
3841
+ ((absolute-file-name? file-name)
3842
+ (load-absolute file-name))
3843
+ ((absolute-file-name? dir)
3844
+ (load-absolute (in-vicinity dir file-name)))
3845
+ (else
3846
+ (load-from-path (in-vicinity dir file-name))))))))
3847
+
3848
+ (define-syntax load
3849
+ (make-variable-transformer
3850
+ (lambda (x)
3851
+ (let* ((src (syntax-source x))
3852
+ (file (and src (assq-ref src 'filename)))
3853
+ (dir (and (string? file) (dirname file))))
3854
+ (syntax-case x ()
3855
+ ((_ arg ...)
3856
+ #`(load-in-vicinity #,(or dir #'(getcwd)) arg ...))
3857
+ (id
3858
+ (identifier? #'id)
3859
+ #`(lambda args
3860
+ (apply load-in-vicinity #,(or dir #'(getcwd)) args))))))))
3861
+
3862
+
3863
+
3864
+ ;;; {`cond-expand' for SRFI-0 support.}
3865
+ ;;;
3866
+ ;;; This syntactic form expands into different commands or
3867
+ ;;; definitions, depending on the features provided by the Scheme
3868
+ ;;; implementation.
3869
+ ;;;
3870
+ ;;; Syntax:
3871
+ ;;;
3872
+ ;;; <cond-expand>
3873
+ ;;; --> (cond-expand <cond-expand-clause>+)
3874
+ ;;; | (cond-expand <cond-expand-clause>* (else <command-or-definition>))
3875
+ ;;; <cond-expand-clause>
3876
+ ;;; --> (<feature-requirement> <command-or-definition>*)
3877
+ ;;; <feature-requirement>
3878
+ ;;; --> <feature-identifier>
3879
+ ;;; | (and <feature-requirement>*)
3880
+ ;;; | (or <feature-requirement>*)
3881
+ ;;; | (not <feature-requirement>)
3882
+ ;;; <feature-identifier>
3883
+ ;;; --> <a symbol which is the name or alias of a SRFI>
3884
+ ;;;
3885
+ ;;; Additionally, this implementation provides the
3886
+ ;;; <feature-identifier>s `guile' and `r5rs', so that programs can
3887
+ ;;; determine the implementation type and the supported standard.
3888
+ ;;;
3889
+ ;;; Remember to update the features list when adding more SRFIs.
3890
+ ;;;
3891
+
3892
+ (define %cond-expand-features
3893
+ ;; This should contain only features that are present in core Guile,
3894
+ ;; before loading any modules. Modular features are handled by
3895
+ ;; placing 'cond-expand-provide' in the relevant module.
3896
+ '(guile
3897
+ guile-2
3898
+ guile-2.2
3899
+ r5rs
3900
+ srfi-0 ;; cond-expand itself
3901
+ srfi-4 ;; homogeneous numeric vectors
3902
+ srfi-6 ;; string ports
3903
+ srfi-13 ;; string library
3904
+ srfi-14 ;; character sets
3905
+ srfi-16 ;; case-lambda
3906
+ srfi-23 ;; `error` procedure
3907
+ srfi-30 ;; nested multi-line comments
3908
+ srfi-39 ;; parameterize
3909
+ srfi-46 ;; basic syntax-rules extensions
3910
+ srfi-55 ;; require-extension
3911
+ srfi-61 ;; general cond clause
3912
+ srfi-62 ;; s-expression comments
3913
+ srfi-87 ;; => in case clauses
3914
+ srfi-105 ;; curly infix expressions
3915
+ ))
3916
+
3917
+ ;; This table maps module public interfaces to the list of features.
3918
+ ;;
3919
+ (define %cond-expand-table (make-hash-table 31))
3920
+
3921
+ ;; Add one or more features to the `cond-expand' feature list of the
3922
+ ;; module `module'.
3923
+ ;;
3924
+ (define (cond-expand-provide module features)
3925
+ (let ((mod (module-public-interface module)))
3926
+ (and mod
3927
+ (hashq-set! %cond-expand-table mod
3928
+ (append (hashq-ref %cond-expand-table mod '())
3929
+ features)))))
3930
+
3931
+ (define-syntax cond-expand
3932
+ (lambda (x)
3933
+ (define (module-has-feature? mod sym)
3934
+ (or-map (lambda (mod)
3935
+ (memq sym (hashq-ref %cond-expand-table mod '())))
3936
+ (module-uses mod)))
3937
+
3938
+ (define (condition-matches? condition)
3939
+ (syntax-case condition (and or not)
3940
+ ((and c ...)
3941
+ (and-map condition-matches? #'(c ...)))
3942
+ ((or c ...)
3943
+ (or-map condition-matches? #'(c ...)))
3944
+ ((not c)
3945
+ (if (condition-matches? #'c) #f #t))
3946
+ (c
3947
+ (identifier? #'c)
3948
+ (let ((sym (syntax->datum #'c)))
3949
+ (if (memq sym %cond-expand-features)
3950
+ #t
3951
+ (module-has-feature? (current-module) sym))))))
3952
+
3953
+ (define (match clauses alternate)
3954
+ (syntax-case clauses ()
3955
+ (((condition form ...) . rest)
3956
+ (if (condition-matches? #'condition)
3957
+ #'(begin form ...)
3958
+ (match #'rest alternate)))
3959
+ (() (alternate))))
3960
+
3961
+ (syntax-case x (else)
3962
+ ((_ clause ... (else form ...))
3963
+ (match #'(clause ...)
3964
+ (lambda ()
3965
+ #'(begin form ...))))
3966
+ ((_ clause ...)
3967
+ (match #'(clause ...)
3968
+ (lambda ()
3969
+ (syntax-violation 'cond-expand "unfulfilled cond-expand" x)))))))
3970
+
3971
+ ;; This procedure gets called from the startup code with a list of
3972
+ ;; numbers, which are the numbers of the SRFIs to be loaded on startup.
3973
+ ;;
3974
+ (define (use-srfis srfis)
3975
+ (process-use-modules
3976
+ (map (lambda (num)
3977
+ (list (list 'srfi (string->symbol
3978
+ (string-append "srfi-" (number->string num))))))
3979
+ srfis)))
3980
+
3981
+
3982
+
3983
+ ;;; srfi-55: require-extension
3984
+ ;;;
3985
+
3986
+ (define-syntax require-extension
3987
+ (lambda (x)
3988
+ (syntax-case x (srfi)
3989
+ ((_ (srfi n ...))
3990
+ (and-map integer? (syntax->datum #'(n ...)))
3991
+ (with-syntax
3992
+ (((srfi-n ...)
3993
+ (map (lambda (n)
3994
+ (datum->syntax x (symbol-append 'srfi- n)))
3995
+ (map string->symbol
3996
+ (map number->string (syntax->datum #'(n ...)))))))
3997
+ #'(use-modules (srfi srfi-n) ...)))
3998
+ ((_ (type arg ...))
3999
+ (identifier? #'type)
4000
+ (syntax-violation 'require-extension "Not a recognized extension type"
4001
+ x)))))
4002
+
4003
+
4004
+ ;;; Defining transparently inlinable procedures
4005
+ ;;;
4006
+
4007
+ (define-syntax define-inlinable
4008
+ ;; Define a macro and a procedure such that direct calls are inlined, via
4009
+ ;; the macro expansion, whereas references in non-call contexts refer to
4010
+ ;; the procedure. Inspired by the `define-integrable' macro by Dybvig et al.
4011
+ (lambda (x)
4012
+ ;; Use a space in the prefix to avoid potential -Wunused-toplevel
4013
+ ;; warning
4014
+ (define prefix (string->symbol "% "))
4015
+ (define (make-procedure-name name)
4016
+ (datum->syntax name
4017
+ (symbol-append prefix (syntax->datum name)
4018
+ '-procedure)))
4019
+
4020
+ (syntax-case x ()
4021
+ ((_ (name formals ...) body ...)
4022
+ (identifier? #'name)
4023
+ (with-syntax ((proc-name (make-procedure-name #'name))
4024
+ ((args ...) (generate-temporaries #'(formals ...))))
4025
+ #`(begin
4026
+ (define (proc-name formals ...)
4027
+ (syntax-parameterize ((name (identifier-syntax proc-name)))
4028
+ body ...))
4029
+ (define-syntax-parameter name
4030
+ (lambda (x)
4031
+ (syntax-case x ()
4032
+ ((_ args ...)
4033
+ #'((syntax-parameterize ((name (identifier-syntax proc-name)))
4034
+ (lambda (formals ...)
4035
+ body ...))
4036
+ args ...))
4037
+ ((_ a (... ...))
4038
+ (syntax-violation 'name "Wrong number of arguments" x))
4039
+ (_
4040
+ (identifier? x)
4041
+ #'proc-name))))))))))
4042
+
4043
+
4044
+
4045
+ (define using-readline?
4046
+ (let ((using-readline? (make-fluid)))
4047
+ (make-procedure-with-setter
4048
+ (lambda () (fluid-ref using-readline?))
4049
+ (lambda (v) (fluid-set! using-readline? v)))))
4050
+
4051
+
4052
+
4053
+ ;;; {Deprecated stuff}
4054
+ ;;;
4055
+
4056
+ (begin-deprecated
4057
+ (module-use! the-scm-module (resolve-interface '(ice-9 deprecated))))
4058
+
4059
+
4060
+
4061
+ ;;; {Ports}
4062
+ ;;;
4063
+
4064
+ ;; Allow code in (guile) to use port bindings.
4065
+ (module-use! the-root-module (resolve-interface '(ice-9 ports)))
4066
+ ;; Allow users of (guile) to see port bindings.
4067
+ (module-use! the-scm-module (resolve-interface '(ice-9 ports)))
4068
+
4069
+
4070
+
4071
+ ;;; {Threads}
4072
+ ;;;
4073
+
4074
+ ;; Load (ice-9 threads), initializing some internal data structures.
4075
+ (resolve-interface '(ice-9 threads))
4076
+
4077
+
4078
+
4079
+ ;;; SRFI-4 in the default environment. FIXME: we should figure out how
4080
+ ;;; to deprecate this.
4081
+ ;;;
4082
+
4083
+ ;; FIXME:
4084
+ (module-use! the-scm-module (resolve-interface '(srfi srfi-4)))
4085
+
4086
+
4087
+
4088
+ ;;; A few identifiers that need to be defined in this file are really
4089
+ ;;; internal implementation details. We shove them off into internal
4090
+ ;;; modules, removing them from the (guile) module.
4091
+ ;;;
4092
+
4093
+ (define-module (system syntax internal))
4094
+
4095
+ (let ()
4096
+ (define (steal-bindings! from to ids)
4097
+ (for-each
4098
+ (lambda (sym)
4099
+ (let ((v (module-local-variable from sym)))
4100
+ (module-remove! from sym)
4101
+ (module-add! to sym v)))
4102
+ ids)
4103
+ (module-export! to ids))
4104
+
4105
+ (steal-bindings! the-root-module (resolve-module '(system syntax internal))
4106
+ '(syntax?
4107
+ syntax-local-binding
4108
+ %syntax-module
4109
+ syntax-locally-bound-identifiers
4110
+ syntax-session-id
4111
+ make-syntax
4112
+ syntax-expression
4113
+ syntax-wrap
4114
+ syntax-module)))
4115
+
4116
+
4117
+
4118
+
4119
+ ;;; Place the user in the guile-user module.
4120
+ ;;;
4121
+
4122
+ ;; Set filename to #f to prevent reload.
4123
+ (define-module (guile-user)
4124
+ #:autoload (system base compile) (compile compile-file)
4125
+ #:filename #f)
4126
+
4127
+ ;; Remain in the `(guile)' module at compilation-time so that the
4128
+ ;; `-Wunused-toplevel' warning works as expected.
4129
+ (eval-when (compile) (set-current-module the-root-module))
4130
+
4131
+ ;;; boot-9.scm ends here