diff --git a/node-addon-lilypond/output/extra/libc.so.6 b/node-addon-lilypond/output/extra/libc.so.6 new file mode 100755 index 0000000000000000000000000000000000000000..cc6e394feaef2e99207d6d6944bc6666a75cc23b --- /dev/null +++ b/node-addon-lilypond/output/extra/libc.so.6 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:467d8d5596e31cec78cdcde0c589bd04c031ec36598531bfd77e346ac447d9d6 +size 2030928 diff --git a/node-addon-lilypond/output/extra/libdl.so.2 b/node-addon-lilypond/output/extra/libdl.so.2 new file mode 100755 index 0000000000000000000000000000000000000000..416de71c20b0dbddea229efa7561a50a767667e9 --- /dev/null +++ b/node-addon-lilypond/output/extra/libdl.so.2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:398f33bacb604813ef22a5ae10b73a319180a6467a5e3e60a412dd271b2aff3b +size 14560 diff --git a/node-addon-lilypond/output/extra/libexpat.so.1 b/node-addon-lilypond/output/extra/libexpat.so.1 new file mode 100755 index 0000000000000000000000000000000000000000..12acf6bbd74c70b42805b0bbb81007be78f167b9 --- /dev/null +++ b/node-addon-lilypond/output/extra/libexpat.so.1 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f15cdbce5b1b9a0032fe1ab4e17eea95601dd8a6404ba20c98a7103e3089676e +size 202880 diff --git a/node-addon-lilypond/output/extra/libgcc_s.so.1 b/node-addon-lilypond/output/extra/libgcc_s.so.1 new file mode 100755 index 0000000000000000000000000000000000000000..6215586e830023117cb7847fd9888833d232cbe0 --- /dev/null +++ b/node-addon-lilypond/output/extra/libgcc_s.so.1 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2f0e486606bd477c6a6ad3588176a16099ed05a8bf47cf3bd27b490bea3d59e9 +size 96616 diff --git a/node-addon-lilypond/output/extra/libgmp.so.10 b/node-addon-lilypond/output/extra/libgmp.so.10 new file mode 100755 index 0000000000000000000000000000000000000000..818444e946b5b2f47267d78fb9de5fa0f5e47220 --- /dev/null +++ b/node-addon-lilypond/output/extra/libgmp.so.10 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d54e955d21688b5b840ac49dda592be5e1f5546df67eb18fea400116e76b9852 +size 526688 diff --git a/node-addon-lilypond/output/extra/libm.so.6 b/node-addon-lilypond/output/extra/libm.so.6 new file mode 100755 index 0000000000000000000000000000000000000000..fc98acb7b5f0e225bd75a9d846025413badbfedd --- /dev/null +++ b/node-addon-lilypond/output/extra/libm.so.6 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:464dcab115cca26b8715cf3521f9ca1d9b7eb6b0500b7d3bed7a2353fd744c52 +size 1700792 diff --git a/node-addon-lilypond/output/extra/libpcre.so.3 b/node-addon-lilypond/output/extra/libpcre.so.3 new file mode 100755 index 0000000000000000000000000000000000000000..17b002efd37d64ee13c43a6831181f23b7bd5de8 --- /dev/null +++ b/node-addon-lilypond/output/extra/libpcre.so.3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d14920b8c1cb4e4cbe5f7c9ad23f6d9cf7b4ab1ddce1a29c9fc766b51c29ebea +size 464824 diff --git a/node-addon-lilypond/output/extra/libpthread.so.0 b/node-addon-lilypond/output/extra/libpthread.so.0 new file mode 100755 index 0000000000000000000000000000000000000000..9ffd918a22c0ec7319fa838d0b1cf0d061b95809 --- /dev/null +++ b/node-addon-lilypond/output/extra/libpthread.so.0 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:99c0999f13790d4365986180bc2e6dccbabd4d9b874a76799014c0c397e8f02a +size 144976 diff --git a/node-addon-lilypond/output/extra/libstdc++.so.6 b/node-addon-lilypond/output/extra/libstdc++.so.6 new file mode 100755 index 0000000000000000000000000000000000000000..44f16f21a7a2fec8626b4d3530075595047e6e04 --- /dev/null +++ b/node-addon-lilypond/output/extra/libstdc++.so.6 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a7ce5e3ab89895f02ad5d55f6b2090c3882ba5f4e12fbd9b96f0ed1712e2a1f6 +size 1594864 diff --git a/node-addon-lilypond/output/extra/libz.so.1 b/node-addon-lilypond/output/extra/libz.so.1 new file mode 100755 index 0000000000000000000000000000000000000000..6986690f1b744a60fdcead6bcba92726232536cc --- /dev/null +++ b/node-addon-lilypond/output/extra/libz.so.1 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:219c6c0efe93bd6d751bba1e8ae84a162309c665cc5e36beddcf295b72f9bc09 +size 116960 diff --git a/node-addon-lilypond/output/libdatrie.so.1 b/node-addon-lilypond/output/libdatrie.so.1 new file mode 100755 index 0000000000000000000000000000000000000000..0f5cc812cef5bbb72bd0f54906024e6944b6d22c --- /dev/null +++ b/node-addon-lilypond/output/libdatrie.so.1 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6c30fb636f01c4bbce7a5ac3eadcba61720d0821a2cbaa5238a675b7370caaad +size 26544 diff --git a/node-addon-lilypond/output/libffi.so.6 b/node-addon-lilypond/output/libffi.so.6 new file mode 100755 index 0000000000000000000000000000000000000000..c9b61d6d2a0abc43ea6b42c9181d3f75946be507 --- /dev/null +++ b/node-addon-lilypond/output/libffi.so.6 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5a675e4f4e40312eebbaf9816e009793a394ae9385115bf10b82b83643f84963 +size 31032 diff --git a/node-addon-lilypond/output/libfontconfig.so.1 b/node-addon-lilypond/output/libfontconfig.so.1 new file mode 100755 index 0000000000000000000000000000000000000000..c7295f5640f7f2fdcb78005b19bc827954b3811c --- /dev/null +++ b/node-addon-lilypond/output/libfontconfig.so.1 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7a8a2c7373cd9483fa9af3e797a33144979de9125d578bb6b63e47f56e4f58de +size 281984 diff --git a/node-addon-lilypond/output/libfreetype.so.6 b/node-addon-lilypond/output/libfreetype.so.6 new file mode 100755 index 0000000000000000000000000000000000000000..389df8f25886944a345a8dc29e831b2ac44de736 --- /dev/null +++ b/node-addon-lilypond/output/libfreetype.so.6 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d2e48e02376decc11d1b8cf5b09c8e0f991d31d8909d0fd2c006dc2b1209e860 +size 735704 diff --git a/node-addon-lilypond/output/libglib-2.0.so.0 b/node-addon-lilypond/output/libglib-2.0.so.0 new file mode 100755 index 0000000000000000000000000000000000000000..44e669b71a221a8d7af341ad4109d9852a85f70a --- /dev/null +++ b/node-addon-lilypond/output/libglib-2.0.so.0 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9450de63b8dfe0e3dfc753d77c8cf86531365efeccee68578dd6b08ad9a68779 +size 1137968 diff --git a/node-addon-lilypond/output/libgobject-2.0.so.0 b/node-addon-lilypond/output/libgobject-2.0.so.0 new file mode 100755 index 0000000000000000000000000000000000000000..618bfad9870adb296a225ce40fa79f32fc61a0fe --- /dev/null +++ b/node-addon-lilypond/output/libgobject-2.0.so.0 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:677342b9e18f64c658d7b8133ecc8c5654cbca07484fdceabdbd2331e18e4cd8 +size 342072 diff --git a/node-addon-lilypond/output/libgraphite2.so.3 b/node-addon-lilypond/output/libgraphite2.so.3 new file mode 100755 index 0000000000000000000000000000000000000000..1f022fa71b990557af838ecf6d4a038c4e2d5000 --- /dev/null +++ b/node-addon-lilypond/output/libgraphite2.so.3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5efccb06571c46f4aef27805688f4dc5e168d1224edea3fc61b339f2a33aa348 +size 182424 diff --git a/node-addon-lilypond/output/libguile-srfi-srfi-1-v-3.so b/node-addon-lilypond/output/libguile-srfi-srfi-1-v-3.so new file mode 100755 index 0000000000000000000000000000000000000000..9b51b55e7599ab4440580c12fb47bdde3b74417c --- /dev/null +++ b/node-addon-lilypond/output/libguile-srfi-srfi-1-v-3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dfb0db9ad891809b90ed161022eb340959d93ec701b2c88b1aa437fe4f284b74 +size 108192 diff --git a/node-addon-lilypond/output/libguile.so b/node-addon-lilypond/output/libguile.so new file mode 100755 index 0000000000000000000000000000000000000000..73381511af11beecbe30a755d95eab00e95e98c3 --- /dev/null +++ b/node-addon-lilypond/output/libguile.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6722c0302a80aa446436ad49fdc0678ebd0782ed92ddea70ebf9e0e902ebebf3 +size 1235424 diff --git a/node-addon-lilypond/output/libharfbuzz.so.0 b/node-addon-lilypond/output/libharfbuzz.so.0 new file mode 100755 index 0000000000000000000000000000000000000000..e3d50b29524dda884a7ef6437294a9affb49fd93 --- /dev/null +++ b/node-addon-lilypond/output/libharfbuzz.so.0 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3ed819725042eb62aed9c0e257ad35e9d6834912a8ceafccd5333005567cac0a +size 646064 diff --git a/node-addon-lilypond/output/liblilypond.so b/node-addon-lilypond/output/liblilypond.so new file mode 100755 index 0000000000000000000000000000000000000000..2843d719fa0999d2789983b1857f93fc7bb99334 --- /dev/null +++ b/node-addon-lilypond/output/liblilypond.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:25cfa4b0972c0dbaa66e71b5a652479e3a67a3611cf518614317a8819f075711 +size 8707312 diff --git a/node-addon-lilypond/output/libpango-1.0.so.0 b/node-addon-lilypond/output/libpango-1.0.so.0 new file mode 100755 index 0000000000000000000000000000000000000000..c72f1994c63defa37237fe81824a9f507474bb8e --- /dev/null +++ b/node-addon-lilypond/output/libpango-1.0.so.0 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d0bb21da459593889d1f60319779d35840915620d0f96c385c4711a32199e26a +size 313264 diff --git a/node-addon-lilypond/output/libpangoft2-1.0.so.0 b/node-addon-lilypond/output/libpangoft2-1.0.so.0 new file mode 100755 index 0000000000000000000000000000000000000000..394dd9f0daec214b0a4ab8d1ad73050fb2eb2ede --- /dev/null +++ b/node-addon-lilypond/output/libpangoft2-1.0.so.0 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2663e090308fd304b0931775da8c4664f8871ddc4392937178e2e996818b36f8 +size 87904 diff --git a/node-addon-lilypond/output/libpng16.so.16 b/node-addon-lilypond/output/libpng16.so.16 new file mode 100755 index 0000000000000000000000000000000000000000..e71f3a86c8532201582f89078f915a2b5bc3aabb --- /dev/null +++ b/node-addon-lilypond/output/libpng16.so.16 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0353da90d7c3699685c99c2cabf17d7b4a4212c3a2d6c29beb739e1c83da418e +size 202672 diff --git a/node-addon-lilypond/output/libthai.so.0 b/node-addon-lilypond/output/libthai.so.0 new file mode 100755 index 0000000000000000000000000000000000000000..6b2d364c651e611df5e0c39bcc9ed0eff01d7953 --- /dev/null +++ b/node-addon-lilypond/output/libthai.so.0 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:39373a82e85412d5a6ed68d2ff3e37da5452895894844eb8523eca5f3c687092 +size 36904 diff --git a/node-addon-lilypond/output/lilypond.node b/node-addon-lilypond/output/lilypond.node new file mode 100755 index 0000000000000000000000000000000000000000..0a0363b765a233f482acd10856cb210437157e11 --- /dev/null +++ b/node-addon-lilypond/output/lilypond.node @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:980e421accd2cc159019be6c9cfe0a32d77b2eb7fd702070f3910f9c3cc4ff54 +size 305080 diff --git a/node-addon-lilypond/output/share/guile/1.8/guile-procedures.txt b/node-addon-lilypond/output/share/guile/1.8/guile-procedures.txt new file mode 100755 index 0000000000000000000000000000000000000000..48ada710875d9f8cdf26921366388858182791ea --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/guile-procedures.txt @@ -0,0 +1,7539 @@ +This is guile-procedures.txt, produced by makeinfo version 6.5 from +guile-procedures.texi. + + acons + -- Scheme Procedure: acons key value alist + Add a new key-value pair to ALIST. A new pair is created whose car + is KEY and whose cdr is VALUE, and the pair is consed onto ALIST, + and the new list is returned. This function is _not_ destructive; + ALIST is not modified. + + sloppy-assq + -- Scheme Procedure: sloppy-assq key alist + Behaves like 'assq' but does not do any error checking. + Recommended only for use in Guile internals. + + sloppy-assv + -- Scheme Procedure: sloppy-assv key alist + Behaves like 'assv' but does not do any error checking. + Recommended only for use in Guile internals. + + sloppy-assoc + -- Scheme Procedure: sloppy-assoc key alist + Behaves like 'assoc' but does not do any error checking. + Recommended only for use in Guile internals. + + assq + -- Scheme Procedure: assq key alist + -- Scheme Procedure: assv key alist + -- Scheme Procedure: assoc key alist + Fetch the entry in ALIST that is associated with KEY. To decide + whether the argument KEY matches a particular entry in ALIST, + 'assq' compares keys with 'eq?', 'assv' uses 'eqv?' and 'assoc' + uses 'equal?'. If KEY cannot be found in ALIST (according to + whichever equality predicate is in use), then return '#f'. These + functions return the entire alist entry found (i.e. both the key + and the value). + + assv + -- Scheme Procedure: assv key alist + Behaves like 'assq' but uses 'eqv?' for key comparison. + + assoc + -- Scheme Procedure: assoc key alist + Behaves like 'assq' but uses 'equal?' for key comparison. + + assq-ref + -- Scheme Procedure: assq-ref alist key + -- Scheme Procedure: assv-ref alist key + -- Scheme Procedure: assoc-ref alist key + Like 'assq', 'assv' and 'assoc', except that only the value + associated with KEY in ALIST is returned. These functions are + equivalent to + + (let ((ent (ASSOCIATOR KEY ALIST))) + (and ent (cdr ent))) + + where ASSOCIATOR is one of 'assq', 'assv' or 'assoc'. + + assv-ref + -- Scheme Procedure: assv-ref alist key + Behaves like 'assq-ref' but uses 'eqv?' for key comparison. + + assoc-ref + -- Scheme Procedure: assoc-ref alist key + Behaves like 'assq-ref' but uses 'equal?' for key comparison. + + assq-set! + -- Scheme Procedure: assq-set! alist key val + -- Scheme Procedure: assv-set! alist key value + -- Scheme Procedure: assoc-set! alist key value + Reassociate KEY in ALIST with VALUE: find any existing ALIST entry + for KEY and associate it with the new VALUE. If ALIST does not + contain an entry for KEY, add a new one. Return the (possibly new) + alist. + + These functions do not attempt to verify the structure of ALIST, + and so may cause unusual results if passed an object that is not an + association list. + + assv-set! + -- Scheme Procedure: assv-set! alist key val + Behaves like 'assq-set!' but uses 'eqv?' for key comparison. + + assoc-set! + -- Scheme Procedure: assoc-set! alist key val + Behaves like 'assq-set!' but uses 'equal?' for key comparison. + + assq-remove! + -- Scheme Procedure: assq-remove! alist key + -- Scheme Procedure: assv-remove! alist key + -- Scheme Procedure: assoc-remove! alist key + Delete the first entry in ALIST associated with KEY, and return the + resulting alist. + + assv-remove! + -- Scheme Procedure: assv-remove! alist key + Behaves like 'assq-remove!' but uses 'eqv?' for key comparison. + + assoc-remove! + -- Scheme Procedure: assoc-remove! alist key + Behaves like 'assq-remove!' but uses 'equal?' for key comparison. + + make-arbiter + -- Scheme Procedure: make-arbiter name + Return an arbiter object, initially unlocked. Currently NAME is + only used for diagnostic output. + + try-arbiter + -- Scheme Procedure: try-arbiter arb + If ARB is unlocked, then lock it and return '#t'. If ARB is + already locked, then do nothing and return '#f'. + + release-arbiter + -- Scheme Procedure: release-arbiter arb + If ARB is locked, then unlock it and return '#t'. If ARB is + already unlocked, then do nothing and return '#f'. + + Typical usage is for the thread which locked an arbiter to later + release it, but that's not required, any thread can release it. + + async + -- Scheme Procedure: async thunk + Create a new async for the procedure THUNK. + + async-mark + -- Scheme Procedure: async-mark a + Mark the async A for future execution. + + run-asyncs + -- Scheme Procedure: run-asyncs list_of_a + Execute all thunks from the asyncs of the list LIST_OF_A. + + system-async + -- Scheme Procedure: system-async thunk + This function is deprecated. You can use THUNK directly instead of + explicitly creating an async object. + + system-async-mark + -- Scheme Procedure: system-async-mark proc [thread] + Mark PROC (a procedure with zero arguments) for future execution in + THREAD. If PROC has already been marked for THREAD but has not + been executed yet, this call has no effect. If THREAD is omitted, + the thread that called 'system-async-mark' is used. + + This procedure is not safe to be called from C signal handlers. + Use 'scm_sigaction' or 'scm_sigaction_for_thread' to install signal + handlers. + + noop + -- Scheme Procedure: noop . args + Do nothing. When called without arguments, return '#f', otherwise + return the first argument. + + unmask-signals + -- Scheme Procedure: unmask-signals + Unmask signals. The returned value is not specified. + + mask-signals + -- Scheme Procedure: mask-signals + Mask signals. The returned value is not specified. + + call-with-blocked-asyncs + -- Scheme Procedure: call-with-blocked-asyncs proc + Call PROC with no arguments and block the execution of system + asyncs by one level for the current thread while it is running. + Return the value returned by PROC. + + call-with-unblocked-asyncs + -- Scheme Procedure: call-with-unblocked-asyncs proc + Call PROC with no arguments and unblock the execution of system + asyncs by one level for the current thread while it is running. + Return the value returned by PROC. + + display-error + -- Scheme Procedure: display-error stack port subr message args rest + Display an error message to the output port PORT. STACK is the + saved stack for the error, SUBR is the name of the procedure in + which the error occurred and MESSAGE is the actual error message, + which may contain formatting instructions. These will format the + arguments in the list ARGS accordingly. REST is currently ignored. + + display-application + -- Scheme Procedure: display-application frame [port [indent]] + Display a procedure application FRAME to the output port PORT. + INDENT specifies the indentation of the output. + + display-backtrace + -- Scheme Procedure: display-backtrace stack port [first [depth + [highlights]]] + Display a backtrace to the output port PORT. STACK is the stack to + take the backtrace from, FIRST specifies where in the stack to + start and DEPTH how much frames to display. Both FIRST and DEPTH + can be '#f', which means that default values will be used. When + HIGHLIGHTS is given, it should be a list and all members of it are + highligthed in the backtrace. + + backtrace + -- Scheme Procedure: backtrace [highlights] + Display a backtrace of the stack saved by the last error to the + current output port. When HIGHLIGHTS is given, it should be a list + and all members of it are highligthed in the backtrace. + + not + -- Scheme Procedure: not x + Return '#t' iff X is '#f', else return '#f'. + + boolean? + -- Scheme Procedure: boolean? obj + Return '#t' iff OBJ is either '#t' or '#f'. + + char? + -- Scheme Procedure: char? x + Return '#t' iff X is a character, else '#f'. + + char=? + -- Scheme Procedure: char=? x y + Return '#t' iff X is the same character as Y, else '#f'. + + char? + -- Scheme Procedure: char>? x y + Return '#t' iff X is greater than Y in the ASCII sequence, else + '#f'. + + char>=? + -- Scheme Procedure: char>=? x y + Return '#t' iff X is greater than or equal to Y in the ASCII + sequence, else '#f'. + + char-ci=? + -- Scheme Procedure: char-ci=? x y + Return '#t' iff X is the same character as Y ignoring case, else + '#f'. + + char-ci? + -- Scheme Procedure: char-ci>? x y + Return '#t' iff X is greater than Y in the ASCII sequence ignoring + case, else '#f'. + + char-ci>=? + -- Scheme Procedure: char-ci>=? x y + Return '#t' iff X is greater than or equal to Y in the ASCII + sequence ignoring case, else '#f'. + + char-alphabetic? + -- Scheme Procedure: char-alphabetic? chr + Return '#t' iff CHR is alphabetic, else '#f'. + + char-numeric? + -- Scheme Procedure: char-numeric? chr + Return '#t' iff CHR is numeric, else '#f'. + + char-whitespace? + -- Scheme Procedure: char-whitespace? chr + Return '#t' iff CHR is whitespace, else '#f'. + + char-upper-case? + -- Scheme Procedure: char-upper-case? chr + Return '#t' iff CHR is uppercase, else '#f'. + + char-lower-case? + -- Scheme Procedure: char-lower-case? chr + Return '#t' iff CHR is lowercase, else '#f'. + + char-is-both? + -- Scheme Procedure: char-is-both? chr + Return '#t' iff CHR is either uppercase or lowercase, else '#f'. + + char->integer + -- Scheme Procedure: char->integer chr + Return the number corresponding to ordinal position of CHR in the + ASCII sequence. + + integer->char + -- Scheme Procedure: integer->char n + Return the character at position N in the ASCII sequence. + + char-upcase + -- Scheme Procedure: char-upcase chr + Return the uppercase character version of CHR. + + char-downcase + -- Scheme Procedure: char-downcase chr + Return the lowercase character version of CHR. + + with-continuation-barrier + -- Scheme Procedure: with-continuation-barrier proc + Call PROC and return its result. Do not allow the invocation of + continuations that would leave or enter the dynamic extent of the + call to 'with-continuation-barrier'. Such an attempt causes an + error to be signaled. + + Throws (such as errors) that are not caught from within PROC are + caught by 'with-continuation-barrier'. In that case, a short + message is printed to the current error port and '#f' is returned. + + Thus, 'with-continuation-barrier' returns exactly once. + + debug-options-interface + -- Scheme Procedure: debug-options-interface [setting] + Option interface for the debug options. Instead of using this + procedure directly, use the procedures 'debug-enable', + 'debug-disable', 'debug-set!' and 'debug-options'. + + with-traps + -- Scheme Procedure: with-traps thunk + Call THUNK with traps enabled. + + memoized? + -- Scheme Procedure: memoized? obj + Return '#t' if OBJ is memoized. + + unmemoize-expr + -- Scheme Procedure: unmemoize-expr m + Unmemoize the memoized expression M, + + memoized-environment + -- Scheme Procedure: memoized-environment m + Return the environment of the memoized expression M. + + procedure-name + -- Scheme Procedure: procedure-name proc + Return the name of the procedure PROC + + procedure-source + -- Scheme Procedure: procedure-source proc + Return the source of the procedure PROC. + + procedure-environment + -- Scheme Procedure: procedure-environment proc + Return the environment of the procedure PROC. + + local-eval + -- Scheme Procedure: local-eval exp [env] + Evaluate EXP in its environment. If ENV is supplied, it is the + environment in which to evaluate EXP. Otherwise, EXP must be a + memoized code object (in which case, its environment is implicit). + + debug-object? + -- Scheme Procedure: debug-object? obj + Return '#t' if OBJ is a debug object. + + issue-deprecation-warning + -- Scheme Procedure: issue-deprecation-warning . msgs + Output MSGS to '(current-error-port)' when this is the first call + to 'issue-deprecation-warning' with this specific MSGS. Do nothing + otherwise. The argument MSGS should be a list of strings; they are + printed in turn, each one followed by a newline. + + include-deprecated-features + -- Scheme Procedure: include-deprecated-features + Return '#t' iff deprecated features should be included in public + interfaces. + + substring-move-left! + -- Scheme Procedure: substring-move-left! + implemented by the C function "scm_substring_move_x" + + substring-move-right! + -- Scheme Procedure: substring-move-right! + implemented by the C function "scm_substring_move_x" + + c-registered-modules + -- Scheme Procedure: c-registered-modules + Return a list of the object code modules that have been imported + into the current Guile process. Each element of the list is a pair + whose car is the name of the module, and whose cdr is the function + handle for that module's initializer function. The name is the + string that has been passed to scm_register_module_xxx. + + c-clear-registered-modules + -- Scheme Procedure: c-clear-registered-modules + Destroy the list of modules registered with the current Guile + process. The return value is unspecified. *Warning:* this + function does not actually unlink or deallocate these modules, but + only destroys the records of which modules have been loaded. It + should therefore be used only by module bookkeeping operations. + + close-all-ports-except + -- Scheme Procedure: close-all-ports-except . ports + [DEPRECATED] Close all open file ports used by the interpreter + except for those supplied as arguments. This procedure was + intended to be used before an exec call to close file descriptors + which are not needed in the new process. However it has the + undesirable side effect of flushing buffers, so it's deprecated. + Use port-for-each instead. + + variable-set-name-hint! + -- Scheme Procedure: variable-set-name-hint! var hint + Do not use this function. + + builtin-variable + -- Scheme Procedure: builtin-variable name + Do not use this function. + + sloppy-memq + -- Scheme Procedure: sloppy-memq x lst + This procedure behaves like 'memq', but does no type or error + checking. Its use is recommended only in writing Guile internals, + not for high-level Scheme programs. + + sloppy-memv + -- Scheme Procedure: sloppy-memv x lst + This procedure behaves like 'memv', but does no type or error + checking. Its use is recommended only in writing Guile internals, + not for high-level Scheme programs. + + sloppy-member + -- Scheme Procedure: sloppy-member x lst + This procedure behaves like 'member', but does no type or error + checking. Its use is recommended only in writing Guile internals, + not for high-level Scheme programs. + + read-and-eval! + -- Scheme Procedure: read-and-eval! [port] + Read a form from PORT (standard input by default), and evaluate it + (memoizing it in the process) in the top-level environment. If no + data is left to be read from PORT, an 'end-of-file' error is + signalled. + + string->obarray-symbol + -- Scheme Procedure: string->obarray-symbol o s [softp] + Intern a new symbol in OBARRAY, a symbol table, with name STRING. + + If OBARRAY is '#f', use the default system symbol table. If + OBARRAY is '#t', the symbol should not be interned in any symbol + table; merely return the pair (SYMBOL . #). + + The SOFT? argument determines whether new symbol table entries + should be created when the specified symbol is not already present + in OBARRAY. If SOFT? is specified and is a true value, then new + entries should not be added for symbols not already present in the + table; instead, simply return '#f'. + + intern-symbol + -- Scheme Procedure: intern-symbol o s + Add a new symbol to OBARRAY with name STRING, bound to an + unspecified initial value. The symbol table is not modified if a + symbol with this name is already present. + + unintern-symbol + -- Scheme Procedure: unintern-symbol o s + Remove the symbol with name STRING from OBARRAY. This function + returns '#t' if the symbol was present and '#f' otherwise. + + symbol-binding + -- Scheme Procedure: symbol-binding o s + Look up in OBARRAY the symbol whose name is STRING, and return the + value to which it is bound. If OBARRAY is '#f', use the global + symbol table. If STRING is not interned in OBARRAY, an error is + signalled. + + symbol-bound? + -- Scheme Procedure: symbol-bound? o s + Return '#t' if OBARRAY contains a symbol with name STRING bound to + a defined value. This differs from SYMBOL-INTERNED? in that the + mere mention of a symbol usually causes it to be interned; + 'symbol-bound?' determines whether a symbol has been given any + meaningful value. + + symbol-set! + -- Scheme Procedure: symbol-set! o s v + Find the symbol in OBARRAY whose name is STRING, and rebind it to + VALUE. An error is signalled if STRING is not present in OBARRAY. + + gentemp + -- Scheme Procedure: gentemp [prefix [obarray]] + Create a new symbol with a name unique in an obarray. The name is + constructed from an optional string PREFIX and a counter value. + The default prefix is 't'. The OBARRAY is specified as a second + optional argument. Default is the system obarray where all normal + symbols are interned. The counter is increased by 1 at each call. + There is no provision for resetting the counter. + + guardian-destroyed? + -- Scheme Procedure: guardian-destroyed? guardian + Return '#t' if GUARDIAN has been destroyed, otherwise '#f'. + + guardian-greedy? + -- Scheme Procedure: guardian-greedy? guardian + Return '#t' if GUARDIAN is a greedy guardian, otherwise '#f'. + + destroy-guardian! + -- Scheme Procedure: destroy-guardian! guardian + Destroys GUARDIAN, by making it impossible to put any more objects + in it or get any objects from it. It also unguards any objects + guarded by GUARDIAN. + + make-keyword-from-dash-symbol + -- Scheme Procedure: make-keyword-from-dash-symbol symbol + Make a keyword object from a SYMBOL that starts with a dash. + + keyword-dash-symbol + -- Scheme Procedure: keyword-dash-symbol keyword + Return the dash symbol for KEYWORD. This is the inverse of + 'make-keyword-from-dash-symbol'. + + dynamic-link + -- Scheme Procedure: dynamic-link filename + Find the shared object (shared library) denoted by FILENAME and + link it into the running Guile application. The returned scheme + object is a "handle" for the library which can be passed to + 'dynamic-func', 'dynamic-call' etc. + + Searching for object files is system dependent. Normally, if + FILENAME does have an explicit directory it will be searched for in + locations such as '/usr/lib' and '/usr/local/lib'. + + dynamic-object? + -- Scheme Procedure: dynamic-object? obj + Return '#t' if OBJ is a dynamic object handle, or '#f' otherwise. + + dynamic-unlink + -- Scheme Procedure: dynamic-unlink dobj + Unlink a dynamic object from the application, if possible. The + object must have been linked by 'dynamic-link', with DOBJ the + corresponding handle. After this procedure is called, the handle + can no longer be used to access the object. + + dynamic-func + -- Scheme Procedure: dynamic-func name dobj + Return a "handle" for the function NAME in the shared object + referred to by DOBJ. The handle can be passed to 'dynamic-call' to + actually call the function. + + Regardless whether your C compiler prepends an underscore '_' to + the global names in a program, you should *not* include this + underscore in NAME since it will be added automatically when + necessary. + + dynamic-call + -- Scheme Procedure: dynamic-call func dobj + Call a C function in a dynamic object. Two styles of invocation + are supported: + + * FUNC can be a function handle returned by 'dynamic-func'. In + this case DOBJ is ignored + * FUNC can be a string with the name of the function to call, + with DOBJ the handle of the dynamic object in which to find + the function. This is equivalent to + + (dynamic-call (dynamic-func FUNC DOBJ) #f) + + In either case, the function is passed no arguments and its return + value is ignored. + + dynamic-args-call + -- Scheme Procedure: dynamic-args-call func dobj args + Call the C function indicated by FUNC and DOBJ, just like + 'dynamic-call', but pass it some arguments and return its return + value. The C function is expected to take two arguments and return + an 'int', just like 'main': + int c_func (int argc, char **argv); + + The parameter ARGS must be a list of strings and is converted into + an array of 'char *'. The array is passed in ARGV and its size in + ARGC. The return value is converted to a Scheme number and + returned from the call to 'dynamic-args-call'. + + dynamic-wind + -- Scheme Procedure: dynamic-wind in_guard thunk out_guard + All three arguments must be 0-argument procedures. IN_GUARD is + called, then THUNK, then OUT_GUARD. + + If, any time during the execution of THUNK, the continuation of the + 'dynamic_wind' expression is escaped non-locally, OUT_GUARD is + called. If the continuation of the dynamic-wind is re-entered, + IN_GUARD is called. Thus IN_GUARD and OUT_GUARD may be called any + number of times. + (define x 'normal-binding) + => x + (define a-cont (call-with-current-continuation + (lambda (escape) + (let ((old-x x)) + (dynamic-wind + ;; in-guard: + ;; + (lambda () (set! x 'special-binding)) + + ;; thunk + ;; + (lambda () (display x) (newline) + (call-with-current-continuation escape) + (display x) (newline) + x) + + ;; out-guard: + ;; + (lambda () (set! x old-x))))))) + + ;; Prints: + special-binding + ;; Evaluates to: + => a-cont + x + => normal-binding + (a-cont #f) + ;; Prints: + special-binding + ;; Evaluates to: + => a-cont ;; the value of the (define a-cont...) + x + => normal-binding + a-cont + => special-binding + + environment? + -- Scheme Procedure: environment? obj + Return '#t' if OBJ is an environment, or '#f' otherwise. + + environment-bound? + -- Scheme Procedure: environment-bound? env sym + Return '#t' if SYM is bound in ENV, or '#f' otherwise. + + environment-ref + -- Scheme Procedure: environment-ref env sym + Return the value of the location bound to SYM in ENV. If SYM is + unbound in ENV, signal an 'environment:unbound' error. + + environment-fold + -- Scheme Procedure: environment-fold env proc init + Iterate over all the bindings in ENV, accumulating some value. For + each binding in ENV, apply PROC to the symbol bound, its value, and + the result from the previous application of PROC. Use INIT as + PROC's third argument the first time PROC is applied. If ENV + contains no bindings, this function simply returns INIT. If ENV + binds the symbol sym1 to the value val1, sym2 to val2, and so on, + then this procedure computes: + (proc sym1 val1 + (proc sym2 val2 + ... + (proc symn valn + init))) + Each binding in ENV will be processed exactly once. + 'environment-fold' makes no guarantees about the order in which the + bindings are processed. Here is a function which, given an + environment, constructs an association list representing that + environment's bindings, using environment-fold: + (define (environment->alist env) + (environment-fold env + (lambda (sym val tail) + (cons (cons sym val) tail)) + '())) + + environment-define + -- Scheme Procedure: environment-define env sym val + Bind SYM to a new location containing VAL in ENV. If SYM is + already bound to another location in ENV and the binding is + mutable, that binding is replaced. The new binding and location + are both mutable. The return value is unspecified. If SYM is + already bound in ENV, and the binding is immutable, signal an + 'environment:immutable-binding' error. + + environment-undefine + -- Scheme Procedure: environment-undefine env sym + Remove any binding for SYM from ENV. If SYM is unbound in ENV, do + nothing. The return value is unspecified. If SYM is already bound + in ENV, and the binding is immutable, signal an + 'environment:immutable-binding' error. + + environment-set! + -- Scheme Procedure: environment-set! env sym val + If ENV binds SYM to some location, change that location's value to + VAL. The return value is unspecified. If SYM is not bound in ENV, + signal an 'environment:unbound' error. If ENV binds SYM to an + immutable location, signal an 'environment:immutable-location' + error. + + environment-cell + -- Scheme Procedure: environment-cell env sym for_write + Return the value cell which ENV binds to SYM, or '#f' if the + binding does not live in a value cell. The argument FOR-WRITE + indicates whether the caller intends to modify the variable's value + by mutating the value cell. If the variable is immutable, then + 'environment-cell' signals an 'environment:immutable-location' + error. If SYM is unbound in ENV, signal an 'environment:unbound' + error. If you use this function, you should consider using + 'environment-observe', to be notified when SYM gets re-bound to a + new value cell, or becomes undefined. + + environment-observe + -- Scheme Procedure: environment-observe env proc + Whenever ENV's bindings change, apply PROC to ENV. This function + returns an object, token, which you can pass to + 'environment-unobserve' to remove PROC from the set of procedures + observing ENV. The type and value of token is unspecified. + + environment-observe-weak + -- Scheme Procedure: environment-observe-weak env proc + This function is the same as environment-observe, except that the + reference ENV retains to PROC is a weak reference. This means + that, if there are no other live, non-weak references to PROC, it + will be garbage-collected, and dropped from ENV's list of observing + procedures. + + environment-unobserve + -- Scheme Procedure: environment-unobserve token + Cancel the observation request which returned the value TOKEN. The + return value is unspecified. If a call '(environment-observe env + proc)' returns TOKEN, then the call '(environment-unobserve token)' + will cause PROC to no longer be called when ENV's bindings change. + + make-leaf-environment + -- Scheme Procedure: make-leaf-environment + Create a new leaf environment, containing no bindings. All + bindings and locations created in the new environment will be + mutable. + + leaf-environment? + -- Scheme Procedure: leaf-environment? object + Return '#t' if object is a leaf environment, or '#f' otherwise. + + make-eval-environment + -- Scheme Procedure: make-eval-environment local imported + Return a new environment object eval whose bindings are the union + of the bindings in the environments LOCAL and IMPORTED, with + bindings from LOCAL taking precedence. Definitions made in eval + are placed in LOCAL. Applying 'environment-define' or + 'environment-undefine' to eval has the same effect as applying the + procedure to LOCAL. Note that eval incorporates LOCAL and IMPORTED + by reference: If, after creating eval, the program changes the + bindings of LOCAL or IMPORTED, those changes will be visible in + eval. Since most Scheme evaluation takes place in eval + environments, they transparently cache the bindings received from + LOCAL and IMPORTED. Thus, the first time the program looks up a + symbol in eval, eval may make calls to LOCAL or IMPORTED to find + their bindings, but subsequent references to that symbol will be as + fast as references to bindings in finite environments. In typical + use, LOCAL will be a finite environment, and IMPORTED will be an + import environment + + eval-environment? + -- Scheme Procedure: eval-environment? object + Return '#t' if object is an eval environment, or '#f' otherwise. + + eval-environment-local + -- Scheme Procedure: eval-environment-local env + Return the local environment of eval environment ENV. + + eval-environment-set-local! + -- Scheme Procedure: eval-environment-set-local! env local + Change ENV's local environment to LOCAL. + + eval-environment-imported + -- Scheme Procedure: eval-environment-imported env + Return the imported environment of eval environment ENV. + + eval-environment-set-imported! + -- Scheme Procedure: eval-environment-set-imported! env imported + Change ENV's imported environment to IMPORTED. + + make-import-environment + -- Scheme Procedure: make-import-environment imports conflict_proc + Return a new environment IMP whose bindings are the union of the + bindings from the environments in IMPORTS; IMPORTS must be a list + of environments. That is, IMP binds a symbol to a location when + some element of IMPORTS does. If two different elements of IMPORTS + have a binding for the same symbol, the CONFLICT-PROC is called + with the following parameters: the import environment, the symbol + and the list of the imported environments that bind the symbol. If + the CONFLICT-PROC returns an environment ENV, the conflict is + considered as resolved and the binding from ENV is used. If the + CONFLICT-PROC returns some non-environment object, the conflict is + considered unresolved and the symbol is treated as unspecified in + the import environment. The checking for conflicts may be + performed lazily, i. e. at the moment when a value or binding for + a certain symbol is requested instead of the moment when the + environment is created or the bindings of the imports change. All + bindings in IMP are immutable. If you apply 'environment-define' + or 'environment-undefine' to IMP, Guile will signal an + 'environment:immutable-binding' error. However, notice that the + set of bindings in IMP may still change, if one of its imported + environments changes. + + import-environment? + -- Scheme Procedure: import-environment? object + Return '#t' if object is an import environment, or '#f' otherwise. + + import-environment-imports + -- Scheme Procedure: import-environment-imports env + Return the list of environments imported by the import environment + ENV. + + import-environment-set-imports! + -- Scheme Procedure: import-environment-set-imports! env imports + Change ENV's list of imported environments to IMPORTS, and check + for conflicts. + + make-export-environment + -- Scheme Procedure: make-export-environment private signature + Return a new environment EXP containing only those bindings in + private whose symbols are present in SIGNATURE. The PRIVATE + argument must be an environment. + + The environment EXP binds symbol to location when ENV does, and + symbol is exported by SIGNATURE. + + SIGNATURE is a list specifying which of the bindings in PRIVATE + should be visible in EXP. Each element of SIGNATURE should be a + list of the form: (symbol attribute ...) where each attribute is + one of the following: + the symbol 'mutable-location' + EXP should treat the location bound to symbol as mutable. + That is, EXP will pass calls to 'environment-set!' or + 'environment-cell' directly through to private. + the symbol 'immutable-location' + EXP should treat the location bound to symbol as immutable. + If the program applies 'environment-set!' to EXP and symbol, + or calls 'environment-cell' to obtain a writable value cell, + 'environment-set!' will signal an + 'environment:immutable-location' error. Note that, even if an + export environment treats a location as immutable, the + underlying environment may treat it as mutable, so its value + may change. + It is an error for an element of signature to specify both + 'mutable-location' and 'immutable-location'. If neither is + specified, 'immutable-location' is assumed. + + As a special case, if an element of signature is a lone symbol SYM, + it is equivalent to an element of the form '(sym)'. + + All bindings in EXP are immutable. If you apply + 'environment-define' or 'environment-undefine' to EXP, Guile will + signal an 'environment:immutable-binding' error. However, notice + that the set of bindings in EXP may still change, if the bindings + in private change. + + export-environment? + -- Scheme Procedure: export-environment? object + Return '#t' if object is an export environment, or '#f' otherwise. + + export-environment-private + -- Scheme Procedure: export-environment-private env + Return the private environment of export environment ENV. + + export-environment-set-private! + -- Scheme Procedure: export-environment-set-private! env private + Change the private environment of export environment ENV. + + export-environment-signature + -- Scheme Procedure: export-environment-signature env + Return the signature of export environment ENV. + + export-environment-set-signature! + -- Scheme Procedure: export-environment-set-signature! env signature + Change the signature of export environment ENV. + + eq? + -- Scheme Procedure: eq? x y + Return '#t' if X and Y are the same object, except for numbers and + characters. For example, + + (define x (vector 1 2 3)) + (define y (vector 1 2 3)) + + (eq? x x) => #t + (eq? x y) => #f + + Numbers and characters are not equal to any other object, but the + problem is they're not necessarily 'eq?' to themselves either. + This is even so when the number comes directly from a variable, + + (let ((n (+ 2 3))) + (eq? n n)) => *unspecified* + + Generally 'eqv?' should be used when comparing numbers or + characters. '=' or 'char=?' can be used too. + + It's worth noting that end-of-list '()', '#t', '#f', a symbol of a + given name, and a keyword of a given name, are unique objects. + There's just one of each, so for instance no matter how '()' arises + in a program, it's the same object and can be compared with 'eq?', + + (define x (cdr '(123))) + (define y (cdr '(456))) + (eq? x y) => #t + + (define x (string->symbol "foo")) + (eq? x 'foo) => #t + + eqv? + -- Scheme Procedure: eqv? x y + Return '#t' if X and Y are the same object, or for characters and + numbers the same value. + + On objects except characters and numbers, 'eqv?' is the same as + 'eq?', it's true if X and Y are the same object. + + If X and Y are numbers or characters, 'eqv?' compares their type + and value. An exact number is not 'eqv?' to an inexact number + (even if their value is the same). + + (eqv? 3 (+ 1 2)) => #t + (eqv? 1 1.0) => #f + + equal? + -- Scheme Procedure: equal? x y + Return '#t' if X and Y are the same type, and their contents or + value are equal. + + For a pair, string, vector or array, 'equal?' compares the + contents, and does so using using the same 'equal?' recursively, so + a deep structure can be traversed. + + (equal? (list 1 2 3) (list 1 2 3)) => #t + (equal? (list 1 2 3) (vector 1 2 3)) => #f + + For other objects, 'equal?' compares as per 'eqv?', which means + characters and numbers are compared by type and value (and like + 'eqv?', exact and inexact numbers are not 'equal?', even if their + value is the same). + + (equal? 3 (+ 1 2)) => #t + (equal? 1 1.0) => #f + + Hash tables are currently only compared as per 'eq?', so two + different tables are not 'equal?', even if their contents are the + same. + + 'equal?' does not support circular data structures, it may go into + an infinite loop if asked to compare two circular lists or similar. + + New application-defined object types (Smobs) have an 'equalp' + handler which is called by 'equal?'. This lets an application + traverse the contents or control what is considered 'equal?' for + two such objects. If there's no handler, the default is to just + compare as per 'eq?'. + + scm-error + -- Scheme Procedure: scm-error key subr message args data + Raise an error with key KEY. SUBR can be a string naming the + procedure associated with the error, or '#f'. MESSAGE is the error + message string, possibly containing '~S' and '~A' escapes. When an + error is reported, these are replaced by formatting the + corresponding members of ARGS: '~A' (was '%s' in older versions of + Guile) formats using 'display' and '~S' (was '%S') formats using + 'write'. DATA is a list or '#f' depending on KEY: if KEY is + 'system-error' then it should be a list containing the Unix 'errno' + value; If KEY is 'signal' then it should be a list containing the + Unix signal number; If KEY is 'out-of-range' or 'wrong-type-arg', + it is a list containing the bad value; otherwise it will usually be + '#f'. + + strerror + -- Scheme Procedure: strerror err + Return the Unix error message corresponding to ERR, which must be + an integer value. + + apply:nconc2last + -- Scheme Procedure: apply:nconc2last lst + Given a list (ARG1 ... ARGS), this function conses the ARG1 ... + arguments onto the front of ARGS, and returns the resulting list. + Note that ARGS is a list; thus, the argument to this function is a + list whose last element is a list. Note: Rather than do new + consing, 'apply:nconc2last' destroys its argument, so use with + care. + + force + -- Scheme Procedure: force promise + If the promise X has not been computed yet, compute and return X, + otherwise just return the previously computed value. + + promise? + -- Scheme Procedure: promise? obj + Return true if OBJ is a promise, i.e. a delayed computation (*note + (r5rs.info)Delayed evaluation::). + + cons-source + -- Scheme Procedure: cons-source xorig x y + Create and return a new pair whose car and cdr are X and Y. Any + source properties associated with XORIG are also associated with + the new pair. + + copy-tree + -- Scheme Procedure: copy-tree obj + Recursively copy the data tree that is bound to OBJ, and return a + the new data structure. 'copy-tree' recurses down the contents of + both pairs and vectors (since both cons cells and vector cells may + point to arbitrary objects), and stops recursing when it hits any + other object. + + primitive-eval + -- Scheme Procedure: primitive-eval exp + Evaluate EXP in the top-level environment specified by the current + module. + + eval + -- Scheme Procedure: eval exp module_or_state + Evaluate EXP, a list representing a Scheme expression, in the + top-level environment specified by MODULE_OR_STATE. While EXP is + evaluated (using 'primitive-eval'), MODULE_OR_STATE is made the + current module when it is a module, or the current dynamic state + when it is a dynamic state.Example: (eval '(+ 1 2) + (interaction-environment)) + + eval-options-interface + -- Scheme Procedure: eval-options-interface [setting] + Option interface for the evaluation options. Instead of using this + procedure directly, use the procedures 'eval-enable', + 'eval-disable', 'eval-set!' and 'eval-options'. + + evaluator-traps-interface + -- Scheme Procedure: evaluator-traps-interface [setting] + Option interface for the evaluator trap options. + + defined? + -- Scheme Procedure: defined? sym [env] + Return '#t' if SYM is defined in the lexical environment ENV. When + ENV is not specified, look in the top-level environment as defined + by the current module. + + map-in-order + -- Scheme Procedure: map-in-order + implemented by the C function "scm_map" + + self-evaluating? + -- Scheme Procedure: self-evaluating? obj + Return #t for objects which Guile considers self-evaluating + + load-extension + -- Scheme Procedure: load-extension lib init + Load and initialize the extension designated by LIB and INIT. When + there is no pre-registered function for LIB/INIT, this is + equivalent to + + (dynamic-call INIT (dynamic-link LIB)) + + When there is a pre-registered function, that function is called + instead. + + Normally, there is no pre-registered function. This option exists + only for situations where dynamic linking is unavailable or + unwanted. In that case, you would statically link your program + with the desired library, and register its init function right + after Guile has been initialized. + + LIB should be a string denoting a shared library without any file + type suffix such as ".so". The suffix is provided automatically. + It should also not contain any directory components. Libraries + that implement Guile Extensions should be put into the normal + locations for shared libraries. We recommend to use the naming + convention libguile-bla-blum for a extension related to a module + '(bla blum)'. + + The normal way for a extension to be used is to write a small + Scheme file that defines a module, and to load the extension into + this module. When the module is auto-loaded, the extension is + loaded as well. For example, + + (define-module (bla blum)) + + (load-extension "libguile-bla-blum" "bla_init_blum") + + program-arguments + -- Scheme Procedure: program-arguments + -- Scheme Procedure: command-line + Return the list of command line arguments passed to Guile, as a + list of strings. The list includes the invoked program name, which + is usually '"guile"', but excludes switches and parameters for + command line options like '-e' and '-l'. + + set-program-arguments + -- Scheme Procedure: set-program-arguments lst + Set the command line arguments to be returned by + 'program-arguments' (and 'command-line'). LST should be a list of + strings, the first of which is the program name (either a script + name, or just '"guile"'). + + Program arguments are held in a fluid and therefore have a separate + value in each Guile thread. Neither the list nor the strings + within it are copied, so should not be modified later. + + make-fluid + -- Scheme Procedure: make-fluid + Return a newly created fluid. Fluids are objects that can hold one + value per dynamic state. That is, modifications to this value are + only visible to code that executes with the same dynamic state as + the modifying code. When a new dynamic state is constructed, it + inherits the values from its parent. Because each thread normally + executes with its own dynamic state, you can use fluids for thread + local storage. + + fluid? + -- Scheme Procedure: fluid? obj + Return '#t' iff OBJ is a fluid; otherwise, return '#f'. + + fluid-ref + -- Scheme Procedure: fluid-ref fluid + Return the value associated with FLUID in the current dynamic root. + If FLUID has not been set, then return '#f'. + + fluid-set! + -- Scheme Procedure: fluid-set! fluid value + Set the value associated with FLUID in the current dynamic root. + + with-fluids* + -- Scheme Procedure: with-fluids* fluids values thunk + Set FLUIDS to VALUES temporary, and call THUNK. FLUIDS must be a + list of fluids and VALUES must be the same number of their values + to be applied. Each substitution is done one after another. THUNK + must be a procedure with no argument. + + with-fluid* + -- Scheme Procedure: with-fluid* fluid value thunk + Set FLUID to VALUE temporarily, and call THUNK. THUNK must be a + procedure with no argument. + + make-dynamic-state + -- Scheme Procedure: make-dynamic-state [parent] + Return a copy of the dynamic state object PARENT or of the current + dynamic state when PARENT is omitted. + + dynamic-state? + -- Scheme Procedure: dynamic-state? obj + Return '#t' if OBJ is a dynamic state object; return '#f' otherwise + + current-dynamic-state + -- Scheme Procedure: current-dynamic-state + Return the current dynamic state object. + + set-current-dynamic-state + -- Scheme Procedure: set-current-dynamic-state state + Set the current dynamic state object to STATE and return the + previous current dynamic state object. + + with-dynamic-state + -- Scheme Procedure: with-dynamic-state state proc + Call PROC while STATE is the current dynamic state object. + + setvbuf + -- Scheme Procedure: setvbuf port mode [size] + Set the buffering mode for PORT. MODE can be: + '_IONBF' + non-buffered + '_IOLBF' + line buffered + '_IOFBF' + block buffered, using a newly allocated buffer of SIZE bytes. + If SIZE is omitted, a default size will be used. + + file-port? + -- Scheme Procedure: file-port? obj + Determine whether OBJ is a port that is related to a file. + + open-file + -- Scheme Procedure: open-file filename mode + Open the file whose name is FILENAME, and return a port + representing that file. The attributes of the port are determined + by the MODE string. The way in which this is interpreted is + similar to C stdio. The first character must be one of the + following: + 'r' + Open an existing file for input. + 'w' + Open a file for output, creating it if it doesn't already + exist or removing its contents if it does. + 'a' + Open a file for output, creating it if it doesn't already + exist. All writes to the port will go to the end of the file. + The "append mode" can be turned off while the port is in use + *note fcntl: Ports and File Descriptors. + The following additional characters can be appended: + 'b' + Open the underlying file in binary mode, if supported by the + operating system. + '+' + Open the port for both input and output. E.g., 'r+': open an + existing file for both input and output. + '0' + Create an "unbuffered" port. In this case input and output + operations are passed directly to the underlying port + implementation without additional buffering. This is likely + to slow down I/O operations. The buffering mode can be + changed while a port is in use *note setvbuf: Ports and File + Descriptors. + 'l' + Add line-buffering to the port. The port output buffer will + be automatically flushed whenever a newline character is + written. + In theory we could create read/write ports which were buffered in + one direction only. However this isn't included in the current + interfaces. If a file cannot be opened with the access requested, + 'open-file' throws an exception. + + gc-live-object-stats + -- Scheme Procedure: gc-live-object-stats + Return an alist of statistics of the current live objects. + + gc-stats + -- Scheme Procedure: gc-stats + Return an association list of statistics about Guile's current use + of storage. + + object-address + -- Scheme Procedure: object-address obj + Return an integer that for the lifetime of OBJ is uniquely returned + by this function for OBJ + + gc + -- Scheme Procedure: gc + Scans all of SCM objects and reclaims for further use those that + are no longer accessible. + + class-of + -- Scheme Procedure: class-of x + Return the class of X. + + %compute-slots + -- Scheme Procedure: %compute-slots class + Return a list consisting of the names of all slots belonging to + class CLASS, i. e. the slots of CLASS and of all of its + superclasses. + + get-keyword + -- Scheme Procedure: get-keyword key l default_value + Determine an associated value for the keyword KEY from the list L. + The list L has to consist of an even number of elements, where, + starting with the first, every second element is a keyword, + followed by its associated value. If L does not hold a value for + KEY, the value DEFAULT_VALUE is returned. + + %initialize-object + -- Scheme Procedure: %initialize-object obj initargs + Initialize the object OBJ with the given arguments INITARGS. + + %prep-layout! + -- Scheme Procedure: %prep-layout! class + + %inherit-magic! + -- Scheme Procedure: %inherit-magic! class dsupers + + instance? + -- Scheme Procedure: instance? obj + Return '#t' if OBJ is an instance. + + class-name + -- Scheme Procedure: class-name obj + Return the class name of OBJ. + + class-direct-supers + -- Scheme Procedure: class-direct-supers obj + Return the direct superclasses of the class OBJ. + + class-direct-slots + -- Scheme Procedure: class-direct-slots obj + Return the direct slots of the class OBJ. + + class-direct-subclasses + -- Scheme Procedure: class-direct-subclasses obj + Return the direct subclasses of the class OBJ. + + class-direct-methods + -- Scheme Procedure: class-direct-methods obj + Return the direct methods of the class OBJ + + class-precedence-list + -- Scheme Procedure: class-precedence-list obj + Return the class precedence list of the class OBJ. + + class-slots + -- Scheme Procedure: class-slots obj + Return the slot list of the class OBJ. + + class-environment + -- Scheme Procedure: class-environment obj + Return the environment of the class OBJ. + + generic-function-name + -- Scheme Procedure: generic-function-name obj + Return the name of the generic function OBJ. + + generic-function-methods + -- Scheme Procedure: generic-function-methods obj + Return the methods of the generic function OBJ. + + method-generic-function + -- Scheme Procedure: method-generic-function obj + Return the generic function for the method OBJ. + + method-specializers + -- Scheme Procedure: method-specializers obj + Return specializers of the method OBJ. + + method-procedure + -- Scheme Procedure: method-procedure obj + Return the procedure of the method OBJ. + + accessor-method-slot-definition + -- Scheme Procedure: accessor-method-slot-definition obj + Return the slot definition of the accessor OBJ. + + %tag-body + -- Scheme Procedure: %tag-body body + Internal GOOPS magic--don't use this function! + + make-unbound + -- Scheme Procedure: make-unbound + Return the unbound value. + + unbound? + -- Scheme Procedure: unbound? obj + Return '#t' if OBJ is unbound. + + assert-bound + -- Scheme Procedure: assert-bound value obj + Return VALUE if it is bound, and invoke the SLOT-UNBOUND method of + OBJ if it is not. + + @assert-bound-ref + -- Scheme Procedure: @assert-bound-ref obj index + Like 'assert-bound', but use INDEX for accessing the value from + OBJ. + + %fast-slot-ref + -- Scheme Procedure: %fast-slot-ref obj index + Return the slot value with index INDEX from OBJ. + + %fast-slot-set! + -- Scheme Procedure: %fast-slot-set! obj index value + Set the slot with index INDEX in OBJ to VALUE. + + slot-ref-using-class + -- Scheme Procedure: slot-ref-using-class class obj slot_name + + slot-set-using-class! + -- Scheme Procedure: slot-set-using-class! class obj slot_name value + + slot-bound-using-class? + -- Scheme Procedure: slot-bound-using-class? class obj slot_name + + slot-exists-using-class? + -- Scheme Procedure: slot-exists-using-class? class obj slot_name + + slot-ref + -- Scheme Procedure: slot-ref obj slot_name + Return the value from OBJ's slot with the name SLOT_NAME. + + slot-set! + -- Scheme Procedure: slot-set! obj slot_name value + Set the slot named SLOT_NAME of OBJ to VALUE. + + slot-bound? + -- Scheme Procedure: slot-bound? obj slot_name + Return '#t' if the slot named SLOT_NAME of OBJ is bound. + + slot-exists? + -- Scheme Procedure: slot-exists? obj slot_name + Return '#t' if OBJ has a slot named SLOT_NAME. + + %allocate-instance + -- Scheme Procedure: %allocate-instance class initargs + Create a new instance of class CLASS and initialize it from the + arguments INITARGS. + + %set-object-setter! + -- Scheme Procedure: %set-object-setter! obj setter + + %modify-instance + -- Scheme Procedure: %modify-instance old new + + %modify-class + -- Scheme Procedure: %modify-class old new + + %invalidate-class + -- Scheme Procedure: %invalidate-class class + + %invalidate-method-cache! + -- Scheme Procedure: %invalidate-method-cache! gf + + generic-capability? + -- Scheme Procedure: generic-capability? proc + + enable-primitive-generic! + -- Scheme Procedure: enable-primitive-generic! . subrs + + primitive-generic-generic + -- Scheme Procedure: primitive-generic-generic subr + + make + -- Scheme Procedure: make . args + Make a new object. ARGS must contain the class and all necessary + initialization information. + + find-method + -- Scheme Procedure: find-method . l + + %method-more-specific? + -- Scheme Procedure: %method-more-specific? m1 m2 targs + Return true if method M1 is more specific than M2 given the + argument types (classes) listed in TARGS. + + %goops-loaded + -- Scheme Procedure: %goops-loaded + Announce that GOOPS is loaded and perform initialization on the C + level which depends on the loaded GOOPS modules. + + make-guardian + -- Scheme Procedure: make-guardian + Create a new guardian. A guardian protects a set of objects from + garbage collection, allowing a program to apply cleanup or other + actions. + + 'make-guardian' returns a procedure representing the guardian. + Calling the guardian procedure with an argument adds the argument + to the guardian's set of protected objects. Calling the guardian + procedure without an argument returns one of the protected objects + which are ready for garbage collection, or '#f' if no such object + is available. Objects which are returned in this way are removed + from the guardian. + + You can put a single object into a guardian more than once and you + can put a single object into more than one guardian. The object + will then be returned multiple times by the guardian procedures. + + An object is eligible to be returned from a guardian when it is no + longer referenced from outside any guardian. + + There is no guarantee about the order in which objects are returned + from a guardian. If you want to impose an order on finalization + actions, for example, you can do that by keeping objects alive in + some global data structure until they are no longer needed for + finalizing other objects. + + Being an element in a weak vector, a key in a hash table with weak + keys, or a value in a hash table with weak value does not prevent + an object from being returned by a guardian. But as long as an + object can be returned from a guardian it will not be removed from + such a weak vector or hash table. In other words, a weak link does + not prevent an object from being considered collectable, but being + inside a guardian prevents a weak link from being broken. + + A key in a weak key hash table can be though of as having a strong + reference to its associated value as long as the key is accessible. + Consequently, when the key only accessible from within a guardian, + the reference from the key to the value is also considered to be + coming from within a guardian. Thus, if there is no other + reference to the value, it is eligible to be returned from a + guardian. + + hashq + -- Scheme Procedure: hashq key size + Determine a hash value for KEY that is suitable for lookups in a + hashtable of size SIZE, where 'eq?' is used as the equality + predicate. The function returns an integer in the range 0 to SIZE + - 1. Note that 'hashq' may use internal addresses. Thus two calls + to hashq where the keys are 'eq?' are not guaranteed to deliver the + same value if the key object gets garbage collected in between. + This can happen, for example with symbols: '(hashq 'foo n) (gc) + (hashq 'foo n)' may produce two different values, since 'foo' will + be garbage collected. + + hashv + -- Scheme Procedure: hashv key size + Determine a hash value for KEY that is suitable for lookups in a + hashtable of size SIZE, where 'eqv?' is used as the equality + predicate. The function returns an integer in the range 0 to SIZE + - 1. Note that '(hashv key)' may use internal addresses. Thus two + calls to hashv where the keys are 'eqv?' are not guaranteed to + deliver the same value if the key object gets garbage collected in + between. This can happen, for example with symbols: '(hashv 'foo + n) (gc) (hashv 'foo n)' may produce two different values, since + 'foo' will be garbage collected. + + hash + -- Scheme Procedure: hash key size + Determine a hash value for KEY that is suitable for lookups in a + hashtable of size SIZE, where 'equal?' is used as the equality + predicate. The function returns an integer in the range 0 to SIZE + - 1. + + make-hash-table + -- Scheme Procedure: make-hash-table [n] + Make a new abstract hash table object with minimum number of + buckets N + + make-weak-key-hash-table + -- Scheme Procedure: make-weak-key-hash-table [n] + -- Scheme Procedure: make-weak-value-hash-table size + -- Scheme Procedure: make-doubly-weak-hash-table size + Return a weak hash table with SIZE buckets. + + You can modify weak hash tables in exactly the same way you would + modify regular hash tables. (*note Hash Tables::) + + make-weak-value-hash-table + -- Scheme Procedure: make-weak-value-hash-table [n] + Return a hash table with weak values with SIZE buckets. (*note + Hash Tables::) + + make-doubly-weak-hash-table + -- Scheme Procedure: make-doubly-weak-hash-table n + Return a hash table with weak keys and values with SIZE buckets. + (*note Hash Tables::) + + hash-table? + -- Scheme Procedure: hash-table? obj + Return '#t' if OBJ is an abstract hash table object. + + weak-key-hash-table? + -- Scheme Procedure: weak-key-hash-table? obj + -- Scheme Procedure: weak-value-hash-table? obj + -- Scheme Procedure: doubly-weak-hash-table? obj + Return '#t' if OBJ is the specified weak hash table. Note that a + doubly weak hash table is neither a weak key nor a weak value hash + table. + + weak-value-hash-table? + -- Scheme Procedure: weak-value-hash-table? obj + Return '#t' if OBJ is a weak value hash table. + + doubly-weak-hash-table? + -- Scheme Procedure: doubly-weak-hash-table? obj + Return '#t' if OBJ is a doubly weak hash table. + + hash-clear! + -- Scheme Procedure: hash-clear! table + Remove all items from TABLE (without triggering a resize). + + hashq-get-handle + -- Scheme Procedure: hashq-get-handle table key + This procedure returns the '(key . value)' pair from the hash table + TABLE. If TABLE does not hold an associated value for KEY, '#f' is + returned. Uses 'eq?' for equality testing. + + hashq-create-handle! + -- Scheme Procedure: hashq-create-handle! table key init + This function looks up KEY in TABLE and returns its handle. If KEY + is not already present, a new handle is created which associates + KEY with INIT. + + hashq-ref + -- Scheme Procedure: hashq-ref table key [dflt] + Look up KEY in the hash table TABLE, and return the value (if any) + associated with it. If KEY is not found, return DEFAULT (or '#f' + if no DEFAULT argument is supplied). Uses 'eq?' for equality + testing. + + hashq-set! + -- Scheme Procedure: hashq-set! table key val + Find the entry in TABLE associated with KEY, and store VALUE there. + Uses 'eq?' for equality testing. + + hashq-remove! + -- Scheme Procedure: hashq-remove! table key + Remove KEY (and any value associated with it) from TABLE. Uses + 'eq?' for equality tests. + + hashv-get-handle + -- Scheme Procedure: hashv-get-handle table key + This procedure returns the '(key . value)' pair from the hash table + TABLE. If TABLE does not hold an associated value for KEY, '#f' is + returned. Uses 'eqv?' for equality testing. + + hashv-create-handle! + -- Scheme Procedure: hashv-create-handle! table key init + This function looks up KEY in TABLE and returns its handle. If KEY + is not already present, a new handle is created which associates + KEY with INIT. + + hashv-ref + -- Scheme Procedure: hashv-ref table key [dflt] + Look up KEY in the hash table TABLE, and return the value (if any) + associated with it. If KEY is not found, return DEFAULT (or '#f' + if no DEFAULT argument is supplied). Uses 'eqv?' for equality + testing. + + hashv-set! + -- Scheme Procedure: hashv-set! table key val + Find the entry in TABLE associated with KEY, and store VALUE there. + Uses 'eqv?' for equality testing. + + hashv-remove! + -- Scheme Procedure: hashv-remove! table key + Remove KEY (and any value associated with it) from TABLE. Uses + 'eqv?' for equality tests. + + hash-get-handle + -- Scheme Procedure: hash-get-handle table key + This procedure returns the '(key . value)' pair from the hash table + TABLE. If TABLE does not hold an associated value for KEY, '#f' is + returned. Uses 'equal?' for equality testing. + + hash-create-handle! + -- Scheme Procedure: hash-create-handle! table key init + This function looks up KEY in TABLE and returns its handle. If KEY + is not already present, a new handle is created which associates + KEY with INIT. + + hash-ref + -- Scheme Procedure: hash-ref table key [dflt] + Look up KEY in the hash table TABLE, and return the value (if any) + associated with it. If KEY is not found, return DEFAULT (or '#f' + if no DEFAULT argument is supplied). Uses 'equal?' for equality + testing. + + hash-set! + -- Scheme Procedure: hash-set! table key val + Find the entry in TABLE associated with KEY, and store VALUE there. + Uses 'equal?' for equality testing. + + hash-remove! + -- Scheme Procedure: hash-remove! table key + Remove KEY (and any value associated with it) from TABLE. Uses + 'equal?' for equality tests. + + hashx-get-handle + -- Scheme Procedure: hashx-get-handle hash assoc table key + This behaves the same way as the corresponding '-get-handle' + function, but uses HASH as a hash function and ASSOC to compare + keys. 'hash' must be a function that takes two arguments, a key to + be hashed and a table size. 'assoc' must be an associator + function, like 'assoc', 'assq' or 'assv'. + + hashx-create-handle! + -- Scheme Procedure: hashx-create-handle! hash assoc table key init + This behaves the same way as the corresponding '-create-handle' + function, but uses HASH as a hash function and ASSOC to compare + keys. 'hash' must be a function that takes two arguments, a key to + be hashed and a table size. 'assoc' must be an associator + function, like 'assoc', 'assq' or 'assv'. + + hashx-ref + -- Scheme Procedure: hashx-ref hash assoc table key [dflt] + This behaves the same way as the corresponding 'ref' function, but + uses HASH as a hash function and ASSOC to compare keys. 'hash' + must be a function that takes two arguments, a key to be hashed and + a table size. 'assoc' must be an associator function, like + 'assoc', 'assq' or 'assv'. + + By way of illustration, 'hashq-ref table key' is equivalent to + 'hashx-ref hashq assq table key'. + + hashx-set! + -- Scheme Procedure: hashx-set! hash assoc table key val + This behaves the same way as the corresponding 'set!' function, but + uses HASH as a hash function and ASSOC to compare keys. 'hash' + must be a function that takes two arguments, a key to be hashed and + a table size. 'assoc' must be an associator function, like + 'assoc', 'assq' or 'assv'. + + By way of illustration, 'hashq-set! table key' is equivalent to + 'hashx-set! hashq assq table key'. + + hashx-remove! + -- Scheme Procedure: hashx-remove! hash assoc table obj + This behaves the same way as the corresponding 'remove!' function, + but uses HASH as a hash function and ASSOC to compare keys. 'hash' + must be a function that takes two arguments, a key to be hashed and + a table size. 'assoc' must be an associator function, like + 'assoc', 'assq' or 'assv'. + + By way of illustration, 'hashq-remove! table key' is equivalent to + 'hashx-remove! hashq assq #f table key'. + + hash-fold + -- Scheme Procedure: hash-fold proc init table + An iterator over hash-table elements. Accumulates and returns a + result by applying PROC successively. The arguments to PROC are + "(key value prior-result)" where key and value are successive pairs + from the hash table TABLE, and prior-result is either INIT (for the + first application of PROC) or the return value of the previous + application of PROC. For example, '(hash-fold acons '() tab)' will + convert a hash table into an a-list of key-value pairs. + + hash-for-each + -- Scheme Procedure: hash-for-each proc table + An iterator over hash-table elements. Applies PROC successively on + all hash table items. The arguments to PROC are "(key value)" + where key and value are successive pairs from the hash table TABLE. + + hash-for-each-handle + -- Scheme Procedure: hash-for-each-handle proc table + An iterator over hash-table elements. Applies PROC successively on + all hash table handles. + + hash-map->list + -- Scheme Procedure: hash-map->list proc table + An iterator over hash-table elements. Accumulates and returns as a + list the results of applying PROC successively. The arguments to + PROC are "(key value)" where key and value are successive pairs + from the hash table TABLE. + + make-hook + -- Scheme Procedure: make-hook [n_args] + Create a hook for storing procedure of arity N_ARGS. N_ARGS + defaults to zero. The returned value is a hook object to be used + with the other hook procedures. + + hook? + -- Scheme Procedure: hook? x + Return '#t' if X is a hook, '#f' otherwise. + + hook-empty? + -- Scheme Procedure: hook-empty? hook + Return '#t' if HOOK is an empty hook, '#f' otherwise. + + add-hook! + -- Scheme Procedure: add-hook! hook proc [append_p] + Add the procedure PROC to the hook HOOK. The procedure is added to + the end if APPEND_P is true, otherwise it is added to the front. + The return value of this procedure is not specified. + + remove-hook! + -- Scheme Procedure: remove-hook! hook proc + Remove the procedure PROC from the hook HOOK. The return value of + this procedure is not specified. + + reset-hook! + -- Scheme Procedure: reset-hook! hook + Remove all procedures from the hook HOOK. The return value of this + procedure is not specified. + + run-hook + -- Scheme Procedure: run-hook hook . args + Apply all procedures from the hook HOOK to the arguments ARGS. The + order of the procedure application is first to last. The return + value of this procedure is not specified. + + hook->list + -- Scheme Procedure: hook->list hook + Convert the procedure list of HOOK to a list. + + gettext + -- Scheme Procedure: gettext msgid [domain [category]] + Return the translation of MSGID in the message domain DOMAIN. + DOMAIN is optional and defaults to the domain set through + (textdomain). CATEGORY is optional and defaults to LC_MESSAGES. + + ngettext + -- Scheme Procedure: ngettext msgid msgid_plural n [domain [category]] + Return the translation of MSGID/MSGID_PLURAL in the message domain + DOMAIN, with the plural form being chosen appropriately for the + number N. DOMAIN is optional and defaults to the domain set + through (textdomain). CATEGORY is optional and defaults to + LC_MESSAGES. + + textdomain + -- Scheme Procedure: textdomain [domainname] + If optional parameter DOMAINNAME is supplied, set the textdomain. + Return the textdomain. + + bindtextdomain + -- Scheme Procedure: bindtextdomain domainname [directory] + If optional parameter DIRECTORY is supplied, set message catalogs + to directory DIRECTORY. Return the directory bound to DOMAINNAME. + + bind-textdomain-codeset + -- Scheme Procedure: bind-textdomain-codeset domainname [encoding] + If optional parameter ENCODING is supplied, set encoding for + message catalogs of DOMAINNAME. Return the encoding of DOMAINNAME. + + ftell + -- Scheme Procedure: ftell fd_port + Return an integer representing the current position of FD/PORT, + measured from the beginning. Equivalent to: + + (seek port 0 SEEK_CUR) + + redirect-port + -- Scheme Procedure: redirect-port old new + This procedure takes two ports and duplicates the underlying file + descriptor from OLD-PORT into NEW-PORT. The current file + descriptor in NEW-PORT will be closed. After the redirection the + two ports will share a file position and file status flags. + + The return value is unspecified. + + Unexpected behaviour can result if both ports are subsequently used + and the original and/or duplicate ports are buffered. + + This procedure does not have any side effects on other ports or + revealed counts. + + dup->fdes + -- Scheme Procedure: dup->fdes fd_or_port [fd] + Return a new integer file descriptor referring to the open file + designated by FD_OR_PORT, which must be either an open file port or + a file descriptor. + + dup2 + -- Scheme Procedure: dup2 oldfd newfd + A simple wrapper for the 'dup2' system call. Copies the file + descriptor OLDFD to descriptor number NEWFD, replacing the previous + meaning of NEWFD. Both OLDFD and NEWFD must be integers. Unlike + for dup->fdes or primitive-move->fdes, no attempt is made to move + away ports which are using NEWFD. The return value is unspecified. + + fileno + -- Scheme Procedure: fileno port + Return the integer file descriptor underlying PORT. Does not + change its revealed count. + + isatty? + -- Scheme Procedure: isatty? port + Return '#t' if PORT is using a serial non-file device, otherwise + '#f'. + + fdopen + -- Scheme Procedure: fdopen fdes modes + Return a new port based on the file descriptor FDES. Modes are + given by the string MODES. The revealed count of the port is + initialized to zero. The modes string is the same as that accepted + by *note open-file: File Ports. + + primitive-move->fdes + -- Scheme Procedure: primitive-move->fdes port fd + Moves the underlying file descriptor for PORT to the integer value + FDES without changing the revealed count of PORT. Any other ports + already using this descriptor will be automatically shifted to new + descriptors and their revealed counts reset to zero. The return + value is '#f' if the file descriptor already had the required value + or '#t' if it was moved. + + fdes->ports + -- Scheme Procedure: fdes->ports fd + Return a list of existing ports which have FDES as an underlying + file descriptor, without changing their revealed counts. + + keyword? + -- Scheme Procedure: keyword? obj + Return '#t' if the argument OBJ is a keyword, else '#f'. + + symbol->keyword + -- Scheme Procedure: symbol->keyword symbol + Return the keyword with the same name as SYMBOL. + + keyword->symbol + -- Scheme Procedure: keyword->symbol keyword + Return the symbol with the same name as KEYWORD. + + make-list + -- Scheme Procedure: make-list n [init] + Create a list containing of N elements, where each element is + initialized to INIT. INIT defaults to the empty list '()' if not + given. + + cons* + -- Scheme Procedure: cons* arg . rest + Like 'list', but the last arg provides the tail of the constructed + list, returning '(cons ARG1 (cons ARG2 (cons ... ARGN)))'. + Requires at least one argument. If given one argument, that + argument is returned as result. This function is called 'list*' in + some other Schemes and in Common LISP. + + null? + -- Scheme Procedure: null? x + Return '#t' iff X is the empty list, else '#f'. + + list? + -- Scheme Procedure: list? x + Return '#t' iff X is a proper list, else '#f'. + + length + -- Scheme Procedure: length lst + Return the number of elements in list LST. + + append + -- Scheme Procedure: append . args + Return a list consisting of the elements the lists passed as + arguments. + (append '(x) '(y)) => (x y) + (append '(a) '(b c d)) => (a b c d) + (append '(a (b)) '((c))) => (a (b) (c)) + The resulting list is always newly allocated, except that it shares + structure with the last list argument. The last argument may + actually be any object; an improper list results if the last + argument is not a proper list. + (append '(a b) '(c . d)) => (a b c . d) + (append '() 'a) => a + + append! + -- Scheme Procedure: append! . lists + A destructive version of 'append' (*note (r5rs)Pairs and Lists::). + The cdr field of each list's final pair is changed to point to the + head of the next list, so no consing is performed. Return the + mutated list. + + last-pair + -- Scheme Procedure: last-pair lst + Return the last pair in LST, signalling an error if LST is + circular. + + reverse + -- Scheme Procedure: reverse lst + Return a new list that contains the elements of LST but in reverse + order. + + reverse! + -- Scheme Procedure: reverse! lst [new_tail] + A destructive version of 'reverse' (*note (r5rs)Pairs and Lists::). + The cdr of each cell in LST is modified to point to the previous + list element. Return the reversed list. + + Caveat: because the list is modified in place, the tail of the + original list now becomes its head, and the head of the original + list now becomes the tail. Therefore, the LST symbol to which the + head of the original list was bound now points to the tail. To + ensure that the head of the modified list is not lost, it is wise + to save the return value of 'reverse!' + + list-ref + -- Scheme Procedure: list-ref list k + Return the Kth element from LIST. + + list-set! + -- Scheme Procedure: list-set! list k val + Set the Kth element of LIST to VAL. + + list-cdr-ref + -- Scheme Procedure: list-cdr-ref + implemented by the C function "scm_list_tail" + + list-tail + -- Scheme Procedure: list-tail lst k + -- Scheme Procedure: list-cdr-ref lst k + Return the "tail" of LST beginning with its Kth element. The first + element of the list is considered to be element 0. + + 'list-tail' and 'list-cdr-ref' are identical. It may help to think + of 'list-cdr-ref' as accessing the Kth cdr of the list, or + returning the results of cdring K times down LST. + + list-cdr-set! + -- Scheme Procedure: list-cdr-set! list k val + Set the Kth cdr of LIST to VAL. + + list-head + -- Scheme Procedure: list-head lst k + Copy the first K elements from LST into a new list, and return it. + + list-copy + -- Scheme Procedure: list-copy lst + Return a (newly-created) copy of LST. + + list + -- Scheme Procedure: list . objs + Return a list containing OBJS, the arguments to 'list'. + + memq + -- Scheme Procedure: memq x lst + Return the first sublist of LST whose car is 'eq?' to X where the + sublists of LST are the non-empty lists returned by '(list-tail LST + K)' for K less than the length of LST. If X does not occur in LST, + then '#f' (not the empty list) is returned. + + memv + -- Scheme Procedure: memv x lst + Return the first sublist of LST whose car is 'eqv?' to X where the + sublists of LST are the non-empty lists returned by '(list-tail LST + K)' for K less than the length of LST. If X does not occur in LST, + then '#f' (not the empty list) is returned. + + member + -- Scheme Procedure: member x lst + Return the first sublist of LST whose car is 'equal?' to X where + the sublists of LST are the non-empty lists returned by '(list-tail + LST K)' for K less than the length of LST. If X does not occur in + LST, then '#f' (not the empty list) is returned. + + delq! + -- Scheme Procedure: delq! item lst + -- Scheme Procedure: delv! item lst + -- Scheme Procedure: delete! item lst + These procedures are destructive versions of 'delq', 'delv' and + 'delete': they modify the existing LST rather than creating a new + list. Caveat evaluator: Like other destructive list functions, + these functions cannot modify the binding of LST, and so cannot be + used to delete the first element of LST destructively. + + delv! + -- Scheme Procedure: delv! item lst + Destructively remove all elements from LST that are 'eqv?' to ITEM. + + delete! + -- Scheme Procedure: delete! item lst + Destructively remove all elements from LST that are 'equal?' to + ITEM. + + delq + -- Scheme Procedure: delq item lst + Return a newly-created copy of LST with elements 'eq?' to ITEM + removed. This procedure mirrors 'memq': 'delq' compares elements + of LST against ITEM with 'eq?'. + + delv + -- Scheme Procedure: delv item lst + Return a newly-created copy of LST with elements 'eqv?' to ITEM + removed. This procedure mirrors 'memv': 'delv' compares elements + of LST against ITEM with 'eqv?'. + + delete + -- Scheme Procedure: delete item lst + Return a newly-created copy of LST with elements 'equal?' to ITEM + removed. This procedure mirrors 'member': 'delete' compares + elements of LST against ITEM with 'equal?'. + + delq1! + -- Scheme Procedure: delq1! item lst + Like 'delq!', but only deletes the first occurrence of ITEM from + LST. Tests for equality using 'eq?'. See also 'delv1!' and + 'delete1!'. + + delv1! + -- Scheme Procedure: delv1! item lst + Like 'delv!', but only deletes the first occurrence of ITEM from + LST. Tests for equality using 'eqv?'. See also 'delq1!' and + 'delete1!'. + + delete1! + -- Scheme Procedure: delete1! item lst + Like 'delete!', but only deletes the first occurrence of ITEM from + LST. Tests for equality using 'equal?'. See also 'delq1!' and + 'delv1!'. + + filter + -- Scheme Procedure: filter pred list + Return all the elements of 2nd arg LIST that satisfy predicate + PRED. The list is not disordered - elements that appear in the + result list occur in the same order as they occur in the argument + list. The returned list may share a common tail with the argument + list. The dynamic order in which the various applications of pred + are made is not specified. + + (filter even? '(0 7 8 8 43 -4)) => (0 8 8 -4) + + filter! + -- Scheme Procedure: filter! pred list + Linear-update variant of 'filter'. + + primitive-load + -- Scheme Procedure: primitive-load filename + Load the file named FILENAME and evaluate its contents in the + top-level environment. The load paths are not searched; FILENAME + must either be a full pathname or be a pathname relative to the + current directory. If the variable '%load-hook' is defined, it + should be bound to a procedure that will be called before any code + is loaded. See the documentation for '%load-hook' later in this + section. + + %package-data-dir + -- Scheme Procedure: %package-data-dir + Return the name of the directory where Scheme packages, modules and + libraries are kept. On most Unix systems, this will be + '/usr/local/share/guile'. + + %library-dir + -- Scheme Procedure: %library-dir + Return the directory where the Guile Scheme library files are + installed. E.g., may return "/usr/share/guile/1.3.5". + + %site-dir + -- Scheme Procedure: %site-dir + Return the directory where the Guile site files are installed. + E.g., may return "/usr/share/guile/site". + + parse-path + -- Scheme Procedure: parse-path path [tail] + Parse PATH, which is expected to be a colon-separated string, into + a list and return the resulting list with TAIL appended. If PATH + is '#f', TAIL is returned. + + search-path + -- Scheme Procedure: search-path path filename [extensions] + Search PATH for a directory containing a file named FILENAME. The + file must be readable, and not a directory. If we find one, return + its full filename; otherwise, return '#f'. If FILENAME is + absolute, return it unchanged. If given, EXTENSIONS is a list of + strings; for each directory in PATH, we search for FILENAME + concatenated with each EXTENSION. + + %search-load-path + -- Scheme Procedure: %search-load-path filename + Search %LOAD-PATH for the file named FILENAME, which must be + readable by the current user. If FILENAME is found in the list of + paths to search or is an absolute pathname, return its full + pathname. Otherwise, return '#f'. Filenames may have any of the + optional extensions in the '%load-extensions' list; + '%search-load-path' will try each extension automatically. + + primitive-load-path + -- Scheme Procedure: primitive-load-path filename + Search %LOAD-PATH for the file named FILENAME and load it into the + top-level environment. If FILENAME is a relative pathname and is + not found in the list of search paths, an error is signalled. + + procedure->memoizing-macro + -- Scheme Procedure: procedure->memoizing-macro code + Return a "macro" which, when a symbol defined to this value appears + as the first symbol in an expression, evaluates the result of + applying CODE to the expression and the environment. + + 'procedure->memoizing-macro' is the same as 'procedure->macro', + except that the expression returned by CODE replaces the original + macro expression in the memoized form of the containing code. + + procedure->syntax + -- Scheme Procedure: procedure->syntax code + Return a "macro" which, when a symbol defined to this value appears + as the first symbol in an expression, returns the result of + applying CODE to the expression and the environment. + + procedure->macro + -- Scheme Procedure: procedure->macro code + Return a "macro" which, when a symbol defined to this value appears + as the first symbol in an expression, evaluates the result of + applying CODE to the expression and the environment. For example: + + (define trace + (procedure->macro + (lambda (x env) `(set! ,(cadr x) (tracef ,(cadr x) ',(cadr x)))))) + + (trace foo) == (set! foo (tracef foo 'foo)). + + macro? + -- Scheme Procedure: macro? obj + Return '#t' if OBJ is a regular macro, a memoizing macro or a + syntax transformer. + + macro-type + -- Scheme Procedure: macro-type m + Return one of the symbols 'syntax', 'macro' or 'macro!', depending + on whether M is a syntax transformer, a regular macro, or a + memoizing macro, respectively. If M is not a macro, '#f' is + returned. + + macro-name + -- Scheme Procedure: macro-name m + Return the name of the macro M. + + macro-transformer + -- Scheme Procedure: macro-transformer m + Return the transformer of the macro M. + + current-module + -- Scheme Procedure: current-module + Return the current module. + + set-current-module + -- Scheme Procedure: set-current-module module + Set the current module to MODULE and return the previous current + module. + + interaction-environment + -- Scheme Procedure: interaction-environment + Return a specifier for the environment that contains + implementation-defined bindings, typically a superset of those + listed in the report. The intent is that this procedure will + return the environment in which the implementation would evaluate + expressions dynamically typed by the user. + + env-module + -- Scheme Procedure: env-module env + Return the module of ENV, a lexical environment. + + standard-eval-closure + -- Scheme Procedure: standard-eval-closure module + Return an eval closure for the module MODULE. + + standard-interface-eval-closure + -- Scheme Procedure: standard-interface-eval-closure module + Return a interface eval closure for the module MODULE. Such a + closure does not allow new bindings to be added. + + module-import-interface + -- Scheme Procedure: module-import-interface module sym + + %get-pre-modules-obarray + -- Scheme Procedure: %get-pre-modules-obarray + Return the obarray that is used for all new bindings before the + module system is booted. The first call to 'set-current-module' + will boot the module system. + + exact? + -- Scheme Procedure: exact? x + Return '#t' if X is an exact number, '#f' otherwise. + + odd? + -- Scheme Procedure: odd? n + Return '#t' if N is an odd number, '#f' otherwise. + + even? + -- Scheme Procedure: even? n + Return '#t' if N is an even number, '#f' otherwise. + + inf? + -- Scheme Procedure: inf? x + Return '#t' if X is either '+inf.0' or '-inf.0', '#f' otherwise. + + nan? + -- Scheme Procedure: nan? n + Return '#t' if N is a NaN, '#f' otherwise. + + inf + -- Scheme Procedure: inf + Return Inf. + + nan + -- Scheme Procedure: nan + Return NaN. + + abs + -- Scheme Procedure: abs x + Return the absolute value of X. + + logand + -- Scheme Procedure: logand n1 n2 + Return the bitwise AND of the integer arguments. + + (logand) => -1 + (logand 7) => 7 + (logand #b111 #b011 #b001) => 1 + + logior + -- Scheme Procedure: logior n1 n2 + Return the bitwise OR of the integer arguments. + + (logior) => 0 + (logior 7) => 7 + (logior #b000 #b001 #b011) => 3 + + logxor + -- Scheme Procedure: logxor n1 n2 + Return the bitwise XOR of the integer arguments. A bit is set in + the result if it is set in an odd number of arguments. + (logxor) => 0 + (logxor 7) => 7 + (logxor #b000 #b001 #b011) => 2 + (logxor #b000 #b001 #b011 #b011) => 1 + + logtest + -- Scheme Procedure: logtest j k + Test whether J and K have any 1 bits in common. This is equivalent + to '(not (zero? (logand j k)))', but without actually calculating + the 'logand', just testing for non-zero. + + (logtest #b0100 #b1011) => #f + (logtest #b0100 #b0111) => #t + + logbit? + -- Scheme Procedure: logbit? index j + Test whether bit number INDEX in J is set. INDEX starts from 0 for + the least significant bit. + + (logbit? 0 #b1101) => #t + (logbit? 1 #b1101) => #f + (logbit? 2 #b1101) => #t + (logbit? 3 #b1101) => #t + (logbit? 4 #b1101) => #f + + lognot + -- Scheme Procedure: lognot n + Return the integer which is the ones-complement of the integer + argument. + + (number->string (lognot #b10000000) 2) + => "-10000001" + (number->string (lognot #b0) 2) + => "-1" + + modulo-expt + -- Scheme Procedure: modulo-expt n k m + Return N raised to the integer exponent K, modulo M. + + (modulo-expt 2 3 5) + => 3 + + integer-expt + -- Scheme Procedure: integer-expt n k + Return N raised to the power K. K must be an exact integer, N can + be any number. + + Negative K is supported, and results in 1/n^abs(k) in the usual + way. N^0 is 1, as usual, and that includes 0^0 is 1. + + (integer-expt 2 5) => 32 + (integer-expt -3 3) => -27 + (integer-expt 5 -3) => 1/125 + (integer-expt 0 0) => 1 + + ash + -- Scheme Procedure: ash n cnt + Return N shifted left by CNT bits, or shifted right if CNT is + negative. This is an "arithmetic" shift. + + This is effectively a multiplication by 2^CNT, and when CNT is + negative it's a division, rounded towards negative infinity. (Note + that this is not the same rounding as 'quotient' does.) + + With N viewed as an infinite precision twos complement, 'ash' means + a left shift introducing zero bits, or a right shift dropping bits. + + (number->string (ash #b1 3) 2) => "1000" + (number->string (ash #b1010 -1) 2) => "101" + + ;; -23 is bits ...11101001, -6 is bits ...111010 + (ash -23 -2) => -6 + + bit-extract + -- Scheme Procedure: bit-extract n start end + Return the integer composed of the START (inclusive) through END + (exclusive) bits of N. The STARTth bit becomes the 0-th bit in the + result. + + (number->string (bit-extract #b1101101010 0 4) 2) + => "1010" + (number->string (bit-extract #b1101101010 4 9) 2) + => "10110" + + logcount + -- Scheme Procedure: logcount n + Return the number of bits in integer N. If integer is positive, + the 1-bits in its binary representation are counted. If negative, + the 0-bits in its two's-complement binary representation are + counted. If 0, 0 is returned. + + (logcount #b10101010) + => 4 + (logcount 0) + => 0 + (logcount -2) + => 1 + + integer-length + -- Scheme Procedure: integer-length n + Return the number of bits necessary to represent N. + + (integer-length #b10101010) + => 8 + (integer-length 0) + => 0 + (integer-length #b1111) + => 4 + + number->string + -- Scheme Procedure: number->string n [radix] + Return a string holding the external representation of the number N + in the given RADIX. If N is inexact, a radix of 10 will be used. + + string->number + -- Scheme Procedure: string->number string [radix] + Return a number of the maximally precise representation expressed + by the given STRING. RADIX must be an exact integer, either 2, 8, + 10, or 16. If supplied, RADIX is a default radix that may be + overridden by an explicit radix prefix in STRING (e.g. "#o177"). + If RADIX is not supplied, then the default radix is 10. If string + is not a syntactically valid notation for a number, then + 'string->number' returns '#f'. + + number? + -- Scheme Procedure: number? x + Return '#t' if X is a number, '#f' otherwise. + + complex? + -- Scheme Procedure: complex? x + Return '#t' if X is a complex number, '#f' otherwise. Note that + the sets of real, rational and integer values form subsets of the + set of complex numbers, i. e. the predicate will also be + fulfilled if X is a real, rational or integer number. + + real? + -- Scheme Procedure: real? x + Return '#t' if X is a real number, '#f' otherwise. Note that the + set of integer values forms a subset of the set of real numbers, i. + e. the predicate will also be fulfilled if X is an integer number. + + rational? + -- Scheme Procedure: rational? x + Return '#t' if X is a rational number, '#f' otherwise. Note that + the set of integer values forms a subset of the set of rational + numbers, i. e. the predicate will also be fulfilled if X is an + integer number. + + integer? + -- Scheme Procedure: integer? x + Return '#t' if X is an integer number, '#f' else. + + inexact? + -- Scheme Procedure: inexact? x + Return '#t' if X is an inexact number, '#f' else. + + 1+ + -- Scheme Procedure: 1+ x + Return X+1. + + 1- + -- Scheme Procedure: 1- x + Return X-1. + + truncate + -- Scheme Procedure: truncate x + Round the number X towards zero. + + round + -- Scheme Procedure: round x + Round the number X towards the nearest integer. When it is exactly + halfway between two integers, round towards the even one. + + floor + -- Scheme Procedure: floor x + Round the number X towards minus infinity. + + ceiling + -- Scheme Procedure: ceiling x + Round the number X towards infinity. + + $expt + -- Scheme Procedure: $expt x y + Return X raised to the power of Y. This procedure does not accept + complex arguments. + + $atan2 + -- Scheme Procedure: $atan2 x y + Return the arc tangent of the two arguments X and Y. This is + similar to calculating the arc tangent of X / Y, except that the + signs of both arguments are used to determine the quadrant of the + result. This procedure does not accept complex arguments. + + make-rectangular + -- Scheme Procedure: make-rectangular real_part imaginary_part + Return a complex number constructed of the given REAL-PART and + IMAGINARY-PART parts. + + make-polar + -- Scheme Procedure: make-polar x y + Return the complex number X * e^(i * Y). + + inexact->exact + -- Scheme Procedure: inexact->exact z + Return an exact number that is numerically closest to Z. + + rationalize + -- Scheme Procedure: rationalize x eps + Returns the _simplest_ rational number differing from X by no more + than EPS. + + As required by R5RS, 'rationalize' only returns an exact result + when both its arguments are exact. Thus, you might need to use + 'inexact->exact' on the arguments. + + (rationalize (inexact->exact 1.2) 1/100) + => 6/5 + + log + -- Scheme Procedure: log z + Return the natural logarithm of Z. + + log10 + -- Scheme Procedure: log10 z + Return the base 10 logarithm of Z. + + exp + -- Scheme Procedure: exp z + Return e to the power of Z, where e is the base of natural + logarithms (2.71828...). + + sqrt + -- Scheme Procedure: sqrt x + Return the square root of Z. Of the two possible roots (positive + and negative), the one with the a positive real part is returned, + or if that's zero then a positive imaginary part. Thus, + + (sqrt 9.0) => 3.0 + (sqrt -9.0) => 0.0+3.0i + (sqrt 1.0+1.0i) => 1.09868411346781+0.455089860562227i + (sqrt -1.0-1.0i) => 0.455089860562227-1.09868411346781i + + entity? + -- Scheme Procedure: entity? obj + Return '#t' if OBJ is an entity. + + operator? + -- Scheme Procedure: operator? obj + Return '#t' if OBJ is an operator. + + valid-object-procedure? + -- Scheme Procedure: valid-object-procedure? proc + Return '#t' iff PROC is a procedure that can be used with + 'set-object-procedure'. It is always valid to use a closure + constructed by 'lambda'. + + set-object-procedure! + -- Scheme Procedure: set-object-procedure! obj proc + Set the object procedure of OBJ to PROC. OBJ must be either an + entity or an operator. + + make-class-object + -- Scheme Procedure: make-class-object metaclass layout + Create a new class object of class METACLASS, with the slot layout + specified by LAYOUT. + + make-subclass-object + -- Scheme Procedure: make-subclass-object class layout + Create a subclass object of CLASS, with the slot layout specified + by LAYOUT. + + object-properties + -- Scheme Procedure: object-properties obj + Return OBJ's property list. + + set-object-properties! + -- Scheme Procedure: set-object-properties! obj alist + Set OBJ's property list to ALIST. + + object-property + -- Scheme Procedure: object-property obj key + Return the property of OBJ with name KEY. + + set-object-property! + -- Scheme Procedure: set-object-property! obj key value + In OBJ's property list, set the property named KEY to VALUE. + + cons + -- Scheme Procedure: cons x y + Return a newly allocated pair whose car is X and whose cdr is Y. + The pair is guaranteed to be different (in the sense of 'eq?') from + every previously existing object. + + pair? + -- Scheme Procedure: pair? x + Return '#t' if X is a pair; otherwise return '#f'. + + set-car! + -- Scheme Procedure: set-car! pair value + Stores VALUE in the car field of PAIR. The value returned by + 'set-car!' is unspecified. + + set-cdr! + -- Scheme Procedure: set-cdr! pair value + Stores VALUE in the cdr field of PAIR. The value returned by + 'set-cdr!' is unspecified. + + char-ready? + -- Scheme Procedure: char-ready? [port] + Return '#t' if a character is ready on input PORT and return '#f' + otherwise. If 'char-ready?' returns '#t' then the next 'read-char' + operation on PORT is guaranteed not to hang. If PORT is a file + port at end of file then 'char-ready?' returns '#t'. + + 'char-ready?' exists to make it possible for a program to accept + characters from interactive ports without getting stuck waiting for + input. Any input editors associated with such ports must make sure + that characters whose existence has been asserted by 'char-ready?' + cannot be rubbed out. If 'char-ready?' were to return '#f' at end + of file, a port at end of file would be indistinguishable from an + interactive port that has no ready characters. + + drain-input + -- Scheme Procedure: drain-input port + This procedure clears a port's input buffers, similar to the way + that force-output clears the output buffer. The contents of the + buffers are returned as a single string, e.g., + + (define p (open-input-file ...)) + (drain-input p) => empty string, nothing buffered yet. + (unread-char (read-char p) p) + (drain-input p) => initial chars from p, up to the buffer size. + + Draining the buffers may be useful for cleanly finishing buffered + I/O so that the file descriptor can be used directly for further + input. + + current-input-port + -- Scheme Procedure: current-input-port + Return the current input port. This is the default port used by + many input procedures. Initially, 'current-input-port' returns the + "standard input" in Unix and C terminology. + + current-output-port + -- Scheme Procedure: current-output-port + Return the current output port. This is the default port used by + many output procedures. Initially, 'current-output-port' returns + the "standard output" in Unix and C terminology. + + current-error-port + -- Scheme Procedure: current-error-port + Return the port to which errors and warnings should be sent (the + "standard error" in Unix and C terminology). + + current-load-port + -- Scheme Procedure: current-load-port + Return the current-load-port. The load port is used internally by + 'primitive-load'. + + set-current-input-port + -- Scheme Procedure: set-current-input-port port + -- Scheme Procedure: set-current-output-port port + -- Scheme Procedure: set-current-error-port port + Change the ports returned by 'current-input-port', + 'current-output-port' and 'current-error-port', respectively, so + that they use the supplied PORT for input or output. + + set-current-output-port + -- Scheme Procedure: set-current-output-port port + Set the current default output port to PORT. + + set-current-error-port + -- Scheme Procedure: set-current-error-port port + Set the current default error port to PORT. + + port-revealed + -- Scheme Procedure: port-revealed port + Return the revealed count for PORT. + + set-port-revealed! + -- Scheme Procedure: set-port-revealed! port rcount + Sets the revealed count for a port to a given value. The return + value is unspecified. + + port-mode + -- Scheme Procedure: port-mode port + Return the port modes associated with the open port PORT. These + will not necessarily be identical to the modes used when the port + was opened, since modes such as "append" which are used only during + port creation are not retained. + + close-port + -- Scheme Procedure: close-port port + Close the specified port object. Return '#t' if it successfully + closes a port or '#f' if it was already closed. An exception may + be raised if an error occurs, for example when flushing buffered + output. See also *note close: Ports and File Descriptors, for a + procedure which can close file descriptors. + + close-input-port + -- Scheme Procedure: close-input-port port + Close the specified input port object. The routine has no effect + if the file has already been closed. An exception may be raised if + an error occurs. The value returned is unspecified. + + See also *note close: Ports and File Descriptors, for a procedure + which can close file descriptors. + + close-output-port + -- Scheme Procedure: close-output-port port + Close the specified output port object. The routine has no effect + if the file has already been closed. An exception may be raised if + an error occurs. The value returned is unspecified. + + See also *note close: Ports and File Descriptors, for a procedure + which can close file descriptors. + + port-for-each + -- Scheme Procedure: port-for-each proc + Apply PROC to each port in the Guile port table in turn. The + return value is unspecified. More specifically, PROC is applied + exactly once to every port that exists in the system at the time + PORT-FOR-EACH is invoked. Changes to the port table while + PORT-FOR-EACH is running have no effect as far as PORT-FOR-EACH is + concerned. + + input-port? + -- Scheme Procedure: input-port? x + Return '#t' if X is an input port, otherwise return '#f'. Any + object satisfying this predicate also satisfies 'port?'. + + output-port? + -- Scheme Procedure: output-port? x + Return '#t' if X is an output port, otherwise return '#f'. Any + object satisfying this predicate also satisfies 'port?'. + + port? + -- Scheme Procedure: port? x + Return a boolean indicating whether X is a port. Equivalent to + '(or (input-port? X) (output-port? X))'. + + port-closed? + -- Scheme Procedure: port-closed? port + Return '#t' if PORT is closed or '#f' if it is open. + + eof-object? + -- Scheme Procedure: eof-object? x + Return '#t' if X is an end-of-file object; otherwise return '#f'. + + force-output + -- Scheme Procedure: force-output [port] + Flush the specified output port, or the current output port if PORT + is omitted. The current output buffer contents are passed to the + underlying port implementation (e.g., in the case of fports, the + data will be written to the file and the output buffer will be + cleared.) It has no effect on an unbuffered port. + + The return value is unspecified. + + flush-all-ports + -- Scheme Procedure: flush-all-ports + Equivalent to calling 'force-output' on all open output ports. The + return value is unspecified. + + read-char + -- Scheme Procedure: read-char [port] + Return the next character available from PORT, updating PORT to + point to the following character. If no more characters are + available, the end-of-file object is returned. + + peek-char + -- Scheme Procedure: peek-char [port] + Return the next character available from PORT, _without_ updating + PORT to point to the following character. If no more characters + are available, the end-of-file object is returned. + + The value returned by a call to 'peek-char' is the same as the + value that would have been returned by a call to 'read-char' on the + same port. The only difference is that the very next call to + 'read-char' or 'peek-char' on that PORT will return the value + returned by the preceding call to 'peek-char'. In particular, a + call to 'peek-char' on an interactive port will hang waiting for + input whenever a call to 'read-char' would have hung. + + unread-char + -- Scheme Procedure: unread-char cobj [port] + Place CHAR in PORT so that it will be read by the next read + operation. If called multiple times, the unread characters will be + read again in last-in first-out order. If PORT is not supplied, + the current input port is used. + + unread-string + -- Scheme Procedure: unread-string str port + Place the string STR in PORT so that its characters will be read in + subsequent read operations. If called multiple times, the unread + characters will be read again in last-in first-out order. If PORT + is not supplied, the current-input-port is used. + + seek + -- Scheme Procedure: seek fd_port offset whence + Sets the current position of FD/PORT to the integer OFFSET, which + is interpreted according to the value of WHENCE. + + One of the following variables should be supplied for WHENCE: + -- Variable: SEEK_SET + Seek from the beginning of the file. + -- Variable: SEEK_CUR + Seek from the current position. + -- Variable: SEEK_END + Seek from the end of the file. + If FD/PORT is a file descriptor, the underlying system call is + 'lseek'. PORT may be a string port. + + The value returned is the new position in the file. This means + that the current position of a port can be obtained using: + (seek port 0 SEEK_CUR) + + truncate-file + -- Scheme Procedure: truncate-file object [length] + Truncate FILE to LENGTH bytes. FILE can be a filename string, a + port object, or an integer file descriptor. The return value is + unspecified. + + For a port or file descriptor LENGTH can be omitted, in which case + the file is truncated at the current position (per 'ftell' above). + + On most systems a file can be extended by giving a length greater + than the current size, but this is not mandatory in the POSIX + standard. + + port-line + -- Scheme Procedure: port-line port + Return the current line number for PORT. + + The first line of a file is 0. But you might want to add 1 when + printing line numbers, since starting from 1 is traditional in + error messages, and likely to be more natural to non-programmers. + + set-port-line! + -- Scheme Procedure: set-port-line! port line + Set the current line number for PORT to LINE. The first line of a + file is 0. + + port-column + -- Scheme Procedure: port-column port + Return the current column number of PORT. If the number is + unknown, the result is #f. Otherwise, the result is a 0-origin + integer - i.e. the first character of the first line is line 0, + column 0. (However, when you display a file position, for example + in an error message, we recommend you add 1 to get 1-origin + integers. This is because lines and column numbers traditionally + start with 1, and that is what non-programmers will find most + natural.) + + set-port-column! + -- Scheme Procedure: set-port-column! port column + Set the current column of PORT. Before reading the first character + on a line the column should be 0. + + port-filename + -- Scheme Procedure: port-filename port + Return the filename associated with PORT. This function returns + the strings "standard input", "standard output" and "standard + error" when called on the current input, output and error ports + respectively. + + set-port-filename! + -- Scheme Procedure: set-port-filename! port filename + Change the filename associated with PORT, using the current input + port if none is specified. Note that this does not change the + port's source of data, but only the value that is returned by + 'port-filename' and reported in diagnostic output. + + %make-void-port + -- Scheme Procedure: %make-void-port mode + Create and return a new void port. A void port acts like + '/dev/null'. The MODE argument specifies the input/output modes + for this port: see the documentation for 'open-file' in *note File + Ports::. + + print-options-interface + -- Scheme Procedure: print-options-interface [setting] + Option interface for the print options. Instead of using this + procedure directly, use the procedures 'print-enable', + 'print-disable', 'print-set!' and 'print-options'. + + simple-format + -- Scheme Procedure: simple-format destination message . args + Write MESSAGE to DESTINATION, defaulting to the current output + port. MESSAGE can contain '~A' (was '%s') and '~S' (was '%S') + escapes. When printed, the escapes are replaced with corresponding + members of ARGS: '~A' formats using 'display' and '~S' formats + using 'write'. If DESTINATION is '#t', then use the current output + port, if DESTINATION is '#f', then return a string containing the + formatted text. Does not add a trailing newline. + + newline + -- Scheme Procedure: newline [port] + Send a newline to PORT. If PORT is omitted, send to the current + output port. + + write-char + -- Scheme Procedure: write-char chr [port] + Send character CHR to PORT. + + port-with-print-state + -- Scheme Procedure: port-with-print-state port [pstate] + Create a new port which behaves like PORT, but with an included + print state PSTATE. PSTATE is optional. If PSTATE isn't supplied + and PORT already has a print state, the old print state is reused. + + get-print-state + -- Scheme Procedure: get-print-state port + Return the print state of the port PORT. If PORT has no associated + print state, '#f' is returned. + + procedure-properties + -- Scheme Procedure: procedure-properties proc + Return OBJ's property list. + + set-procedure-properties! + -- Scheme Procedure: set-procedure-properties! proc new_val + Set OBJ's property list to ALIST. + + procedure-property + -- Scheme Procedure: procedure-property p k + Return the property of OBJ with name KEY. + + set-procedure-property! + -- Scheme Procedure: set-procedure-property! p k v + In OBJ's property list, set the property named KEY to VALUE. + + procedure? + -- Scheme Procedure: procedure? obj + Return '#t' if OBJ is a procedure. + + closure? + -- Scheme Procedure: closure? obj + Return '#t' if OBJ is a closure. + + thunk? + -- Scheme Procedure: thunk? obj + Return '#t' if OBJ is a thunk. + + procedure-documentation + -- Scheme Procedure: procedure-documentation proc + Return the documentation string associated with 'proc'. By + convention, if a procedure contains more than one expression and + the first expression is a string constant, that string is assumed + to contain documentation for that procedure. + + procedure-with-setter? + -- Scheme Procedure: procedure-with-setter? obj + Return '#t' if OBJ is a procedure with an associated setter + procedure. + + make-procedure-with-setter + -- Scheme Procedure: make-procedure-with-setter procedure setter + Create a new procedure which behaves like PROCEDURE, but with the + associated setter SETTER. + + procedure + -- Scheme Procedure: procedure proc + Return the procedure of PROC, which must be either a procedure with + setter, or an operator struct. + + primitive-make-property + -- Scheme Procedure: primitive-make-property not_found_proc + Create a "property token" that can be used with + 'primitive-property-ref' and 'primitive-property-set!'. See + 'primitive-property-ref' for the significance of NOT_FOUND_PROC. + + primitive-property-ref + -- Scheme Procedure: primitive-property-ref prop obj + Return the property PROP of OBJ. + + When no value has yet been associated with PROP and OBJ, the + NOT-FOUND-PROC from PROP is used. A call '(NOT-FOUND-PROC PROP + OBJ)' is made and the result set as the property value. If + NOT-FOUND-PROC is '#f' then '#f' is the property value. + + primitive-property-set! + -- Scheme Procedure: primitive-property-set! prop obj val + Set the property PROP of OBJ to VAL. + + primitive-property-del! + -- Scheme Procedure: primitive-property-del! prop obj + Remove any value associated with PROP and OBJ. + + random + -- Scheme Procedure: random n [state] + Return a number in [0, N). + + Accepts a positive integer or real n and returns a number of the + same type between zero (inclusive) and N (exclusive). The values + returned have a uniform distribution. + + The optional argument STATE must be of the type produced by + 'seed->random-state'. It defaults to the value of the variable + *RANDOM-STATE*. This object is used to maintain the state of the + pseudo-random-number generator and is altered as a side effect of + the random operation. + + copy-random-state + -- Scheme Procedure: copy-random-state [state] + Return a copy of the random state STATE. + + seed->random-state + -- Scheme Procedure: seed->random-state seed + Return a new random state using SEED. + + random:uniform + -- Scheme Procedure: random:uniform [state] + Return a uniformly distributed inexact real random number in [0,1). + + random:normal + -- Scheme Procedure: random:normal [state] + Return an inexact real in a normal distribution. The distribution + used has mean 0 and standard deviation 1. For a normal + distribution with mean m and standard deviation d use '(+ m (* d + (random:normal)))'. + + random:solid-sphere! + -- Scheme Procedure: random:solid-sphere! v [state] + Fills VECT with inexact real random numbers the sum of whose + squares is less than 1.0. Thinking of VECT as coordinates in space + of dimension N = '(vector-length VECT)', the coordinates are + uniformly distributed within the unit N-sphere. + + random:hollow-sphere! + -- Scheme Procedure: random:hollow-sphere! v [state] + Fills vect with inexact real random numbers the sum of whose + squares is equal to 1.0. Thinking of vect as coordinates in space + of dimension n = (vector-length vect), the coordinates are + uniformly distributed over the surface of the unit n-sphere. + + random:normal-vector! + -- Scheme Procedure: random:normal-vector! v [state] + Fills vect with inexact real random numbers that are independent + and standard normally distributed (i.e., with mean 0 and variance + 1). + + random:exp + -- Scheme Procedure: random:exp [state] + Return an inexact real in an exponential distribution with mean 1. + For an exponential distribution with mean u use (* u (random:exp)). + + %read-delimited! + -- Scheme Procedure: %read-delimited! delims str gobble [port [start + [end]]] + Read characters from PORT into STR until one of the characters in + the DELIMS string is encountered. If GOBBLE is true, discard the + delimiter character; otherwise, leave it in the input stream for + the next read. If PORT is not specified, use the value of + '(current-input-port)'. If START or END are specified, store data + only into the substring of STR bounded by START and END (which + default to the beginning and end of the string, respectively). + + Return a pair consisting of the delimiter that terminated the + string and the number of characters read. If reading stopped at + the end of file, the delimiter returned is the EOF-OBJECT; if the + string was filled without encountering a delimiter, this value is + '#f'. + + %read-line + -- Scheme Procedure: %read-line [port] + Read a newline-terminated line from PORT, allocating storage as + necessary. The newline terminator (if any) is removed from the + string, and a pair consisting of the line and its delimiter is + returned. The delimiter may be either a newline or the EOF-OBJECT; + if '%read-line' is called at the end of file, it returns the pair + '(# . #)'. + + write-line + -- Scheme Procedure: write-line obj [port] + Display OBJ and a newline character to PORT. If PORT is not + specified, '(current-output-port)' is used. This function is + equivalent to: + (display obj [port]) + (newline [port]) + + read-options-interface + -- Scheme Procedure: read-options-interface [setting] + Option interface for the read options. Instead of using this + procedure directly, use the procedures 'read-enable', + 'read-disable', 'read-set!' and 'read-options'. + + read + -- Scheme Procedure: read [port] + Read an s-expression from the input port PORT, or from the current + input port if PORT is not specified. Any whitespace before the + next token is discarded. + + read-hash-extend + -- Scheme Procedure: read-hash-extend chr proc + Install the procedure PROC for reading expressions starting with + the character sequence '#' and CHR. PROC will be called with two + arguments: the character CHR and the port to read further data + from. The object returned will be the return value of 'read'. + + call-with-dynamic-root + -- Scheme Procedure: call-with-dynamic-root thunk handler + Call THUNK with a new dynamic state and withina continuation + barrier. The HANDLER catches allotherwise uncaught throws and + executes within the samedynamic context as THUNK. + + dynamic-root + -- Scheme Procedure: dynamic-root + Return an object representing the current dynamic root. + + These objects are only useful for comparison using 'eq?'. + + read-string!/partial + -- Scheme Procedure: read-string!/partial str [port_or_fdes [start + [end]]] + Read characters from a port or file descriptor into a string STR. + A port must have an underlying file descriptor -- a so-called + fport. This procedure is scsh-compatible and can efficiently read + large strings. It will: + + * attempt to fill the entire string, unless the START and/or END + arguments are supplied. i.e., START defaults to 0 and END + defaults to '(string-length str)' + * use the current input port if PORT_OR_FDES is not supplied. + * return fewer than the requested number of characters in some + cases, e.g., on end of file, if interrupted by a signal, or if + not all the characters are immediately available. + * wait indefinitely for some input if no characters are + currently available, unless the port is in non-blocking mode. + * read characters from the port's input buffers if available, + instead from the underlying file descriptor. + * return '#f' if end-of-file is encountered before reading any + characters, otherwise return the number of characters read. + * return 0 if the port is in non-blocking mode and no characters + are immediately available. + * return 0 if the request is for 0 bytes, with no end-of-file + check. + + write-string/partial + -- Scheme Procedure: write-string/partial str [port_or_fdes [start + [end]]] + Write characters from a string STR to a port or file descriptor. A + port must have an underlying file descriptor -- a so-called fport. + This procedure is scsh-compatible and can efficiently write large + strings. It will: + + * attempt to write the entire string, unless the START and/or + END arguments are supplied. i.e., START defaults to 0 and END + defaults to '(string-length str)' + * use the current output port if PORT_OF_FDES is not supplied. + * in the case of a buffered port, store the characters in the + port's output buffer, if all will fit. If they will not fit + then any existing buffered characters will be flushed before + attempting to write the new characters directly to the + underlying file descriptor. If the port is in non-blocking + mode and buffered characters can not be flushed immediately, + then an 'EAGAIN' system-error exception will be raised (Note: + scsh does not support the use of non-blocking buffered ports.) + * write fewer than the requested number of characters in some + cases, e.g., if interrupted by a signal or if not all of the + output can be accepted immediately. + * wait indefinitely for at least one character from STR to be + accepted by the port, unless the port is in non-blocking mode. + * return the number of characters accepted by the port. + * return 0 if the port is in non-blocking mode and can not + accept at least one character from STR immediately + * return 0 immediately if the request size is 0 bytes. + + sigaction + -- Scheme Procedure: sigaction signum [handler [flags [thread]]] + Install or report the signal handler for a specified signal. + + SIGNUM is the signal number, which can be specified using the value + of variables such as 'SIGINT'. + + If HANDLER is omitted, 'sigaction' returns a pair: the CAR is the + current signal hander, which will be either an integer with the + value 'SIG_DFL' (default action) or 'SIG_IGN' (ignore), or the + Scheme procedure which handles the signal, or '#f' if a non-Scheme + procedure handles the signal. The CDR contains the current + 'sigaction' flags for the handler. + + If HANDLER is provided, it is installed as the new handler for + SIGNUM. HANDLER can be a Scheme procedure taking one argument, or + the value of 'SIG_DFL' (default action) or 'SIG_IGN' (ignore), or + '#f' to restore whatever signal handler was installed before + 'sigaction' was first used. When a scheme procedure has been + specified, that procedure will run in the given THREAD. When no + thread has been given, the thread that made this call to + 'sigaction' is used. Flags can optionally be specified for the new + handler. The return value is a pair with information about the old + handler as described above. + + This interface does not provide access to the "signal blocking" + facility. Maybe this is not needed, since the thread support may + provide solutions to the problem of consistent access to data + structures. + + restore-signals + -- Scheme Procedure: restore-signals + Return all signal handlers to the values they had before any call + to 'sigaction' was made. The return value is unspecified. + + alarm + -- Scheme Procedure: alarm i + Set a timer to raise a 'SIGALRM' signal after the specified number + of seconds (an integer). It's advisable to install a signal + handler for 'SIGALRM' beforehand, since the default action is to + terminate the process. + + The return value indicates the time remaining for the previous + alarm, if any. The new value replaces the previous alarm. If + there was no previous alarm, the return value is zero. + + setitimer + -- Scheme Procedure: setitimer which_timer interval_seconds + interval_microseconds value_seconds value_microseconds + Set the timer specified by WHICH_TIMER according to the given + INTERVAL_SECONDS, INTERVAL_MICROSECONDS, VALUE_SECONDS, and + VALUE_MICROSECONDS values. + + Return information about the timer's previous setting. Errors are + handled as described in the guile info pages under "POSIX Interface + Conventions". + + The timers available are: 'ITIMER_REAL', 'ITIMER_VIRTUAL', and + 'ITIMER_PROF'. + + The return value will be a list of two cons pairs representing the + current state of the given timer. The first pair is the seconds + and microseconds of the timer 'it_interval', and the second pair is + the seconds and microseconds of the timer 'it_value'. + + getitimer + -- Scheme Procedure: getitimer which_timer + Return information about the timer specified by WHICH_TIMER Errors + are handled as described in the guile info pages under "POSIX + Interface Conventions". + + The timers available are: 'ITIMER_REAL', 'ITIMER_VIRTUAL', and + 'ITIMER_PROF'. + + The return value will be a list of two cons pairs representing the + current state of the given timer. The first pair is the seconds + and microseconds of the timer 'it_interval', and the second pair is + the seconds and microseconds of the timer 'it_value'. + + pause + -- Scheme Procedure: pause + Pause the current process (thread?) until a signal arrives whose + action is to either terminate the current process or invoke a + handler procedure. The return value is unspecified. + + sleep + -- Scheme Procedure: sleep i + Wait for the given number of seconds (an integer) or until a signal + arrives. The return value is zero if the time elapses or the + number of seconds remaining otherwise. + + See also 'usleep'. + + usleep + -- Scheme Procedure: usleep i + Wait the given period USECS microseconds (an integer). If a signal + arrives the wait stops and the return value is the time remaining, + in microseconds. If the period elapses with no signal the return + is zero. + + On most systems the process scheduler is not microsecond accurate + and the actual period slept by 'usleep' may be rounded to a system + clock tick boundary. Traditionally such ticks were 10 milliseconds + apart, and that interval is often still used. + + See also 'sleep'. + + raise + -- Scheme Procedure: raise sig + Sends a specified signal SIG to the current process, where SIG is + as described for the kill procedure. + + system + -- Scheme Procedure: system [cmd] + Execute CMD using the operating system's "command processor". + Under Unix this is usually the default shell 'sh'. The value + returned is CMD's exit status as returned by 'waitpid', which can + be interpreted using 'status:exit-val' and friends. + + If 'system' is called without arguments, return a boolean + indicating whether the command processor is available. + + system* + -- Scheme Procedure: system* . args + Execute the command indicated by ARGS. The first element must be a + string indicating the command to be executed, and the remaining + items must be strings representing each of the arguments to that + command. + + This function returns the exit status of the command as provided by + 'waitpid'. This value can be handled with 'status:exit-val' and + the related functions. + + 'system*' is similar to 'system', but accepts only one string + per-argument, and performs no shell interpretation. The command is + executed using fork and execlp. Accordingly this function may be + safer than 'system' in situations where shell interpretation is not + required. + + Example: (system* "echo" "foo" "bar") + + getenv + -- Scheme Procedure: getenv nam + Looks up the string NAME in the current environment. The return + value is '#f' unless a string of the form 'NAME=VALUE' is found, in + which case the string 'VALUE' is returned. + + primitive-exit + -- Scheme Procedure: primitive-exit [status] + Terminate the current process without unwinding the Scheme stack. + The exit status is STATUS if supplied, otherwise zero. + + primitive-_exit + -- Scheme Procedure: primitive-_exit [status] + Terminate the current process using the _exit() system call and + without unwinding the Scheme stack. The exit status is STATUS if + supplied, otherwise zero. + + This function is typically useful after a fork, to ensure no Scheme + cleanups or 'atexit' handlers are run (those usually belonging in + the parent rather than the child). + + restricted-vector-sort! + -- Scheme Procedure: restricted-vector-sort! vec less startpos endpos + Sort the vector VEC, using LESS for comparing the vector elements. + STARTPOS (inclusively) and ENDPOS (exclusively) delimit the range + of the vector which gets sorted. The return value is not + specified. + + sorted? + -- Scheme Procedure: sorted? items less + Return '#t' iff ITEMS is a list or a vector such that for all 1 <= + i <= m, the predicate LESS returns true when applied to all + elements i - 1 and i + + merge + -- Scheme Procedure: merge alist blist less + Merge two already sorted lists into one. Given two lists ALIST and + BLIST, such that '(sorted? alist less?)' and '(sorted? blist + less?)', return a new list in which the elements of ALIST and BLIST + have been stably interleaved so that '(sorted? (merge alist blist + less?) less?)'. Note: this does _not_ accept vectors. + + merge! + -- Scheme Procedure: merge! alist blist less + Takes two lists ALIST and BLIST such that '(sorted? alist less?)' + and '(sorted? blist less?)' and returns a new list in which the + elements of ALIST and BLIST have been stably interleaved so that + '(sorted? (merge alist blist less?) less?)'. This is the + destructive variant of 'merge' Note: this does _not_ accept + vectors. + + sort! + -- Scheme Procedure: sort! items less + Sort the sequence ITEMS, which may be a list or a vector. LESS is + used for comparing the sequence elements. The sorting is + destructive, that means that the input sequence is modified to + produce the sorted result. This is not a stable sort. + + sort + -- Scheme Procedure: sort items less + Sort the sequence ITEMS, which may be a list or a vector. LESS is + used for comparing the sequence elements. This is not a stable + sort. + + stable-sort! + -- Scheme Procedure: stable-sort! items less + Sort the sequence ITEMS, which may be a list or a vector. LESS is + used for comparing the sequence elements. The sorting is + destructive, that means that the input sequence is modified to + produce the sorted result. This is a stable sort. + + stable-sort + -- Scheme Procedure: stable-sort items less + Sort the sequence ITEMS, which may be a list or a vector. LESS is + used for comparing the sequence elements. This is a stable sort. + + sort-list! + -- Scheme Procedure: sort-list! items less + Sort the list ITEMS, using LESS for comparing the list elements. + The sorting is destructive, that means that the input list is + modified to produce the sorted result. This is a stable sort. + + sort-list + -- Scheme Procedure: sort-list items less + Sort the list ITEMS, using LESS for comparing the list elements. + This is a stable sort. + + source-properties + -- Scheme Procedure: source-properties obj + Return the source property association list of OBJ. + + set-source-properties! + -- Scheme Procedure: set-source-properties! obj plist + Install the association list PLIST as the source property list for + OBJ. + + source-property + -- Scheme Procedure: source-property obj key + Return the source property specified by KEY from OBJ's source + property list. + + set-source-property! + -- Scheme Procedure: set-source-property! obj key datum + Set the source property of object OBJ, which is specified by KEY to + DATUM. Normally, the key will be a symbol. + + %get-stack-size + -- Scheme Procedure: %get-stack-size + Return the current thread's C stack size (in Scheme objects). + + stack? + -- Scheme Procedure: stack? obj + Return '#t' if OBJ is a calling stack. + + make-stack + -- Scheme Procedure: make-stack obj . args + Create a new stack. If OBJ is '#t', the current evaluation stack + is used for creating the stack frames, otherwise the frames are + taken from OBJ (which must be either a debug object or a + continuation). + + ARGS should be a list containing any combination of integer, + procedure and '#t' values. + + These values specify various ways of cutting away uninteresting + stack frames from the top and bottom of the stack that 'make-stack' + returns. They come in pairs like this: '(INNER_CUT_1 OUTER_CUT_1 + INNER_CUT_2 OUTER_CUT_2 ...)'. + + Each INNER_CUT_N can be '#t', an integer, or a procedure. '#t' + means to cut away all frames up to but excluding the first user + module frame. An integer means to cut away exactly that number of + frames. A procedure means to cut away all frames up to but + excluding the application frame whose procedure matches the + specified one. + + Each OUTER_CUT_N can be an integer or a procedure. An integer + means to cut away that number of frames. A procedure means to cut + away frames down to but excluding the application frame whose + procedure matches the specified one. + + If the OUTER_CUT_N of the last pair is missing, it is taken as 0. + + stack-id + -- Scheme Procedure: stack-id stack + Return the identifier given to STACK by 'start-stack'. + + stack-ref + -- Scheme Procedure: stack-ref stack index + Return the INDEX'th frame from STACK. + + stack-length + -- Scheme Procedure: stack-length stack + Return the length of STACK. + + frame? + -- Scheme Procedure: frame? obj + Return '#t' if OBJ is a stack frame. + + last-stack-frame + -- Scheme Procedure: last-stack-frame obj + Return a stack which consists of a single frame, which is the last + stack frame for OBJ. OBJ must be either a debug object or a + continuation. + + frame-number + -- Scheme Procedure: frame-number frame + Return the frame number of FRAME. + + frame-source + -- Scheme Procedure: frame-source frame + Return the source of FRAME. + + frame-procedure + -- Scheme Procedure: frame-procedure frame + Return the procedure for FRAME, or '#f' if no procedure is + associated with FRAME. + + frame-arguments + -- Scheme Procedure: frame-arguments frame + Return the arguments of FRAME. + + frame-previous + -- Scheme Procedure: frame-previous frame + Return the previous frame of FRAME, or '#f' if FRAME is the first + frame in its stack. + + frame-next + -- Scheme Procedure: frame-next frame + Return the next frame of FRAME, or '#f' if FRAME is the last frame + in its stack. + + frame-real? + -- Scheme Procedure: frame-real? frame + Return '#t' if FRAME is a real frame. + + frame-procedure? + -- Scheme Procedure: frame-procedure? frame + Return '#t' if a procedure is associated with FRAME. + + frame-evaluating-args? + -- Scheme Procedure: frame-evaluating-args? frame + Return '#t' if FRAME contains evaluated arguments. + + frame-overflow? + -- Scheme Procedure: frame-overflow? frame + Return '#t' if FRAME is an overflow frame. + + get-internal-real-time + -- Scheme Procedure: get-internal-real-time + Return the number of time units since the interpreter was started. + + times + -- Scheme Procedure: times + Return an object with information about real and processor time. + The following procedures accept such an object as an argument and + return a selected component: + + 'tms:clock' + The current real time, expressed as time units relative to an + arbitrary base. + 'tms:utime' + The CPU time units used by the calling process. + 'tms:stime' + The CPU time units used by the system on behalf of the calling + process. + 'tms:cutime' + The CPU time units used by terminated child processes of the + calling process, whose status has been collected (e.g., using + 'waitpid'). + 'tms:cstime' + Similarly, the CPU times units used by the system on behalf of + terminated child processes. + + get-internal-run-time + -- Scheme Procedure: get-internal-run-time + Return the number of time units of processor time used by the + interpreter. Both _system_ and _user_ time are included but + subprocesses are not. + + current-time + -- Scheme Procedure: current-time + Return the number of seconds since 1970-01-01 00:00:00 UTC, + excluding leap seconds. + + gettimeofday + -- Scheme Procedure: gettimeofday + Return a pair containing the number of seconds and microseconds + since 1970-01-01 00:00:00 UTC, excluding leap seconds. Note: + whether true microsecond resolution is available depends on the + operating system. + + localtime + -- Scheme Procedure: localtime time [zone] + Return an object representing the broken down components of TIME, + an integer like the one returned by 'current-time'. The time zone + for the calculation is optionally specified by ZONE (a string), + otherwise the 'TZ' environment variable or the system default is + used. + + gmtime + -- Scheme Procedure: gmtime time + Return an object representing the broken down components of TIME, + an integer like the one returned by 'current-time'. The values are + calculated for UTC. + + mktime + -- Scheme Procedure: mktime sbd_time [zone] + BD-TIME is an object representing broken down time and 'zone' is an + optional time zone specifier (otherwise the TZ environment variable + or the system default is used). + + Returns a pair: the car is a corresponding integer time value like + that returned by 'current-time'; the cdr is a broken down time + object, similar to as BD-TIME but with normalized values. + + tzset + -- Scheme Procedure: tzset + Initialize the timezone from the TZ environment variable or the + system default. It's not usually necessary to call this procedure + since it's done automatically by other procedures that depend on + the timezone. + + strftime + -- Scheme Procedure: strftime format stime + Return a string which is broken-down time structure STIME formatted + according to the given FORMAT string. + + FORMAT contains field specifications introduced by a '%' character. + See *note (libc)Formatting Calendar Time::, or 'man 3 strftime', + for the available formatting. + + (strftime "%c" (localtime (current-time))) + => "Mon Mar 11 20:17:43 2002" + + If 'setlocale' has been called (*note Locales::), month and day + names are from the current locale and in the locale character set. + + strptime + -- Scheme Procedure: strptime format string + Performs the reverse action to 'strftime', parsing STRING according + to the specification supplied in TEMPLATE. The interpretation of + month and day names is dependent on the current locale. The value + returned is a pair. The car has an object with time components in + the form returned by 'localtime' or 'gmtime', but the time zone + components are not usefully set. The cdr reports the number of + characters from STRING which were used for the conversion. + + string? + -- Scheme Procedure: string? obj + Return '#t' if OBJ is a string, else '#f'. + + list->string + -- Scheme Procedure: list->string + implemented by the C function "scm_string" + + string + -- Scheme Procedure: string . chrs + -- Scheme Procedure: list->string chrs + Return a newly allocated string composed of the arguments, CHRS. + + make-string + -- Scheme Procedure: make-string k [chr] + Return a newly allocated string of length K. If CHR is given, then + all elements of the string are initialized to CHR, otherwise the + contents of the STRING are unspecified. + + string-length + -- Scheme Procedure: string-length string + Return the number of characters in STRING. + + string-ref + -- Scheme Procedure: string-ref str k + Return character K of STR using zero-origin indexing. K must be a + valid index of STR. + + string-set! + -- Scheme Procedure: string-set! str k chr + Store CHR in element K of STR and return an unspecified value. K + must be a valid index of STR. + + substring + -- Scheme Procedure: substring str start [end] + Return a newly allocated string formed from the characters of STR + beginning with index START (inclusive) and ending with index END + (exclusive). STR must be a string, START and END must be exact + integers satisfying: + + 0 <= START <= END <= (string-length STR). + + substring/read-only + -- Scheme Procedure: substring/read-only str start [end] + Return a newly allocated string formed from the characters of STR + beginning with index START (inclusive) and ending with index END + (exclusive). STR must be a string, START and END must be exact + integers satisfying: + + 0 <= START <= END <= (string-length STR). + + The returned string is read-only. + + substring/copy + -- Scheme Procedure: substring/copy str start [end] + Return a newly allocated string formed from the characters of STR + beginning with index START (inclusive) and ending with index END + (exclusive). STR must be a string, START and END must be exact + integers satisfying: + + 0 <= START <= END <= (string-length STR). + + substring/shared + -- Scheme Procedure: substring/shared str start [end] + Return string that indirectly refers to the characters of STR + beginning with index START (inclusive) and ending with index END + (exclusive). STR must be a string, START and END must be exact + integers satisfying: + + 0 <= START <= END <= (string-length STR). + + string-append + -- Scheme Procedure: string-append . args + Return a newly allocated string whose characters form the + concatenation of the given strings, ARGS. + + uniform-vector? + -- Scheme Procedure: uniform-vector? obj + Return '#t' if OBJ is a uniform vector. + + uniform-vector-ref + -- Scheme Procedure: uniform-vector-ref v idx + Return the element at index IDX of the homogenous numeric vector V. + + uniform-vector-set! + -- Scheme Procedure: uniform-vector-set! v idx val + Set the element at index IDX of the homogenous numeric vector V to + VAL. + + uniform-vector->list + -- Scheme Procedure: uniform-vector->list uvec + Convert the uniform numeric vector UVEC to a list. + + uniform-vector-length + -- Scheme Procedure: uniform-vector-length v + Return the number of elements in the uniform vector V. + + uniform-vector-read! + -- Scheme Procedure: uniform-vector-read! uvec [port_or_fd [start + [end]]] + Fill the elements of UVEC by reading raw bytes from PORT-OR-FDES, + using host byte order. + + The optional arguments START (inclusive) and END (exclusive) allow + a specified region to be read, leaving the remainder of the vector + unchanged. + + When PORT-OR-FDES is a port, all specified elements of UVEC are + attempted to be read, potentially blocking while waiting formore + input or end-of-file. When PORT-OR-FD is an integer, a single call + to read(2) is made. + + An error is signalled when the last element has only been partially + filled before reaching end-of-file or in the single call to + read(2). + + 'uniform-vector-read!' returns the number of elements read. + + PORT-OR-FDES may be omitted, in which case it defaults to the value + returned by '(current-input-port)'. + + uniform-vector-write + -- Scheme Procedure: uniform-vector-write uvec [port_or_fd [start + [end]]] + Write the elements of UVEC as raw bytes to PORT-OR-FDES, in the + host byte order. + + The optional arguments START (inclusive) and END (exclusive) allow + a specified region to be written. + + When PORT-OR-FDES is a port, all specified elements of UVEC are + attempted to be written, potentially blocking while waiting for + more room. When PORT-OR-FD is an integer, a single call to + write(2) is made. + + An error is signalled when the last element has only been partially + written in the single call to write(2). + + The number of objects actually written is returned. PORT-OR-FDES + may be omitted, in which case it defaults to the value returned by + '(current-output-port)'. + + u8vector? + -- Scheme Procedure: u8vector? obj + Return '#t' if OBJ is a vector of type u8, '#f' otherwise. + + make-u8vector + -- Scheme Procedure: make-u8vector len [fill] + Return a newly allocated uniform numeric vector which can hold LEN + elements. If FILL is given, it is used to initialize the elements, + otherwise the contents of the vector is unspecified. + + u8vector + -- Scheme Procedure: u8vector . l + Return a newly allocated uniform numeric vector containing all + argument values. + + u8vector-length + -- Scheme Procedure: u8vector-length uvec + Return the number of elements in the uniform numeric vector UVEC. + + u8vector-ref + -- Scheme Procedure: u8vector-ref uvec index + Return the element at INDEX in the uniform numeric vector UVEC. + + u8vector-set! + -- Scheme Procedure: u8vector-set! uvec index value + Set the element at INDEX in the uniform numeric vector UVEC to + VALUE. The return value is not specified. + + u8vector->list + -- Scheme Procedure: u8vector->list uvec + Convert the uniform numeric vector UVEC to a list. + + list->u8vector + -- Scheme Procedure: list->u8vector l + Convert the list L to a numeric uniform vector. + + any->u8vector + -- Scheme Procedure: any->u8vector obj + Convert OBJ, which can be a list, vector, or uniform vector, to a + numeric uniform vector of type u8. + + s8vector? + -- Scheme Procedure: s8vector? obj + Return '#t' if OBJ is a vector of type s8, '#f' otherwise. + + make-s8vector + -- Scheme Procedure: make-s8vector len [fill] + Return a newly allocated uniform numeric vector which can hold LEN + elements. If FILL is given, it is used to initialize the elements, + otherwise the contents of the vector is unspecified. + + s8vector + -- Scheme Procedure: s8vector . l + Return a newly allocated uniform numeric vector containing all + argument values. + + s8vector-length + -- Scheme Procedure: s8vector-length uvec + Return the number of elements in the uniform numeric vector UVEC. + + s8vector-ref + -- Scheme Procedure: s8vector-ref uvec index + Return the element at INDEX in the uniform numeric vector UVEC. + + s8vector-set! + -- Scheme Procedure: s8vector-set! uvec index value + Set the element at INDEX in the uniform numeric vector UVEC to + VALUE. The return value is not specified. + + s8vector->list + -- Scheme Procedure: s8vector->list uvec + Convert the uniform numeric vector UVEC to a list. + + list->s8vector + -- Scheme Procedure: list->s8vector l + Convert the list L to a numeric uniform vector. + + any->s8vector + -- Scheme Procedure: any->s8vector obj + Convert OBJ, which can be a list, vector, or uniform vector, to a + numeric uniform vector of type s8. + + u16vector? + -- Scheme Procedure: u16vector? obj + Return '#t' if OBJ is a vector of type u16, '#f' otherwise. + + make-u16vector + -- Scheme Procedure: make-u16vector len [fill] + Return a newly allocated uniform numeric vector which can hold LEN + elements. If FILL is given, it is used to initialize the elements, + otherwise the contents of the vector is unspecified. + + u16vector + -- Scheme Procedure: u16vector . l + Return a newly allocated uniform numeric vector containing all + argument values. + + u16vector-length + -- Scheme Procedure: u16vector-length uvec + Return the number of elements in the uniform numeric vector UVEC. + + u16vector-ref + -- Scheme Procedure: u16vector-ref uvec index + Return the element at INDEX in the uniform numeric vector UVEC. + + u16vector-set! + -- Scheme Procedure: u16vector-set! uvec index value + Set the element at INDEX in the uniform numeric vector UVEC to + VALUE. The return value is not specified. + + u16vector->list + -- Scheme Procedure: u16vector->list uvec + Convert the uniform numeric vector UVEC to a list. + + list->u16vector + -- Scheme Procedure: list->u16vector l + Convert the list L to a numeric uniform vector. + + any->u16vector + -- Scheme Procedure: any->u16vector obj + Convert OBJ, which can be a list, vector, or uniform vector, to a + numeric uniform vector of type u16. + + s16vector? + -- Scheme Procedure: s16vector? obj + Return '#t' if OBJ is a vector of type s16, '#f' otherwise. + + make-s16vector + -- Scheme Procedure: make-s16vector len [fill] + Return a newly allocated uniform numeric vector which can hold LEN + elements. If FILL is given, it is used to initialize the elements, + otherwise the contents of the vector is unspecified. + + s16vector + -- Scheme Procedure: s16vector . l + Return a newly allocated uniform numeric vector containing all + argument values. + + s16vector-length + -- Scheme Procedure: s16vector-length uvec + Return the number of elements in the uniform numeric vector UVEC. + + s16vector-ref + -- Scheme Procedure: s16vector-ref uvec index + Return the element at INDEX in the uniform numeric vector UVEC. + + s16vector-set! + -- Scheme Procedure: s16vector-set! uvec index value + Set the element at INDEX in the uniform numeric vector UVEC to + VALUE. The return value is not specified. + + s16vector->list + -- Scheme Procedure: s16vector->list uvec + Convert the uniform numeric vector UVEC to a list. + + list->s16vector + -- Scheme Procedure: list->s16vector l + Convert the list L to a numeric uniform vector. + + any->s16vector + -- Scheme Procedure: any->s16vector obj + Convert OBJ, which can be a list, vector, or uniform vector, to a + numeric uniform vector of type s16. + + u32vector? + -- Scheme Procedure: u32vector? obj + Return '#t' if OBJ is a vector of type u32, '#f' otherwise. + + make-u32vector + -- Scheme Procedure: make-u32vector len [fill] + Return a newly allocated uniform numeric vector which can hold LEN + elements. If FILL is given, it is used to initialize the elements, + otherwise the contents of the vector is unspecified. + + u32vector + -- Scheme Procedure: u32vector . l + Return a newly allocated uniform numeric vector containing all + argument values. + + u32vector-length + -- Scheme Procedure: u32vector-length uvec + Return the number of elements in the uniform numeric vector UVEC. + + u32vector-ref + -- Scheme Procedure: u32vector-ref uvec index + Return the element at INDEX in the uniform numeric vector UVEC. + + u32vector-set! + -- Scheme Procedure: u32vector-set! uvec index value + Set the element at INDEX in the uniform numeric vector UVEC to + VALUE. The return value is not specified. + + u32vector->list + -- Scheme Procedure: u32vector->list uvec + Convert the uniform numeric vector UVEC to a list. + + list->u32vector + -- Scheme Procedure: list->u32vector l + Convert the list L to a numeric uniform vector. + + any->u32vector + -- Scheme Procedure: any->u32vector obj + Convert OBJ, which can be a list, vector, or uniform vector, to a + numeric uniform vector of type u32. + + s32vector? + -- Scheme Procedure: s32vector? obj + Return '#t' if OBJ is a vector of type s32, '#f' otherwise. + + make-s32vector + -- Scheme Procedure: make-s32vector len [fill] + Return a newly allocated uniform numeric vector which can hold LEN + elements. If FILL is given, it is used to initialize the elements, + otherwise the contents of the vector is unspecified. + + s32vector + -- Scheme Procedure: s32vector . l + Return a newly allocated uniform numeric vector containing all + argument values. + + s32vector-length + -- Scheme Procedure: s32vector-length uvec + Return the number of elements in the uniform numeric vector UVEC. + + s32vector-ref + -- Scheme Procedure: s32vector-ref uvec index + Return the element at INDEX in the uniform numeric vector UVEC. + + s32vector-set! + -- Scheme Procedure: s32vector-set! uvec index value + Set the element at INDEX in the uniform numeric vector UVEC to + VALUE. The return value is not specified. + + s32vector->list + -- Scheme Procedure: s32vector->list uvec + Convert the uniform numeric vector UVEC to a list. + + list->s32vector + -- Scheme Procedure: list->s32vector l + Convert the list L to a numeric uniform vector. + + any->s32vector + -- Scheme Procedure: any->s32vector obj + Convert OBJ, which can be a list, vector, or uniform vector, to a + numeric uniform vector of type s32. + + u64vector? + -- Scheme Procedure: u64vector? obj + Return '#t' if OBJ is a vector of type u64, '#f' otherwise. + + make-u64vector + -- Scheme Procedure: make-u64vector len [fill] + Return a newly allocated uniform numeric vector which can hold LEN + elements. If FILL is given, it is used to initialize the elements, + otherwise the contents of the vector is unspecified. + + u64vector + -- Scheme Procedure: u64vector . l + Return a newly allocated uniform numeric vector containing all + argument values. + + u64vector-length + -- Scheme Procedure: u64vector-length uvec + Return the number of elements in the uniform numeric vector UVEC. + + u64vector-ref + -- Scheme Procedure: u64vector-ref uvec index + Return the element at INDEX in the uniform numeric vector UVEC. + + u64vector-set! + -- Scheme Procedure: u64vector-set! uvec index value + Set the element at INDEX in the uniform numeric vector UVEC to + VALUE. The return value is not specified. + + u64vector->list + -- Scheme Procedure: u64vector->list uvec + Convert the uniform numeric vector UVEC to a list. + + list->u64vector + -- Scheme Procedure: list->u64vector l + Convert the list L to a numeric uniform vector. + + any->u64vector + -- Scheme Procedure: any->u64vector obj + Convert OBJ, which can be a list, vector, or uniform vector, to a + numeric uniform vector of type u64. + + s64vector? + -- Scheme Procedure: s64vector? obj + Return '#t' if OBJ is a vector of type s64, '#f' otherwise. + + make-s64vector + -- Scheme Procedure: make-s64vector len [fill] + Return a newly allocated uniform numeric vector which can hold LEN + elements. If FILL is given, it is used to initialize the elements, + otherwise the contents of the vector is unspecified. + + s64vector + -- Scheme Procedure: s64vector . l + Return a newly allocated uniform numeric vector containing all + argument values. + + s64vector-length + -- Scheme Procedure: s64vector-length uvec + Return the number of elements in the uniform numeric vector UVEC. + + s64vector-ref + -- Scheme Procedure: s64vector-ref uvec index + Return the element at INDEX in the uniform numeric vector UVEC. + + s64vector-set! + -- Scheme Procedure: s64vector-set! uvec index value + Set the element at INDEX in the uniform numeric vector UVEC to + VALUE. The return value is not specified. + + s64vector->list + -- Scheme Procedure: s64vector->list uvec + Convert the uniform numeric vector UVEC to a list. + + list->s64vector + -- Scheme Procedure: list->s64vector l + Convert the list L to a numeric uniform vector. + + any->s64vector + -- Scheme Procedure: any->s64vector obj + Convert OBJ, which can be a list, vector, or uniform vector, to a + numeric uniform vector of type s64. + + f32vector? + -- Scheme Procedure: f32vector? obj + Return '#t' if OBJ is a vector of type f32, '#f' otherwise. + + make-f32vector + -- Scheme Procedure: make-f32vector len [fill] + Return a newly allocated uniform numeric vector which can hold LEN + elements. If FILL is given, it is used to initialize the elements, + otherwise the contents of the vector is unspecified. + + f32vector + -- Scheme Procedure: f32vector . l + Return a newly allocated uniform numeric vector containing all + argument values. + + f32vector-length + -- Scheme Procedure: f32vector-length uvec + Return the number of elements in the uniform numeric vector UVEC. + + f32vector-ref + -- Scheme Procedure: f32vector-ref uvec index + Return the element at INDEX in the uniform numeric vector UVEC. + + f32vector-set! + -- Scheme Procedure: f32vector-set! uvec index value + Set the element at INDEX in the uniform numeric vector UVEC to + VALUE. The return value is not specified. + + f32vector->list + -- Scheme Procedure: f32vector->list uvec + Convert the uniform numeric vector UVEC to a list. + + list->f32vector + -- Scheme Procedure: list->f32vector l + Convert the list L to a numeric uniform vector. + + any->f32vector + -- Scheme Procedure: any->f32vector obj + Convert OBJ, which can be a list, vector, or uniform vector, to a + numeric uniform vector of type f32. + + f64vector? + -- Scheme Procedure: f64vector? obj + Return '#t' if OBJ is a vector of type f64, '#f' otherwise. + + make-f64vector + -- Scheme Procedure: make-f64vector len [fill] + Return a newly allocated uniform numeric vector which can hold LEN + elements. If FILL is given, it is used to initialize the elements, + otherwise the contents of the vector is unspecified. + + f64vector + -- Scheme Procedure: f64vector . l + Return a newly allocated uniform numeric vector containing all + argument values. + + f64vector-length + -- Scheme Procedure: f64vector-length uvec + Return the number of elements in the uniform numeric vector UVEC. + + f64vector-ref + -- Scheme Procedure: f64vector-ref uvec index + Return the element at INDEX in the uniform numeric vector UVEC. + + f64vector-set! + -- Scheme Procedure: f64vector-set! uvec index value + Set the element at INDEX in the uniform numeric vector UVEC to + VALUE. The return value is not specified. + + f64vector->list + -- Scheme Procedure: f64vector->list uvec + Convert the uniform numeric vector UVEC to a list. + + list->f64vector + -- Scheme Procedure: list->f64vector l + Convert the list L to a numeric uniform vector. + + any->f64vector + -- Scheme Procedure: any->f64vector obj + Convert OBJ, which can be a list, vector, or uniform vector, to a + numeric uniform vector of type f64. + + c32vector? + -- Scheme Procedure: c32vector? obj + Return '#t' if OBJ is a vector of type c32, '#f' otherwise. + + make-c32vector + -- Scheme Procedure: make-c32vector len [fill] + Return a newly allocated uniform numeric vector which can hold LEN + elements. If FILL is given, it is used to initialize the elements, + otherwise the contents of the vector is unspecified. + + c32vector + -- Scheme Procedure: c32vector . l + Return a newly allocated uniform numeric vector containing all + argument values. + + c32vector-length + -- Scheme Procedure: c32vector-length uvec + Return the number of elements in the uniform numeric vector UVEC. + + c32vector-ref + -- Scheme Procedure: c32vector-ref uvec index + Return the element at INDEX in the uniform numeric vector UVEC. + + c32vector-set! + -- Scheme Procedure: c32vector-set! uvec index value + Set the element at INDEX in the uniform numeric vector UVEC to + VALUE. The return value is not specified. + + c32vector->list + -- Scheme Procedure: c32vector->list uvec + Convert the uniform numeric vector UVEC to a list. + + list->c32vector + -- Scheme Procedure: list->c32vector l + Convert the list L to a numeric uniform vector. + + any->c32vector + -- Scheme Procedure: any->c32vector obj + Convert OBJ, which can be a list, vector, or uniform vector, to a + numeric uniform vector of type c32. + + c64vector? + -- Scheme Procedure: c64vector? obj + Return '#t' if OBJ is a vector of type c64, '#f' otherwise. + + make-c64vector + -- Scheme Procedure: make-c64vector len [fill] + Return a newly allocated uniform numeric vector which can hold LEN + elements. If FILL is given, it is used to initialize the elements, + otherwise the contents of the vector is unspecified. + + c64vector + -- Scheme Procedure: c64vector . l + Return a newly allocated uniform numeric vector containing all + argument values. + + c64vector-length + -- Scheme Procedure: c64vector-length uvec + Return the number of elements in the uniform numeric vector UVEC. + + c64vector-ref + -- Scheme Procedure: c64vector-ref uvec index + Return the element at INDEX in the uniform numeric vector UVEC. + + c64vector-set! + -- Scheme Procedure: c64vector-set! uvec index value + Set the element at INDEX in the uniform numeric vector UVEC to + VALUE. The return value is not specified. + + c64vector->list + -- Scheme Procedure: c64vector->list uvec + Convert the uniform numeric vector UVEC to a list. + + list->c64vector + -- Scheme Procedure: list->c64vector l + Convert the list L to a numeric uniform vector. + + any->c64vector + -- Scheme Procedure: any->c64vector obj + Convert OBJ, which can be a list, vector, or uniform vector, to a + numeric uniform vector of type c64. + + string-null? + -- Scheme Procedure: string-null? str + Return '#t' if STR's length is zero, and '#f' otherwise. + (string-null? "") => #t + y => "foo" + (string-null? y) => #f + + string-any-c-code + -- Scheme Procedure: string-any-c-code char_pred s [start [end]] + Check if CHAR_PRED is true for any character in string S. + + CHAR_PRED can be a character to check for any equal to that, or a + character set (*note Character Sets::) to check for any in that + set, or a predicate procedure to call. + + For a procedure, calls '(CHAR_PRED c)' are made successively on the + characters from START to END. If CHAR_PRED returns true (ie. + non-'#f'), 'string-any' stops and that return value is the return + from 'string-any'. The call on the last character (ie. at END-1), + if that point is reached, is a tail call. + + If there are no characters in S (ie. START equals END) then the + return is '#f'. + + string-every-c-code + -- Scheme Procedure: string-every-c-code char_pred s [start [end]] + Check if CHAR_PRED is true for every character in string S. + + CHAR_PRED can be a character to check for every character equal to + that, or a character set (*note Character Sets::) to check for + every character being in that set, or a predicate procedure to + call. + + For a procedure, calls '(CHAR_PRED c)' are made successively on the + characters from START to END. If CHAR_PRED returns '#f', + 'string-every' stops and returns '#f'. The call on the last + character (ie. at END-1), if that point is reached, is a tail call + and the return from that call is the return from 'string-every'. + + If there are no characters in S (ie. START equals END) then the + return is '#t'. + + string-tabulate + -- Scheme Procedure: string-tabulate proc len + PROC is an integer->char procedure. Construct a string of size LEN + by applying PROC to each index to produce the corresponding string + element. The order in which PROC is applied to the indices is not + specified. + + string->list + -- Scheme Procedure: string->list str [start [end]] + Convert the string STR into a list of characters. + + reverse-list->string + -- Scheme Procedure: reverse-list->string chrs + An efficient implementation of '(compose string->list reverse)': + + (reverse-list->string '(#\a #\B #\c)) => "cBa" + + string-join + -- Scheme Procedure: string-join ls [delimiter [grammar]] + Append the string in the string list LS, using the string DELIM as + a delimiter between the elements of LS. GRAMMAR is a symbol which + specifies how the delimiter is placed between the strings, and + defaults to the symbol 'infix'. + + 'infix' + Insert the separator between list elements. An empty string + will produce an empty list. + 'string-infix' + Like 'infix', but will raise an error if given the empty list. + 'suffix' + Insert the separator after every list element. + 'prefix' + Insert the separator before each list element. + + string-copy + -- Scheme Procedure: string-copy str [start [end]] + Return a freshly allocated copy of the string STR. If given, START + and END delimit the portion of STR which is copied. + + string-copy! + -- Scheme Procedure: string-copy! target tstart s [start [end]] + Copy the sequence of characters from index range [START, END) in + string S to string TARGET, beginning at index TSTART. The + characters are copied left-to-right or right-to-left as needed - + the copy is guaranteed to work, even if TARGET and S are the same + string. It is an error if the copy operation runs off the end of + the target string. + + substring-move! + -- Scheme Procedure: substring-move! str1 start1 end1 str2 start2 + Copy the substring of STR1 bounded by START1 and END1 into STR2 + beginning at position START2. STR1 and STR2 can be the same + string. + + string-take + -- Scheme Procedure: string-take s n + Return the N first characters of S. + + string-drop + -- Scheme Procedure: string-drop s n + Return all but the first N characters of S. + + string-take-right + -- Scheme Procedure: string-take-right s n + Return the N last characters of S. + + string-drop-right + -- Scheme Procedure: string-drop-right s n + Return all but the last N characters of S. + + string-pad + -- Scheme Procedure: string-pad s len [chr [start [end]]] + Take that characters from START to END from the string S and return + a new string, right-padded by the character CHR to length LEN. If + the resulting string is longer than LEN, it is truncated on the + right. + + string-pad-right + -- Scheme Procedure: string-pad-right s len [chr [start [end]]] + Take that characters from START to END from the string S and return + a new string, left-padded by the character CHR to length LEN. If + the resulting string is longer than LEN, it is truncated on the + left. + + string-trim + -- Scheme Procedure: string-trim s [char_pred [start [end]]] + Trim S by skipping over all characters on the left that satisfy the + parameter CHAR_PRED: + + * if it is the character CH, characters equal to CH are trimmed, + + * if it is a procedure PRED characters that satisfy PRED are + trimmed, + + * if it is a character set, characters in that set are trimmed. + + If called without a CHAR_PRED argument, all whitespace is trimmed. + + string-trim-right + -- Scheme Procedure: string-trim-right s [char_pred [start [end]]] + Trim S by skipping over all characters on the rightt that satisfy + the parameter CHAR_PRED: + + * if it is the character CH, characters equal to CH are trimmed, + + * if it is a procedure PRED characters that satisfy PRED are + trimmed, + + * if it is a character sets, all characters in that set are + trimmed. + + If called without a CHAR_PRED argument, all whitespace is trimmed. + + string-trim-both + -- Scheme Procedure: string-trim-both s [char_pred [start [end]]] + Trim S by skipping over all characters on both sides of the string + that satisfy the parameter CHAR_PRED: + + * if it is the character CH, characters equal to CH are trimmed, + + * if it is a procedure PRED characters that satisfy PRED are + trimmed, + + * if it is a character set, the characters in the set are + trimmed. + + If called without a CHAR_PRED argument, all whitespace is trimmed. + + string-fill! + -- Scheme Procedure: string-fill! str chr [start [end]] + Stores CHR in every element of the given STR and returns an + unspecified value. + + string-compare + -- Scheme Procedure: string-compare s1 s2 proc_lt proc_eq proc_gt + [start1 [end1 [start2 [end2]]]] + Apply PROC_LT, PROC_EQ, PROC_GT to the mismatch index, depending + upon whether S1 is less than, equal to, or greater than S2. The + mismatch index is the largest index I such that for every 0 <= J < + I, S1[J] = S2[J] - that is, I is the first position that does not + match. + + string-compare-ci + -- Scheme Procedure: string-compare-ci s1 s2 proc_lt proc_eq proc_gt + [start1 [end1 [start2 [end2]]]] + Apply PROC_LT, PROC_EQ, PROC_GT to the mismatch index, depending + upon whether S1 is less than, equal to, or greater than S2. The + mismatch index is the largest index I such that for every 0 <= J < + I, S1[J] = S2[J] - that is, I is the first position that does not + match. The character comparison is done case-insensitively. + + string= + -- Scheme Procedure: string= s1 s2 [start1 [end1 [start2 [end2]]]] + Return '#f' if S1 and S2 are not equal, a true value otherwise. + + string<> + -- Scheme Procedure: string<> s1 s2 [start1 [end1 [start2 [end2]]]] + Return '#f' if S1 and S2 are equal, a true value otherwise. + + string< + -- Scheme Procedure: string< s1 s2 [start1 [end1 [start2 [end2]]]] + Return '#f' if S1 is greater or equal to S2, a true value + otherwise. + + string> + -- Scheme Procedure: string> s1 s2 [start1 [end1 [start2 [end2]]]] + Return '#f' if S1 is less or equal to S2, a true value otherwise. + + string<= + -- Scheme Procedure: string<= s1 s2 [start1 [end1 [start2 [end2]]]] + Return '#f' if S1 is greater to S2, a true value otherwise. + + string>= + -- Scheme Procedure: string>= s1 s2 [start1 [end1 [start2 [end2]]]] + Return '#f' if S1 is less to S2, a true value otherwise. + + string-ci= + -- Scheme Procedure: string-ci= s1 s2 [start1 [end1 [start2 [end2]]]] + Return '#f' if S1 and S2 are not equal, a true value otherwise. + The character comparison is done case-insensitively. + + string-ci<> + -- Scheme Procedure: string-ci<> s1 s2 [start1 [end1 [start2 [end2]]]] + Return '#f' if S1 and S2 are equal, a true value otherwise. The + character comparison is done case-insensitively. + + string-ci< + -- Scheme Procedure: string-ci< s1 s2 [start1 [end1 [start2 [end2]]]] + Return '#f' if S1 is greater or equal to S2, a true value + otherwise. The character comparison is done case-insensitively. + + string-ci> + -- Scheme Procedure: string-ci> s1 s2 [start1 [end1 [start2 [end2]]]] + Return '#f' if S1 is less or equal to S2, a true value otherwise. + The character comparison is done case-insensitively. + + string-ci<= + -- Scheme Procedure: string-ci<= s1 s2 [start1 [end1 [start2 [end2]]]] + Return '#f' if S1 is greater to S2, a true value otherwise. The + character comparison is done case-insensitively. + + string-ci>= + -- Scheme Procedure: string-ci>= s1 s2 [start1 [end1 [start2 [end2]]]] + Return '#f' if S1 is less to S2, a true value otherwise. The + character comparison is done case-insensitively. + + string-hash + -- Scheme Procedure: string-hash s [bound [start [end]]] + Compute a hash value for S. the optional argument BOUND is a + non-negative exact integer specifying the range of the hash + function. A positive value restricts the return value to the range + [0,bound). + + string-hash-ci + -- Scheme Procedure: string-hash-ci s [bound [start [end]]] + Compute a hash value for S. the optional argument BOUND is a + non-negative exact integer specifying the range of the hash + function. A positive value restricts the return value to the range + [0,bound). + + string-prefix-length + -- Scheme Procedure: string-prefix-length s1 s2 [start1 [end1 [start2 + [end2]]]] + Return the length of the longest common prefix of the two strings. + + string-prefix-length-ci + -- Scheme Procedure: string-prefix-length-ci s1 s2 [start1 [end1 + [start2 [end2]]]] + Return the length of the longest common prefix of the two strings, + ignoring character case. + + string-suffix-length + -- Scheme Procedure: string-suffix-length s1 s2 [start1 [end1 [start2 + [end2]]]] + Return the length of the longest common suffix of the two strings. + + string-suffix-length-ci + -- Scheme Procedure: string-suffix-length-ci s1 s2 [start1 [end1 + [start2 [end2]]]] + Return the length of the longest common suffix of the two strings, + ignoring character case. + + string-prefix? + -- Scheme Procedure: string-prefix? s1 s2 [start1 [end1 [start2 + [end2]]]] + Is S1 a prefix of S2? + + string-prefix-ci? + -- Scheme Procedure: string-prefix-ci? s1 s2 [start1 [end1 [start2 + [end2]]]] + Is S1 a prefix of S2, ignoring character case? + + string-suffix? + -- Scheme Procedure: string-suffix? s1 s2 [start1 [end1 [start2 + [end2]]]] + Is S1 a suffix of S2? + + string-suffix-ci? + -- Scheme Procedure: string-suffix-ci? s1 s2 [start1 [end1 [start2 + [end2]]]] + Is S1 a suffix of S2, ignoring character case? + + string-index + -- Scheme Procedure: string-index s char_pred [start [end]] + Search through the string S from left to right, returning the index + of the first occurence of a character which + + * equals CHAR_PRED, if it is character, + + * satisifies the predicate CHAR_PRED, if it is a procedure, + + * is in the set CHAR_PRED, if it is a character set. + + string-index-right + -- Scheme Procedure: string-index-right s char_pred [start [end]] + Search through the string S from right to left, returning the index + of the last occurence of a character which + + * equals CHAR_PRED, if it is character, + + * satisifies the predicate CHAR_PRED, if it is a procedure, + + * is in the set if CHAR_PRED is a character set. + + string-rindex + -- Scheme Procedure: string-rindex s char_pred [start [end]] + Search through the string S from right to left, returning the index + of the last occurence of a character which + + * equals CHAR_PRED, if it is character, + + * satisifies the predicate CHAR_PRED, if it is a procedure, + + * is in the set if CHAR_PRED is a character set. + + string-skip + -- Scheme Procedure: string-skip s char_pred [start [end]] + Search through the string S from left to right, returning the index + of the first occurence of a character which + + * does not equal CHAR_PRED, if it is character, + + * does not satisify the predicate CHAR_PRED, if it is a + procedure, + + * is not in the set if CHAR_PRED is a character set. + + string-skip-right + -- Scheme Procedure: string-skip-right s char_pred [start [end]] + Search through the string S from right to left, returning the index + of the last occurence of a character which + + * does not equal CHAR_PRED, if it is character, + + * does not satisfy the predicate CHAR_PRED, if it is a + procedure, + + * is not in the set if CHAR_PRED is a character set. + + string-count + -- Scheme Procedure: string-count s char_pred [start [end]] + Return the count of the number of characters in the string S which + + * equals CHAR_PRED, if it is character, + + * satisifies the predicate CHAR_PRED, if it is a procedure. + + * is in the set CHAR_PRED, if it is a character set. + + string-contains + -- Scheme Procedure: string-contains s1 s2 [start1 [end1 [start2 + [end2]]]] + Does string S1 contain string S2? Return the index in S1 where S2 + occurs as a substring, or false. The optional start/end indices + restrict the operation to the indicated substrings. + + string-contains-ci + -- Scheme Procedure: string-contains-ci s1 s2 [start1 [end1 [start2 + [end2]]]] + Does string S1 contain string S2? Return the index in S1 where S2 + occurs as a substring, or false. The optional start/end indices + restrict the operation to the indicated substrings. Character + comparison is done case-insensitively. + + string-upcase! + -- Scheme Procedure: string-upcase! str [start [end]] + Destructively upcase every character in 'str'. + + (string-upcase! y) + => "ARRDEFG" + y + => "ARRDEFG" + + string-upcase + -- Scheme Procedure: string-upcase str [start [end]] + Upcase every character in 'str'. + + string-downcase! + -- Scheme Procedure: string-downcase! str [start [end]] + Destructively downcase every character in STR. + + y + => "ARRDEFG" + (string-downcase! y) + => "arrdefg" + y + => "arrdefg" + + string-downcase + -- Scheme Procedure: string-downcase str [start [end]] + Downcase every character in STR. + + string-titlecase! + -- Scheme Procedure: string-titlecase! str [start [end]] + Destructively titlecase every first character in a word in STR. + + string-titlecase + -- Scheme Procedure: string-titlecase str [start [end]] + Titlecase every first character in a word in STR. + + string-capitalize! + -- Scheme Procedure: string-capitalize! str + Upcase the first character of every word in STR destructively and + return STR. + + y => "hello world" + (string-capitalize! y) => "Hello World" + y => "Hello World" + + string-capitalize + -- Scheme Procedure: string-capitalize str + Return a freshly allocated string with the characters in STR, where + the first character of every word is capitalized. + + string-reverse + -- Scheme Procedure: string-reverse str [start [end]] + Reverse the string STR. The optional arguments START and END + delimit the region of STR to operate on. + + string-reverse! + -- Scheme Procedure: string-reverse! str [start [end]] + Reverse the string STR in-place. The optional arguments START and + END delimit the region of STR to operate on. The return value is + unspecified. + + string-append/shared + -- Scheme Procedure: string-append/shared . rest + Like 'string-append', but the result may share memory with the + argument strings. + + string-concatenate + -- Scheme Procedure: string-concatenate ls + Append the elements of LS (which must be strings) together into a + single string. Guaranteed to return a freshly allocated string. + + string-concatenate-reverse + -- Scheme Procedure: string-concatenate-reverse ls [final_string [end]] + Without optional arguments, this procedure is equivalent to + + (string-concatenate (reverse ls)) + + If the optional argument FINAL_STRING is specified, it is consed + onto the beginning to LS before performing the list-reverse and + string-concatenate operations. If END is given, only the + characters of FINAL_STRING up to index END are used. + + Guaranteed to return a freshly allocated string. + + string-concatenate/shared + -- Scheme Procedure: string-concatenate/shared ls + Like 'string-concatenate', but the result may share memory with the + strings in the list LS. + + string-concatenate-reverse/shared + -- Scheme Procedure: string-concatenate-reverse/shared ls [final_string + [end]] + Like 'string-concatenate-reverse', but the result may share memory + with the the strings in the LS arguments. + + string-map + -- Scheme Procedure: string-map proc s [start [end]] + PROC is a char->char procedure, it is mapped over S. The order in + which the procedure is applied to the string elements is not + specified. + + string-map! + -- Scheme Procedure: string-map! proc s [start [end]] + PROC is a char->char procedure, it is mapped over S. The order in + which the procedure is applied to the string elements is not + specified. The string S is modified in-place, the return value is + not specified. + + string-fold + -- Scheme Procedure: string-fold kons knil s [start [end]] + Fold KONS over the characters of S, with KNIL as the terminating + element, from left to right. KONS must expect two arguments: The + actual character and the last result of KONS' application. + + string-fold-right + -- Scheme Procedure: string-fold-right kons knil s [start [end]] + Fold KONS over the characters of S, with KNIL as the terminating + element, from right to left. KONS must expect two arguments: The + actual character and the last result of KONS' application. + + string-unfold + -- Scheme Procedure: string-unfold p f g seed [base [make_final]] + * G is used to generate a series of _seed_ values from the + initial SEED: SEED, (G SEED), (G^2 SEED), (G^3 SEED), ... + * P tells us when to stop - when it returns true when applied to + one of these seed values. + * F maps each seed value to the corresponding character in the + result string. These chars are assembled into the string in a + left-to-right order. + * BASE is the optional initial/leftmost portion of the + constructed string; it default to the empty string. + * MAKE_FINAL is applied to the terminal seed value (on which P + returns true) to produce the final/rightmost portion of the + constructed string. It defaults to '(lambda (x) )'. + + string-unfold-right + -- Scheme Procedure: string-unfold-right p f g seed [base [make_final]] + * G is used to generate a series of _seed_ values from the + initial SEED: SEED, (G SEED), (G^2 SEED), (G^3 SEED), ... + * P tells us when to stop - when it returns true when applied to + one of these seed values. + * F maps each seed value to the corresponding character in the + result string. These chars are assembled into the string in a + right-to-left order. + * BASE is the optional initial/rightmost portion of the + constructed string; it default to the empty string. + * MAKE_FINAL is applied to the terminal seed value (on which P + returns true) to produce the final/leftmost portion of the + constructed string. It defaults to '(lambda (x) )'. + + string-for-each + -- Scheme Procedure: string-for-each proc s [start [end]] + PROC is mapped over S in left-to-right order. The return value is + not specified. + + string-for-each-index + -- Scheme Procedure: string-for-each-index proc s [start [end]] + Call '(PROC i)' for each index i in S, from left to right. + + For example, to change characters to alternately upper and lower + case, + + (define str (string-copy "studly")) + (string-for-each-index + (lambda (i) + (string-set! str i + ((if (even? i) char-upcase char-downcase) + (string-ref str i)))) + str) + str => "StUdLy" + + xsubstring + -- Scheme Procedure: xsubstring s from [to [start [end]]] + This is the _extended substring_ procedure that implements + replicated copying of a substring of some string. + + S is a string, START and END are optional arguments that demarcate + a substring of S, defaulting to 0 and the length of S. Replicate + this substring up and down index space, in both the positive and + negative directions. 'xsubstring' returns the substring of this + string beginning at index FROM, and ending at TO, which defaults to + FROM + (END - START). + + string-xcopy! + -- Scheme Procedure: string-xcopy! target tstart s sfrom [sto [start + [end]]] + Exactly the same as 'xsubstring', but the extracted text is written + into the string TARGET starting at index TSTART. The operation is + not defined if '(eq? TARGET S)' or these arguments share storage - + you cannot copy a string on top of itself. + + string-replace + -- Scheme Procedure: string-replace s1 s2 [start1 [end1 [start2 + [end2]]]] + Return the string S1, but with the characters START1 ... END1 + replaced by the characters START2 ... END2 from S2. + + string-tokenize + -- Scheme Procedure: string-tokenize s [token_set [start [end]]] + Split the string S into a list of substrings, where each substring + is a maximal non-empty contiguous sequence of characters from the + character set TOKEN_SET, which defaults to 'char-set:graphic'. If + START or END indices are provided, they restrict 'string-tokenize' + to operating on the indicated substring of S. + + string-split + -- Scheme Procedure: string-split str chr + Split the string STR into the a list of the substrings delimited by + appearances of the character CHR. Note that an empty substring + between separator characters will result in an empty string in the + result list. + + (string-split "root:x:0:0:root:/root:/bin/bash" #\:) + => + ("root" "x" "0" "0" "root" "/root" "/bin/bash") + + (string-split "::" #\:) + => + ("" "" "") + + (string-split "" #\:) + => + ("") + + string-filter + -- Scheme Procedure: string-filter s char_pred [start [end]] + Filter the string S, retaining only those characters which satisfy + CHAR_PRED. + + If CHAR_PRED is a procedure, it is applied to each character as a + predicate, if it is a character, it is tested for equality and if + it is a character set, it is tested for membership. + + string-delete + -- Scheme Procedure: string-delete s char_pred [start [end]] + Delete characters satisfying CHAR_PRED from S. + + If CHAR_PRED is a procedure, it is applied to each character as a + predicate, if it is a character, it is tested for equality and if + it is a character set, it is tested for membership. + + char-set? + -- Scheme Procedure: char-set? obj + Return '#t' if OBJ is a character set, '#f' otherwise. + + char-set= + -- Scheme Procedure: char-set= . char_sets + Return '#t' if all given character sets are equal. + + char-set<= + -- Scheme Procedure: char-set<= . char_sets + Return '#t' if every character set CSi is a subset of character set + CSi+1. + + char-set-hash + -- Scheme Procedure: char-set-hash cs [bound] + Compute a hash value for the character set CS. If BOUND is given + and non-zero, it restricts the returned value to the range 0 ... + BOUND - 1. + + char-set-cursor + -- Scheme Procedure: char-set-cursor cs + Return a cursor into the character set CS. + + char-set-ref + -- Scheme Procedure: char-set-ref cs cursor + Return the character at the current cursor position CURSOR in the + character set CS. It is an error to pass a cursor for which + 'end-of-char-set?' returns true. + + char-set-cursor-next + -- Scheme Procedure: char-set-cursor-next cs cursor + Advance the character set cursor CURSOR to the next character in + the character set CS. It is an error if the cursor given satisfies + 'end-of-char-set?'. + + end-of-char-set? + -- Scheme Procedure: end-of-char-set? cursor + Return '#t' if CURSOR has reached the end of a character set, '#f' + otherwise. + + char-set-fold + -- Scheme Procedure: char-set-fold kons knil cs + Fold the procedure KONS over the character set CS, initializing it + with KNIL. + + char-set-unfold + -- Scheme Procedure: char-set-unfold p f g seed [base_cs] + This is a fundamental constructor for character sets. + * G is used to generate a series of "seed" values from the + initial seed: SEED, (G SEED), (G^2 SEED), (G^3 SEED), ... + * P tells us when to stop - when it returns true when applied to + one of the seed values. + * F maps each seed value to a character. These characters are + added to the base character set BASE_CS to form the result; + BASE_CS defaults to the empty set. + + char-set-unfold! + -- Scheme Procedure: char-set-unfold! p f g seed base_cs + This is a fundamental constructor for character sets. + * G is used to generate a series of "seed" values from the + initial seed: SEED, (G SEED), (G^2 SEED), (G^3 SEED), ... + * P tells us when to stop - when it returns true when applied to + one of the seed values. + * F maps each seed value to a character. These characters are + added to the base character set BASE_CS to form the result; + BASE_CS defaults to the empty set. + + char-set-for-each + -- Scheme Procedure: char-set-for-each proc cs + Apply PROC to every character in the character set CS. The return + value is not specified. + + char-set-map + -- Scheme Procedure: char-set-map proc cs + Map the procedure PROC over every character in CS. PROC must be a + character -> character procedure. + + char-set-copy + -- Scheme Procedure: char-set-copy cs + Return a newly allocated character set containing all characters in + CS. + + char-set + -- Scheme Procedure: char-set . rest + Return a character set containing all given characters. + + list->char-set + -- Scheme Procedure: list->char-set list [base_cs] + Convert the character list LIST to a character set. If the + character set BASE_CS is given, the character in this set are also + included in the result. + + list->char-set! + -- Scheme Procedure: list->char-set! list base_cs + Convert the character list LIST to a character set. The characters + are added to BASE_CS and BASE_CS is returned. + + string->char-set + -- Scheme Procedure: string->char-set str [base_cs] + Convert the string STR to a character set. If the character set + BASE_CS is given, the characters in this set are also included in + the result. + + string->char-set! + -- Scheme Procedure: string->char-set! str base_cs + Convert the string STR to a character set. The characters from the + string are added to BASE_CS, and BASE_CS is returned. + + char-set-filter + -- Scheme Procedure: char-set-filter pred cs [base_cs] + Return a character set containing every character from CS so that + it satisfies PRED. If provided, the characters from BASE_CS are + added to the result. + + char-set-filter! + -- Scheme Procedure: char-set-filter! pred cs base_cs + Return a character set containing every character from CS so that + it satisfies PRED. The characters are added to BASE_CS and BASE_CS + is returned. + + ucs-range->char-set + -- Scheme Procedure: ucs-range->char-set lower upper [error [base_cs]] + Return a character set containing all characters whose character + codes lie in the half-open range [LOWER,UPPER). + + If ERROR is a true value, an error is signalled if the specified + range contains characters which are not contained in the + implemented character range. If ERROR is '#f', these characters + are silently left out of the resultung character set. + + The characters in BASE_CS are added to the result, if given. + + ucs-range->char-set! + -- Scheme Procedure: ucs-range->char-set! lower upper error base_cs + Return a character set containing all characters whose character + codes lie in the half-open range [LOWER,UPPER). + + If ERROR is a true value, an error is signalled if the specified + range contains characters which are not contained in the + implemented character range. If ERROR is '#f', these characters + are silently left out of the resultung character set. + + The characters are added to BASE_CS and BASE_CS is returned. + + ->char-set + -- Scheme Procedure: ->char-set x + Coerces x into a char-set. X may be a string, character or + char-set. A string is converted to the set of its constituent + characters; a character is converted to a singleton set; a char-set + is returned as-is. + + char-set-size + -- Scheme Procedure: char-set-size cs + Return the number of elements in character set CS. + + char-set-count + -- Scheme Procedure: char-set-count pred cs + Return the number of the elements int the character set CS which + satisfy the predicate PRED. + + char-set->list + -- Scheme Procedure: char-set->list cs + Return a list containing the elements of the character set CS. + + char-set->string + -- Scheme Procedure: char-set->string cs + Return a string containing the elements of the character set CS. + The order in which the characters are placed in the string is not + defined. + + char-set-contains? + -- Scheme Procedure: char-set-contains? cs ch + Return '#t' iff the character CH is contained in the character set + CS. + + char-set-every + -- Scheme Procedure: char-set-every pred cs + Return a true value if every character in the character set CS + satisfies the predicate PRED. + + char-set-any + -- Scheme Procedure: char-set-any pred cs + Return a true value if any character in the character set CS + satisfies the predicate PRED. + + char-set-adjoin + -- Scheme Procedure: char-set-adjoin cs . rest + Add all character arguments to the first argument, which must be a + character set. + + char-set-delete + -- Scheme Procedure: char-set-delete cs . rest + Delete all character arguments from the first argument, which must + be a character set. + + char-set-adjoin! + -- Scheme Procedure: char-set-adjoin! cs . rest + Add all character arguments to the first argument, which must be a + character set. + + char-set-delete! + -- Scheme Procedure: char-set-delete! cs . rest + Delete all character arguments from the first argument, which must + be a character set. + + char-set-complement + -- Scheme Procedure: char-set-complement cs + Return the complement of the character set CS. + + char-set-union + -- Scheme Procedure: char-set-union . rest + Return the union of all argument character sets. + + char-set-intersection + -- Scheme Procedure: char-set-intersection . rest + Return the intersection of all argument character sets. + + char-set-difference + -- Scheme Procedure: char-set-difference cs1 . rest + Return the difference of all argument character sets. + + char-set-xor + -- Scheme Procedure: char-set-xor . rest + Return the exclusive-or of all argument character sets. + + char-set-diff+intersection + -- Scheme Procedure: char-set-diff+intersection cs1 . rest + Return the difference and the intersection of all argument + character sets. + + char-set-complement! + -- Scheme Procedure: char-set-complement! cs + Return the complement of the character set CS. + + char-set-union! + -- Scheme Procedure: char-set-union! cs1 . rest + Return the union of all argument character sets. + + char-set-intersection! + -- Scheme Procedure: char-set-intersection! cs1 . rest + Return the intersection of all argument character sets. + + char-set-difference! + -- Scheme Procedure: char-set-difference! cs1 . rest + Return the difference of all argument character sets. + + char-set-xor! + -- Scheme Procedure: char-set-xor! cs1 . rest + Return the exclusive-or of all argument character sets. + + char-set-diff+intersection! + -- Scheme Procedure: char-set-diff+intersection! cs1 cs2 . rest + Return the difference and the intersection of all argument + character sets. + + string=? + -- Scheme Procedure: string=? s1 s2 + Lexicographic equality predicate; return '#t' if the two strings + are the same length and contain the same characters in the same + positions, otherwise return '#f'. + + The procedure 'string-ci=?' treats upper and lower case letters as + though they were the same character, but 'string=?' treats upper + and lower case as distinct characters. + + string-ci=? + -- Scheme Procedure: string-ci=? s1 s2 + Case-insensitive string equality predicate; return '#t' if the two + strings are the same length and their component characters match + (ignoring case) at each position; otherwise return '#f'. + + string? + -- Scheme Procedure: string>? s1 s2 + Lexicographic ordering predicate; return '#t' if S1 is + lexicographically greater than S2. + + string>=? + -- Scheme Procedure: string>=? s1 s2 + Lexicographic ordering predicate; return '#t' if S1 is + lexicographically greater than or equal to S2. + + string-ci? + -- Scheme Procedure: string-ci>? s1 s2 + Case insensitive lexicographic ordering predicate; return '#t' if + S1 is lexicographically greater than S2 regardless of case. + + string-ci>=? + -- Scheme Procedure: string-ci>=? s1 s2 + Case insensitive lexicographic ordering predicate; return '#t' if + S1 is lexicographically greater than or equal to S2 regardless of + case. + + object->string + -- Scheme Procedure: object->string obj [printer] + Return a Scheme string obtained by printing OBJ. Printing function + can be specified by the optional second argument PRINTER (default: + 'write'). + + call-with-output-string + -- Scheme Procedure: call-with-output-string proc + Calls the one-argument procedure PROC with a newly created output + port. When the function returns, the string composed of the + characters written into the port is returned. + + call-with-input-string + -- Scheme Procedure: call-with-input-string string proc + Calls the one-argument procedure PROC with a newly created input + port from which STRING's contents may be read. The value yielded + by the PROC is returned. + + open-input-string + -- Scheme Procedure: open-input-string str + Take a string and return an input port that delivers characters + from the string. The port can be closed by 'close-input-port', + though its storage will be reclaimed by the garbage collector if it + becomes inaccessible. + + open-output-string + -- Scheme Procedure: open-output-string + Return an output port that will accumulate characters for retrieval + by 'get-output-string'. The port can be closed by the procedure + 'close-output-port', though its storage will be reclaimed by the + garbage collector if it becomes inaccessible. + + get-output-string + -- Scheme Procedure: get-output-string port + Given an output port created by 'open-output-string', return a + string consisting of the characters that have been output to the + port so far. + + eval-string + -- Scheme Procedure: eval-string string [module] + Evaluate STRING as the text representation of a Scheme form or + forms, and return whatever value they produce. Evaluation takes + place in the given module, or the current module when no module is + given. While the code is evaluated, the given module is made the + current one. The current module is restored when this procedure + returns. + + make-struct-layout + -- Scheme Procedure: make-struct-layout fields + Return a new structure layout object. + + FIELDS must be a string made up of pairs of characters strung + together. The first character of each pair describes a field type, + the second a field protection. Allowed types are 'p' for + GC-protected Scheme data, 'u' for unprotected binary data, and 's' + for a field that points to the structure itself. Allowed + protections are 'w' for mutable fields, 'r' for read-only fields, + and 'o' for opaque fields. The last field protection specification + may be capitalized to indicate that the field is a tail-array. + + struct? + -- Scheme Procedure: struct? x + Return '#t' iff X is a structure object, else '#f'. + + struct-vtable? + -- Scheme Procedure: struct-vtable? x + Return '#t' iff X is a vtable structure. + + make-struct + -- Scheme Procedure: make-struct vtable tail_array_size . init + Create a new structure. + + TYPE must be a vtable structure (*note Vtables::). + + TAIL-ELTS must be a non-negative integer. If the layout + specification indicated by TYPE includes a tail-array, this is the + number of elements allocated to that array. + + The INIT1, ... are optional arguments describing how successive + fields of the structure should be initialized. Only fields with + protection 'r' or 'w' can be initialized, except for fields of type + 's', which are automatically initialized to point to the new + structure itself; fields with protection 'o' can not be initialized + by Scheme programs. + + If fewer optional arguments than initializable fields are supplied, + fields of type 'p' get default value #f while fields of type 'u' + are initialized to 0. + + Structs are currently the basic representation for record-like data + structures in Guile. The plan is to eventually replace them with a + new representation which will at the same time be easier to use and + more powerful. + + For more information, see the documentation for + 'make-vtable-vtable'. + + make-vtable-vtable + -- Scheme Procedure: make-vtable-vtable user_fields tail_array_size . + init + Return a new, self-describing vtable structure. + + USER-FIELDS is a string describing user defined fields of the + vtable beginning at index 'vtable-offset-user' (see + 'make-struct-layout'). + + TAIL-SIZE specifies the size of the tail-array (if any) of this + vtable. + + INIT1, ... are the optional initializers for the fields of the + vtable. + + Vtables have one initializable system field--the struct printer. + This field comes before the user fields in the initializers passed + to 'make-vtable-vtable' and 'make-struct', and thus works as a + third optional argument to 'make-vtable-vtable' and a fourth to + 'make-struct' when creating vtables: + + If the value is a procedure, it will be called instead of the + standard printer whenever a struct described by this vtable is + printed. The procedure will be called with arguments STRUCT and + PORT. + + The structure of a struct is described by a vtable, so the vtable + is in essence the type of the struct. The vtable is itself a + struct with a vtable. This could go on forever if it weren't for + the vtable-vtables which are self-describing vtables, and thus + terminate the chain. + + There are several potential ways of using structs, but the standard + one is to use three kinds of structs, together building up a type + sub-system: one vtable-vtable working as the root and one or + several "types", each with a set of "instances". (The + vtable-vtable should be compared to the class which is the + class of itself.) + + (define ball-root (make-vtable-vtable "pr" 0)) + + (define (make-ball-type ball-color) + (make-struct ball-root 0 + (make-struct-layout "pw") + (lambda (ball port) + (format port "#" + (color ball) + (owner ball))) + ball-color)) + (define (color ball) (struct-ref (struct-vtable ball) vtable-offset-user)) + (define (owner ball) (struct-ref ball 0)) + + (define red (make-ball-type 'red)) + (define green (make-ball-type 'green)) + + (define (make-ball type owner) (make-struct type 0 owner)) + + (define ball (make-ball green 'Nisse)) + ball => # + + make-vtable + -- Scheme Procedure: make-vtable fields [printer] + Create a vtable, for creating structures with the given FIELDS. + + The optional PRINTER argument is a function to be called '(PRINTER + struct port)' on the structures created. It should look at STRUCT + and write to PORT. + + struct-ref + -- Scheme Procedure: struct-ref handle pos + -- Scheme Procedure: struct-set! struct n value + Access (or modify) the Nth field of STRUCT. + + If the field is of type 'p', then it can be set to an arbitrary + value. + + If the field is of type 'u', then it can only be set to a + non-negative integer value small enough to fit in one machine word. + + struct-set! + -- Scheme Procedure: struct-set! handle pos val + Set the slot of the structure HANDLE with index POS to VAL. Signal + an error if the slot can not be written to. + + struct-vtable + -- Scheme Procedure: struct-vtable handle + Return the vtable structure that describes the type of STRUCT. + + struct-vtable-tag + -- Scheme Procedure: struct-vtable-tag handle + Return the vtable tag of the structure HANDLE. + + struct-vtable-name + -- Scheme Procedure: struct-vtable-name vtable + Return the name of the vtable VTABLE. + + set-struct-vtable-name! + -- Scheme Procedure: set-struct-vtable-name! vtable name + Set the name of the vtable VTABLE to NAME. + + symbol? + -- Scheme Procedure: symbol? obj + Return '#t' if OBJ is a symbol, otherwise return '#f'. + + symbol-interned? + -- Scheme Procedure: symbol-interned? symbol + Return '#t' if SYMBOL is interned, otherwise return '#f'. + + make-symbol + -- Scheme Procedure: make-symbol name + Return a new uninterned symbol with the name NAME. The returned + symbol is guaranteed to be unique and future calls to + 'string->symbol' will not return it. + + symbol->string + -- Scheme Procedure: symbol->string s + Return the name of SYMBOL as a string. If the symbol was part of + an object returned as the value of a literal expression (section + *note (r5rs)Literal expressions::) or by a call to the 'read' + procedure, and its name contains alphabetic characters, then the + string returned will contain characters in the implementation's + preferred standard case--some implementations will prefer upper + case, others lower case. If the symbol was returned by + 'string->symbol', the case of characters in the string returned + will be the same as the case in the string that was passed to + 'string->symbol'. It is an error to apply mutation procedures like + 'string-set!' to strings returned by this procedure. + + The following examples assume that the implementation's standard + case is lower case: + + (symbol->string 'flying-fish) => "flying-fish" + (symbol->string 'Martin) => "martin" + (symbol->string + (string->symbol "Malvina")) => "Malvina" + + string->symbol + -- Scheme Procedure: string->symbol string + Return the symbol whose name is STRING. This procedure can create + symbols with names containing special characters or letters in the + non-standard case, but it is usually a bad idea to create such + symbols because in some implementations of Scheme they cannot be + read as themselves. See 'symbol->string'. + + The following examples assume that the implementation's standard + case is lower case: + + (eq? 'mISSISSIppi 'mississippi) => #t + (string->symbol "mISSISSIppi") => the symbol with name "mISSISSIppi" + (eq? 'bitBlt (string->symbol "bitBlt")) => #f + (eq? 'JollyWog + (string->symbol (symbol->string 'JollyWog))) => #t + (string=? "K. Harper, M.D." + (symbol->string + (string->symbol "K. Harper, M.D."))) =>#t + + string-ci->symbol + -- Scheme Procedure: string-ci->symbol str + Return the symbol whose name is STR. STR is converted to lowercase + before the conversion is done, if Guile is currently reading + symbols case-insensitively. + + gensym + -- Scheme Procedure: gensym [prefix] + Create a new symbol with a name constructed from a prefix and a + counter value. The string PREFIX can be specified as an optional + argument. Default prefix is ' g'. The counter is increased by 1 + at each call. There is no provision for resetting the counter. + + symbol-hash + -- Scheme Procedure: symbol-hash symbol + Return a hash value for SYMBOL. + + symbol-fref + -- Scheme Procedure: symbol-fref s + Return the contents of SYMBOL's "function slot". + + symbol-pref + -- Scheme Procedure: symbol-pref s + Return the "property list" currently associated with SYMBOL. + + symbol-fset! + -- Scheme Procedure: symbol-fset! s val + Change the binding of SYMBOL's function slot. + + symbol-pset! + -- Scheme Procedure: symbol-pset! s val + Change the binding of SYMBOL's property slot. + + call-with-new-thread + -- Scheme Procedure: call-with-new-thread thunk [handler] + Call 'thunk' in a new thread and with a new dynamic state, + returning a new thread object representing the thread. The + procedure THUNK is called via 'with-continuation-barrier'. + + When HANDLER is specified, then THUNK is called from within a + 'catch' with tag '#t' that has HANDLER as its handler. This catch + is established inside the continuation barrier. + + Once THUNK or HANDLER returns, the return value is made the _exit + value_ of the thread and the thread is terminated. + + yield + -- Scheme Procedure: yield + Move the calling thread to the end of the scheduling queue. + + join-thread + -- Scheme Procedure: join-thread thread + Suspend execution of the calling thread until the target THREAD + terminates, unless the target THREAD has already terminated. + + make-mutex + -- Scheme Procedure: make-mutex + Create a new mutex. + + make-recursive-mutex + -- Scheme Procedure: make-recursive-mutex + Create a new recursive mutex. + + lock-mutex + -- Scheme Procedure: lock-mutex mx + Lock MUTEX. If the mutex is already locked, the calling thread + blocks until the mutex becomes available. The function returns + when the calling thread owns the lock on MUTEX. Locking a mutex + that a thread already owns will succeed right away and will not + block the thread. That is, Guile's mutexes are _recursive_. + + try-mutex + -- Scheme Procedure: try-mutex mutex + Try to lock MUTEX. If the mutex is already locked by someone else, + return '#f'. Else lock the mutex and return '#t'. + + unlock-mutex + -- Scheme Procedure: unlock-mutex mx + Unlocks MUTEX if the calling thread owns the lock on MUTEX. + Calling unlock-mutex on a mutex not owned by the current thread + results in undefined behaviour. Once a mutex has been unlocked, + one thread blocked on MUTEX is awakened and grabs the mutex lock. + Every call to 'lock-mutex' by this thread must be matched with a + call to 'unlock-mutex'. Only the last call to 'unlock-mutex' will + actually unlock the mutex. + + make-condition-variable + -- Scheme Procedure: make-condition-variable + Make a new condition variable. + + wait-condition-variable + -- Scheme Procedure: wait-condition-variable cv mx [t] + Wait until COND-VAR has been signalled. While waiting, MUTEX is + atomically unlocked (as with 'unlock-mutex') and is locked again + when this function returns. When TIME is given, it specifies a + point in time where the waiting should be aborted. It can be + either a integer as returned by 'current-time' or a pair as + returned by 'gettimeofday'. When the waiting is aborted the mutex + is locked and '#f' is returned. When the condition variable is in + fact signalled, the mutex is also locked and '#t' is returned. + + signal-condition-variable + -- Scheme Procedure: signal-condition-variable cv + Wake up one thread that is waiting for CV + + broadcast-condition-variable + -- Scheme Procedure: broadcast-condition-variable cv + Wake up all threads that are waiting for CV. + + current-thread + -- Scheme Procedure: current-thread + Return the thread that called this function. + + all-threads + -- Scheme Procedure: all-threads + Return a list of all threads. + + thread-exited? + -- Scheme Procedure: thread-exited? thread + Return '#t' iff THREAD has exited. + + catch + -- Scheme Procedure: catch key thunk handler [pre_unwind_handler] + Invoke THUNK in the dynamic context of HANDLER for exceptions + matching KEY. If thunk throws to the symbol KEY, then HANDLER is + invoked this way: + (handler key args ...) + + KEY is a symbol or '#t'. + + THUNK takes no arguments. If THUNK returns normally, that is the + return value of 'catch'. + + Handler is invoked outside the scope of its own 'catch'. If + HANDLER again throws to the same key, a new handler from further up + the call chain is invoked. + + If the key is '#t', then a throw to _any_ symbol will match this + call to 'catch'. + + If a PRE-UNWIND-HANDLER is given and THUNK throws an exception that + matches KEY, Guile calls the PRE-UNWIND-HANDLER before unwinding + the dynamic state and invoking the main HANDLER. + PRE-UNWIND-HANDLER should be a procedure with the same signature as + HANDLER, that is '(lambda (key . args))'. It is typically used to + save the stack at the point where the exception occurred, but can + also query other parts of the dynamic state at that point, such as + fluid values. + + A PRE-UNWIND-HANDLER can exit either normally or non-locally. If + it exits normally, Guile unwinds the stack and dynamic context and + then calls the normal (third argument) handler. If it exits + non-locally, that exit determines the continuation. + + with-throw-handler + -- Scheme Procedure: with-throw-handler key thunk handler + Add HANDLER to the dynamic context as a throw handler for key KEY, + then invoke THUNK. + + lazy-catch + -- Scheme Procedure: lazy-catch key thunk handler + This behaves exactly like 'catch', except that it does not unwind + the stack before invoking HANDLER. If the HANDLER procedure + returns normally, Guile rethrows the same exception again to the + next innermost catch, lazy-catch or throw handler. If the HANDLER + exits non-locally, that exit determines the continuation. + + throw + -- Scheme Procedure: throw key . args + Invoke the catch form matching KEY, passing ARGS to the HANDLER. + + KEY is a symbol. It will match catches of the same symbol or of + '#t'. + + If there is no handler at all, Guile prints an error and then + exits. + + values + -- Scheme Procedure: values . args + Delivers all of its arguments to its continuation. Except for + continuations created by the 'call-with-values' procedure, all + continuations take exactly one value. The effect of passing no + value or more than one value to continuations that were not created + by 'call-with-values' is unspecified. + + make-variable + -- Scheme Procedure: make-variable init + Return a variable initialized to value INIT. + + make-undefined-variable + -- Scheme Procedure: make-undefined-variable + Return a variable that is initially unbound. + + variable? + -- Scheme Procedure: variable? obj + Return '#t' iff OBJ is a variable object, else return '#f'. + + variable-ref + -- Scheme Procedure: variable-ref var + Dereference VAR and return its value. VAR must be a variable + object; see 'make-variable' and 'make-undefined-variable'. + + variable-set! + -- Scheme Procedure: variable-set! var val + Set the value of the variable VAR to VAL. VAR must be a variable + object, VAL can be any value. Return an unspecified value. + + variable-bound? + -- Scheme Procedure: variable-bound? var + Return '#t' iff VAR is bound to a value. Throws an error if VAR is + not a variable object. + + vector? + -- Scheme Procedure: vector? obj + Return '#t' if OBJ is a vector, otherwise return '#f'. + + list->vector + -- Scheme Procedure: list->vector + implemented by the C function "scm_vector" + + vector + -- Scheme Procedure: vector . l + -- Scheme Procedure: list->vector l + Return a newly allocated vector composed of the given arguments. + Analogous to 'list'. + + (vector 'a 'b 'c) => #(a b c) + + make-vector + -- Scheme Procedure: make-vector k [fill] + Return a newly allocated vector of K elements. If a second + argument is given, then each position is initialized to FILL. + Otherwise the initial contents of each position is unspecified. + + vector-copy + -- Scheme Procedure: vector-copy vec + Return a copy of VEC. + + vector->list + -- Scheme Procedure: vector->list v + Return a newly allocated list composed of the elements of V. + + (vector->list '#(dah dah didah)) => (dah dah didah) + (list->vector '(dididit dah)) => #(dididit dah) + + vector-fill! + -- Scheme Procedure: vector-fill! v fill + Store FILL in every position of VECTOR. The value returned by + 'vector-fill!' is unspecified. + + vector-move-left! + -- Scheme Procedure: vector-move-left! vec1 start1 end1 vec2 start2 + Copy elements from VEC1, positions START1 to END1, to VEC2 starting + at position START2. START1 and START2 are inclusive indices; END1 + is exclusive. + + 'vector-move-left!' copies elements in leftmost order. Therefore, + in the case where VEC1 and VEC2 refer to the same vector, + 'vector-move-left!' is usually appropriate when START1 is greater + than START2. + + vector-move-right! + -- Scheme Procedure: vector-move-right! vec1 start1 end1 vec2 start2 + Copy elements from VEC1, positions START1 to END1, to VEC2 starting + at position START2. START1 and START2 are inclusive indices; END1 + is exclusive. + + 'vector-move-right!' copies elements in rightmost order. + Therefore, in the case where VEC1 and VEC2 refer to the same + vector, 'vector-move-right!' is usually appropriate when START1 is + less than START2. + + generalized-vector? + -- Scheme Procedure: generalized-vector? obj + Return '#t' if OBJ is a vector, string, bitvector, or uniform + numeric vector. + + generalized-vector-length + -- Scheme Procedure: generalized-vector-length v + Return the length of the generalized vector V. + + generalized-vector-ref + -- Scheme Procedure: generalized-vector-ref v idx + Return the element at index IDX of the generalized vector V. + + generalized-vector-set! + -- Scheme Procedure: generalized-vector-set! v idx val + Set the element at index IDX of the generalized vector V to VAL. + + generalized-vector->list + -- Scheme Procedure: generalized-vector->list v + Return a new list whose elements are the elements of the + generalized vector V. + + major-version + -- Scheme Procedure: major-version + Return a string containing Guile's major version number. E.g., the + 1 in "1.6.5". + + minor-version + -- Scheme Procedure: minor-version + Return a string containing Guile's minor version number. E.g., the + 6 in "1.6.5". + + micro-version + -- Scheme Procedure: micro-version + Return a string containing Guile's micro version number. E.g., the + 5 in "1.6.5". + + version + -- Scheme Procedure: version + -- Scheme Procedure: major-version + -- Scheme Procedure: minor-version + -- Scheme Procedure: micro-version + Return a string describing Guile's version number, or its major, + minor or micro version number, respectively. + + (version) => "1.6.0" + (major-version) => "1" + (minor-version) => "6" + (micro-version) => "0" + + effective-version + -- Scheme Procedure: effective-version + Return a string describing Guile's effective version number. + (version) => "1.6.0" + (effective-version) => "1.6" + (major-version) => "1" + (minor-version) => "6" + (micro-version) => "0" + + make-soft-port + -- Scheme Procedure: make-soft-port pv modes + Return a port capable of receiving or delivering characters as + specified by the MODES string (*note open-file: File Ports.). PV + must be a vector of length 5 or 6. Its components are as follows: + + 0. procedure accepting one character for output + 1. procedure accepting a string for output + 2. thunk for flushing output + 3. thunk for getting one character + 4. thunk for closing port (not by garbage collection) + 5. (if present and not '#f') thunk for computing the number of + characters that can be read from the port without blocking. + + For an output-only port only elements 0, 1, 2, and 4 need be + procedures. For an input-only port only elements 3 and 4 need be + procedures. Thunks 2 and 4 can instead be '#f' if there is no + useful operation for them to perform. + + If thunk 3 returns '#f' or an 'eof-object' (*note eof-object?: + (r5rs)Input.) it indicates that the port has reached end-of-file. + For example: + + (define stdout (current-output-port)) + (define p (make-soft-port + (vector + (lambda (c) (write c stdout)) + (lambda (s) (display s stdout)) + (lambda () (display "." stdout)) + (lambda () (char-upcase (read-char))) + (lambda () (display "@" stdout))) + "rw")) + + (write p p) => # + + make-weak-vector + -- Scheme Procedure: make-weak-vector size [fill] + Return a weak vector with SIZE elements. If the optional argument + FILL is given, all entries in the vector will be set to FILL. The + default value for FILL is the empty list. + + list->weak-vector + -- Scheme Procedure: list->weak-vector + implemented by the C function "scm_weak_vector" + + weak-vector + -- Scheme Procedure: weak-vector . l + -- Scheme Procedure: list->weak-vector l + Construct a weak vector from a list: 'weak-vector' uses the list of + its arguments while 'list->weak-vector' uses its only argument L (a + list) to construct a weak vector the same way 'list->vector' would. + + weak-vector? + -- Scheme Procedure: weak-vector? obj + Return '#t' if OBJ is a weak vector. Note that all weak hashes are + also weak vectors. + + make-weak-key-alist-vector + -- Scheme Procedure: make-weak-key-alist-vector [size] + -- Scheme Procedure: make-weak-value-alist-vector size + -- Scheme Procedure: make-doubly-weak-alist-vector size + Return a weak hash table with SIZE buckets. As with any hash + table, choosing a good size for the table requires some caution. + + You can modify weak hash tables in exactly the same way you would + modify regular hash tables. (*note Hash Tables::) + + make-weak-value-alist-vector + -- Scheme Procedure: make-weak-value-alist-vector [size] + Return a hash table with weak values with SIZE buckets. (*note + Hash Tables::) + + make-doubly-weak-alist-vector + -- Scheme Procedure: make-doubly-weak-alist-vector size + Return a hash table with weak keys and values with SIZE buckets. + (*note Hash Tables::) + + weak-key-alist-vector? + -- Scheme Procedure: weak-key-alist-vector? obj + -- Scheme Procedure: weak-value-alist-vector? obj + -- Scheme Procedure: doubly-weak-alist-vector? obj + Return '#t' if OBJ is the specified weak hash table. Note that a + doubly weak hash table is neither a weak key nor a weak value hash + table. + + weak-value-alist-vector? + -- Scheme Procedure: weak-value-alist-vector? obj + Return '#t' if OBJ is a weak value hash table. + + doubly-weak-alist-vector? + -- Scheme Procedure: doubly-weak-alist-vector? obj + Return '#t' if OBJ is a doubly weak hash table. + + array-fill! + -- Scheme Procedure: array-fill! ra fill + Store FILL in every element of ARRAY. The value returned is + unspecified. + + array-copy-in-order! + -- Scheme Procedure: array-copy-in-order! + implemented by the C function "scm_array_copy_x" + + array-copy! + -- Scheme Procedure: array-copy! src dst + -- Scheme Procedure: array-copy-in-order! src dst + Copy every element from vector or array SOURCE to the corresponding + element of DESTINATION. DESTINATION must have the same rank as + SOURCE, and be at least as large in each dimension. The order is + unspecified. + + array-map-in-order! + -- Scheme Procedure: array-map-in-order! + implemented by the C function "scm_array_map_x" + + array-map! + -- Scheme Procedure: array-map! ra0 proc . lra + -- Scheme Procedure: array-map-in-order! ra0 proc . lra + ARRAY1, ... must have the same number of dimensions as ARRAY0 and + have a range for each index which includes the range for the + corresponding index in ARRAY0. PROC is applied to each tuple of + elements of ARRAY1 ... and the result is stored as the + corresponding element in ARRAY0. The value returned is + unspecified. The order of application is unspecified. + + array-for-each + -- Scheme Procedure: array-for-each proc ra0 . lra + Apply PROC to each tuple of elements of ARRAY0 ... in row-major + order. The value returned is unspecified. + + array-index-map! + -- Scheme Procedure: array-index-map! ra proc + Apply PROC to the indices of each element of ARRAY in turn, storing + the result in the corresponding element. The value returned and + the order of application are unspecified. + + One can implement ARRAY-INDEXES as + (define (array-indexes array) + (let ((ra (apply make-array #f (array-shape array)))) + (array-index-map! ra (lambda x x)) + ra)) + Another example: + (define (apl:index-generator n) + (let ((v (make-uniform-vector n 1))) + (array-index-map! v (lambda (i) i)) + v)) + + array? + -- Scheme Procedure: array? obj [prot] + Return '#t' if the OBJ is an array, and '#f' if not. + + typed-array? + -- Scheme Procedure: typed-array? obj type + Return '#t' if the OBJ is an array of type TYPE, and '#f' if not. + + array-rank + -- Scheme Procedure: array-rank array + Return the number of dimensions of the array ARRAY. + + array-dimensions + -- Scheme Procedure: array-dimensions ra + 'array-dimensions' is similar to 'array-shape' but replaces + elements with a '0' minimum with one greater than the maximum. So: + (array-dimensions (make-array 'foo '(-1 3) 5)) => ((-1 3) 5) + + shared-array-root + -- Scheme Procedure: shared-array-root ra + Return the root vector of a shared array. + + shared-array-offset + -- Scheme Procedure: shared-array-offset ra + Return the root vector index of the first element in the array. + + shared-array-increments + -- Scheme Procedure: shared-array-increments ra + For each dimension, return the distance between elements in the + root vector. + + make-typed-array + -- Scheme Procedure: make-typed-array type fill . bounds + Create and return an array of type TYPE. + + make-array + -- Scheme Procedure: make-array fill . bounds + Create and return an array. + + dimensions->uniform-array + -- Scheme Procedure: dimensions->uniform-array dims prot [fill] + -- Scheme Procedure: make-uniform-vector length prototype [fill] + Create and return a uniform array or vector of type corresponding + to PROTOTYPE with dimensions DIMS or length LENGTH. If FILL is + supplied, it's used to fill the array, otherwise PROTOTYPE is used. + + make-shared-array + -- Scheme Procedure: make-shared-array oldra mapfunc . dims + 'make-shared-array' can be used to create shared subarrays of other + arrays. The MAPPER is a function that translates coordinates in + the new array into coordinates in the old array. A MAPPER must be + linear, and its range must stay within the bounds of the old array, + but it can be otherwise arbitrary. A simple example: + (define fred (make-array #f 8 8)) + (define freds-diagonal + (make-shared-array fred (lambda (i) (list i i)) 8)) + (array-set! freds-diagonal 'foo 3) + (array-ref fred 3 3) => foo + (define freds-center + (make-shared-array fred (lambda (i j) (list (+ 3 i) (+ 3 j))) 2 2)) + (array-ref freds-center 0 0) => foo + + transpose-array + -- Scheme Procedure: transpose-array ra . args + Return an array sharing contents with ARRAY, but with dimensions + arranged in a different order. There must be one DIM argument for + each dimension of ARRAY. DIM0, DIM1, ... should be integers + between 0 and the rank of the array to be returned. Each integer + in that range must appear at least once in the argument list. + + The values of DIM0, DIM1, ... correspond to dimensions in the array + to be returned, their positions in the argument list to dimensions + of ARRAY. Several DIMs may have the same value, in which case the + returned array will have smaller rank than ARRAY. + + (transpose-array '#2((a b) (c d)) 1 0) => #2((a c) (b d)) + (transpose-array '#2((a b) (c d)) 0 0) => #1(a d) + (transpose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 1 0) => + #2((a 4) (b 5) (c 6)) + + enclose-array + -- Scheme Procedure: enclose-array ra . axes + DIM0, DIM1 ... should be nonnegative integers less than the rank of + ARRAY. ENCLOSE-ARRAY returns an array resembling an array of + shared arrays. The dimensions of each shared array are the same as + the DIMth dimensions of the original array, the dimensions of the + outer array are the same as those of the original array that did + not match a DIM. + + An enclosed array is not a general Scheme array. Its elements may + not be set using 'array-set!'. Two references to the same element + of an enclosed array will be 'equal?' but will not in general be + 'eq?'. The value returned by ARRAY-PROTOTYPE when given an + enclosed array is unspecified. + + examples: + (enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1) => + # + + (enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 0) => + # + + array-in-bounds? + -- Scheme Procedure: array-in-bounds? v . args + Return '#t' if its arguments would be acceptable to 'array-ref'. + + array-ref + -- Scheme Procedure: array-ref v . args + Return the element at the '(index1, index2)' element in ARRAY. + + array-set! + -- Scheme Procedure: array-set! v obj . args + Set the element at the '(index1, index2)' element in ARRAY to + NEW-VALUE. The value returned by array-set! is unspecified. + + array-contents + -- Scheme Procedure: array-contents ra [strict] + If ARRAY may be "unrolled" into a one dimensional shared array + without changing their order (last subscript changing fastest), + then 'array-contents' returns that shared array, otherwise it + returns '#f'. All arrays made by MAKE-ARRAY and MAKE-UNIFORM-ARRAY + may be unrolled, some arrays made by MAKE-SHARED-ARRAY may not be. + + If the optional argument STRICT is provided, a shared array will be + returned only if its elements are stored internally contiguous in + memory. + + uniform-array-read! + -- Scheme Procedure: uniform-array-read! ura [port_or_fd [start [end]]] + -- Scheme Procedure: uniform-vector-read! uve [port-or-fdes] [start] + [end] + Attempt to read all elements of URA, in lexicographic order, as + binary objects from PORT-OR-FDES. If an end of file is + encountered, the objects up to that point are put into URA + (starting at the beginning) and the remainder of the array is + unchanged. + + The optional arguments START and END allow a specified region of a + vector (or linearized array) to be read, leaving the remainder of + the vector unchanged. + + 'uniform-array-read!' returns the number of objects read. + PORT-OR-FDES may be omitted, in which case it defaults to the value + returned by '(current-input-port)'. + + uniform-array-write + -- Scheme Procedure: uniform-array-write ura [port_or_fd [start [end]]] + Writes all elements of URA as binary objects to PORT-OR-FDES. + + The optional arguments START and END allow a specified region of a + vector (or linearized array) to be written. + + The number of objects actually written is returned. PORT-OR-FDES + may be omitted, in which case it defaults to the value returned by + '(current-output-port)'. + + bitvector? + -- Scheme Procedure: bitvector? obj + Return '#t' when OBJ is a bitvector, else return '#f'. + + make-bitvector + -- Scheme Procedure: make-bitvector len [fill] + Create a new bitvector of length LEN and optionally initialize all + elements to FILL. + + bitvector + -- Scheme Procedure: bitvector . bits + Create a new bitvector with the arguments as elements. + + bitvector-length + -- Scheme Procedure: bitvector-length vec + Return the length of the bitvector VEC. + + bitvector-ref + -- Scheme Procedure: bitvector-ref vec idx + Return the element at index IDX of the bitvector VEC. + + bitvector-set! + -- Scheme Procedure: bitvector-set! vec idx val + Set the element at index IDX of the bitvector VEC when VAL is true, + else clear it. + + bitvector-fill! + -- Scheme Procedure: bitvector-fill! vec val + Set all elements of the bitvector VEC when VAL is true, else clear + them. + + list->bitvector + -- Scheme Procedure: list->bitvector list + Return a new bitvector initialized with the elements of LIST. + + bitvector->list + -- Scheme Procedure: bitvector->list vec + Return a new list initialized with the elements of the bitvector + VEC. + + bit-count + -- Scheme Procedure: bit-count b bitvector + Return the number of occurrences of the boolean B in BITVECTOR. + + bit-position + -- Scheme Procedure: bit-position item v k + Return the index of the first occurrance of ITEM in bit vector V, + starting from K. If there is no ITEM entry between K and the end + of BITVECTOR, then return '#f'. For example, + + (bit-position #t #*000101 0) => 3 + (bit-position #f #*0001111 3) => #f + + bit-set*! + -- Scheme Procedure: bit-set*! v kv obj + Set entries of bit vector V to OBJ, with KV selecting the entries + to change. The return value is unspecified. + + If KV is a bit vector, then those entries where it has '#t' are the + ones in V which are set to OBJ. KV and V must be the same length. + When OBJ is '#t' it's like KV is OR'ed into V. Or when OBJ is '#f' + it can be seen as an ANDNOT. + + (define bv #*01000010) + (bit-set*! bv #*10010001 #t) + bv + => #*11010011 + + If KV is a u32vector, then its elements are indices into V which + are set to OBJ. + + (define bv #*01000010) + (bit-set*! bv #u32(5 2 7) #t) + bv + => #*01100111 + + bit-count* + -- Scheme Procedure: bit-count* v kv obj + Return a count of how many entries in bit vector V are equal to + OBJ, with KV selecting the entries to consider. + + If KV is a bit vector, then those entries where it has '#t' are the + ones in V which are considered. KV and V must be the same length. + + If KV is a u32vector, then it contains the indexes in V to + consider. + + For example, + + (bit-count* #*01110111 #*11001101 #t) => 3 + (bit-count* #*01110111 #u32(7 0 4) #f) => 2 + + bit-invert! + -- Scheme Procedure: bit-invert! v + Modify the bit vector V by replacing each element with its + negation. + + array->list + -- Scheme Procedure: array->list v + Return a list consisting of all the elements, in order, of ARRAY. + + list->typed-array + -- Scheme Procedure: list->typed-array type shape lst + Return an array of the type TYPE with elements the same as those of + LST. + + The argument SHAPE determines the number of dimensions of the array + and their shape. It is either an exact integer, giving the number + of dimensions directly, or a list whose length specifies the number + of dimensions and each element specified the lower and optionally + the upper bound of the corresponding dimension. When the element + is list of two elements, these elements give the lower and upper + bounds. When it is an exact integer, it gives only the lower + bound. + + list->array + -- Scheme Procedure: list->array ndim lst + Return an array with elements the same as those of LST. + + list->uniform-array + -- Scheme Procedure: list->uniform-array ndim prot lst + Return a uniform array of the type indicated by prototype PROT with + elements the same as those of LST. Elements must be of the + appropriate type, no coercions are done. + + The argument NDIM determines the number of dimensions of the array. + It is either an exact integer, giving the number directly, or a + list of exact integers, whose length specifies the number of + dimensions and each element is the lower index bound of its + dimension. + + array-type + -- Scheme Procedure: array-type ra + + array-prototype + -- Scheme Procedure: array-prototype ra + Return an object that would produce an array of the same type as + ARRAY, if used as the PROTOTYPE for 'make-uniform-array'. + + dynamic-link + -- Scheme Procedure: dynamic-link filename + Find the shared object (shared library) denoted by FILENAME and + link it into the running Guile application. The returned scheme + object is a "handle" for the library which can be passed to + 'dynamic-func', 'dynamic-call' etc. + + Searching for object files is system dependent. Normally, if + FILENAME does have an explicit directory it will be searched for in + locations such as '/usr/lib' and '/usr/local/lib'. + + dynamic-object? + -- Scheme Procedure: dynamic-object? obj + Return '#t' if OBJ is a dynamic object handle, or '#f' otherwise. + + dynamic-unlink + -- Scheme Procedure: dynamic-unlink dobj + Unlink a dynamic object from the application, if possible. The + object must have been linked by 'dynamic-link', with DOBJ the + corresponding handle. After this procedure is called, the handle + can no longer be used to access the object. + + dynamic-func + -- Scheme Procedure: dynamic-func name dobj + Return a "handle" for the function NAME in the shared object + referred to by DOBJ. The handle can be passed to 'dynamic-call' to + actually call the function. + + Regardless whether your C compiler prepends an underscore '_' to + the global names in a program, you should *not* include this + underscore in NAME since it will be added automatically when + necessary. + + dynamic-call + -- Scheme Procedure: dynamic-call func dobj + Call a C function in a dynamic object. Two styles of invocation + are supported: + + * FUNC can be a function handle returned by 'dynamic-func'. In + this case DOBJ is ignored + * FUNC can be a string with the name of the function to call, + with DOBJ the handle of the dynamic object in which to find + the function. This is equivalent to + + (dynamic-call (dynamic-func FUNC DOBJ) #f) + + In either case, the function is passed no arguments and its return + value is ignored. + + dynamic-args-call + -- Scheme Procedure: dynamic-args-call func dobj args + Call the C function indicated by FUNC and DOBJ, just like + 'dynamic-call', but pass it some arguments and return its return + value. The C function is expected to take two arguments and return + an 'int', just like 'main': + int c_func (int argc, char **argv); + + The parameter ARGS must be a list of strings and is converted into + an array of 'char *'. The array is passed in ARGV and its size in + ARGC. The return value is converted to a Scheme number and + returned from the call to 'dynamic-args-call'. + + chown + -- Scheme Procedure: chown object owner group + Change the ownership and group of the file referred to by OBJECT to + the integer values OWNER and GROUP. OBJECT can be a string + containing a file name or, if the platform supports fchown, a port + or integer file descriptor which is open on the file. The return + value is unspecified. + + If OBJECT is a symbolic link, either the ownership of the link or + the ownership of the referenced file will be changed depending on + the operating system (lchown is unsupported at present). If OWNER + or GROUP is specified as '-1', then that ID is not changed. + + chmod + -- Scheme Procedure: chmod object mode + Changes the permissions of the file referred to by OBJ. OBJ can be + a string containing a file name or a port or integer file + descriptor which is open on a file (in which case 'fchmod' is used + as the underlying system call). MODE specifies the new permissions + as a decimal number, e.g., '(chmod "foo" #o755)'. The return value + is unspecified. + + umask + -- Scheme Procedure: umask [mode] + If MODE is omitted, returns a decimal number representing the + current file creation mask. Otherwise the file creation mask is + set to MODE and the previous value is returned. + + E.g., '(umask #o022)' sets the mask to octal 22, decimal 18. + + open-fdes + -- Scheme Procedure: open-fdes path flags [mode] + Similar to 'open' but return a file descriptor instead of a port. + + open + -- Scheme Procedure: open path flags [mode] + Open the file named by PATH for reading and/or writing. FLAGS is + an integer specifying how the file should be opened. MODE is an + integer specifying the permission bits of the file, if it needs to + be created, before the umask is applied. The default is 666 (Unix + itself has no default). + + FLAGS can be constructed by combining variables using 'logior'. + Basic flags are: + + -- Variable: O_RDONLY + Open the file read-only. + -- Variable: O_WRONLY + Open the file write-only. + -- Variable: O_RDWR + Open the file read/write. + -- Variable: O_APPEND + Append to the file instead of truncating. + -- Variable: O_CREAT + Create the file if it does not already exist. + + See the Unix documentation of the 'open' system call for additional + flags. + + close + -- Scheme Procedure: close fd_or_port + Similar to close-port (*note close-port: Closing.), but also works + on file descriptors. A side effect of closing a file descriptor is + that any ports using that file descriptor are moved to a different + file descriptor and have their revealed counts set to zero. + + close-fdes + -- Scheme Procedure: close-fdes fd + A simple wrapper for the 'close' system call. Close file + descriptor FD, which must be an integer. Unlike close (*note + close: Ports and File Descriptors.), the file descriptor will be + closed even if a port is using it. The return value is + unspecified. + + stat + -- Scheme Procedure: stat object + Return an object containing various information about the file + determined by OBJ. OBJ can be a string containing a file name or a + port or integer file descriptor which is open on a file (in which + case 'fstat' is used as the underlying system call). + + The object returned by 'stat' can be passed as a single parameter + to the following procedures, all of which return integers: + + 'stat:dev' + The device containing the file. + 'stat:ino' + The file serial number, which distinguishes this file from all + other files on the same device. + 'stat:mode' + The mode of the file. This includes file type information and + the file permission bits. See 'stat:type' and 'stat:perms' + below. + 'stat:nlink' + The number of hard links to the file. + 'stat:uid' + The user ID of the file's owner. + 'stat:gid' + The group ID of the file. + 'stat:rdev' + Device ID; this entry is defined only for character or block + special files. + 'stat:size' + The size of a regular file in bytes. + 'stat:atime' + The last access time for the file. + 'stat:mtime' + The last modification time for the file. + 'stat:ctime' + The last modification time for the attributes of the file. + 'stat:blksize' + The optimal block size for reading or writing the file, in + bytes. + 'stat:blocks' + The amount of disk space that the file occupies measured in + units of 512 byte blocks. + + In addition, the following procedures return the information from + stat:mode in a more convenient form: + + 'stat:type' + A symbol representing the type of file. Possible values are + regular, directory, symlink, block-special, char-special, + fifo, socket and unknown + 'stat:perms' + An integer representing the access permission bits. + + link + -- Scheme Procedure: link oldpath newpath + Creates a new name NEWPATH in the file system for the file named by + OLDPATH. If OLDPATH is a symbolic link, the link may or may not be + followed depending on the system. + + rename-file + -- Scheme Procedure: rename-file oldname newname + Renames the file specified by OLDNAME to NEWNAME. The return value + is unspecified. + + delete-file + -- Scheme Procedure: delete-file str + Deletes (or "unlinks") the file specified by PATH. + + mkdir + -- Scheme Procedure: mkdir path [mode] + Create a new directory named by PATH. If MODE is omitted then the + permissions of the directory file are set using the current umask. + Otherwise they are set to the decimal value specified with MODE. + The return value is unspecified. + + rmdir + -- Scheme Procedure: rmdir path + Remove the existing directory named by PATH. The directory must be + empty for this to succeed. The return value is unspecified. + + directory-stream? + -- Scheme Procedure: directory-stream? obj + Return a boolean indicating whether OBJECT is a directory stream as + returned by 'opendir'. + + opendir + -- Scheme Procedure: opendir dirname + Open the directory specified by PATH and return a directory stream. + + readdir + -- Scheme Procedure: readdir port + Return (as a string) the next directory entry from the directory + stream STREAM. If there is no remaining entry to be read then the + end of file object is returned. + + rewinddir + -- Scheme Procedure: rewinddir port + Reset the directory port STREAM so that the next call to 'readdir' + will return the first directory entry. + + closedir + -- Scheme Procedure: closedir port + Close the directory stream STREAM. The return value is + unspecified. + + chdir + -- Scheme Procedure: chdir str + Change the current working directory to PATH. The return value is + unspecified. + + getcwd + -- Scheme Procedure: getcwd + Return the name of the current working directory. + + select + -- Scheme Procedure: select reads writes excepts [secs [usecs]] + This procedure has a variety of uses: waiting for the ability to + provide input, accept output, or the existence of exceptional + conditions on a collection of ports or file descriptors, or waiting + for a timeout to occur. It also returns if interrupted by a + signal. + + READS, WRITES and EXCEPTS can be lists or vectors, with each member + a port or a file descriptor. The value returned is a list of three + corresponding lists or vectors containing only the members which + meet the specified requirement. The ability of port buffers to + provide input or accept output is taken into account. Ordering of + the input lists or vectors is not preserved. + + The optional arguments SECS and USECS specify the timeout. Either + SECS can be specified alone, as either an integer or a real number, + or both SECS and USECS can be specified as integers, in which case + USECS is an additional timeout expressed in microseconds. If SECS + is omitted or is '#f' then select will wait for as long as it takes + for one of the other conditions to be satisfied. + + The scsh version of 'select' differs as follows: Only vectors are + accepted for the first three arguments. The USECS argument is not + supported. Multiple values are returned instead of a list. + Duplicates in the input vectors appear only once in output. An + additional 'select!' interface is provided. + + fcntl + -- Scheme Procedure: fcntl object cmd [value] + Apply COMMAND to the specified file descriptor or the underlying + file descriptor of the specified port. VALUE is an optional + integer argument. + + Values for COMMAND are: + + 'F_DUPFD' + Duplicate a file descriptor + 'F_GETFD' + Get flags associated with the file descriptor. + 'F_SETFD' + Set flags associated with the file descriptor to VALUE. + 'F_GETFL' + Get flags associated with the open file. + 'F_SETFL' + Set flags associated with the open file to VALUE + 'F_GETOWN' + Get the process ID of a socket's owner, for 'SIGIO' signals. + 'F_SETOWN' + Set the process that owns a socket to VALUE, for 'SIGIO' + signals. + 'FD_CLOEXEC' + The value used to indicate the "close on exec" flag with + 'F_GETFL' or 'F_SETFL'. + + fsync + -- Scheme Procedure: fsync object + Copies any unwritten data for the specified output file descriptor + to disk. If PORT/FD is a port, its buffer is flushed before the + underlying file descriptor is fsync'd. The return value is + unspecified. + + symlink + -- Scheme Procedure: symlink oldpath newpath + Create a symbolic link named PATH-TO with the value (i.e., pointing + to) PATH-FROM. The return value is unspecified. + + readlink + -- Scheme Procedure: readlink path + Return the value of the symbolic link named by PATH (a string), + i.e., the file that the link points to. + + lstat + -- Scheme Procedure: lstat str + Similar to 'stat', but does not follow symbolic links, i.e., it + will return information about a symbolic link itself, not the file + it points to. PATH must be a string. + + copy-file + -- Scheme Procedure: copy-file oldfile newfile + Copy the file specified by PATH-FROM to PATH-TO. The return value + is unspecified. + + dirname + -- Scheme Procedure: dirname filename + Return the directory name component of the file name FILENAME. If + FILENAME does not contain a directory component, '.' is returned. + + basename + -- Scheme Procedure: basename filename [suffix] + Return the base name of the file name FILENAME. The base name is + the file name without any directory components. If SUFFIX is + provided, and is equal to the end of BASENAME, it is removed also. + + pipe + -- Scheme Procedure: pipe + Return a newly created pipe: a pair of ports which are linked + together on the local machine. The _car_ is the input port and the + _cdr_ is the output port. Data written (and flushed) to the output + port can be read from the input port. Pipes are commonly used for + communication with a newly forked child process. The need to flush + the output port can be avoided by making it unbuffered using + 'setvbuf'. + + Writes occur atomically provided the size of the data in bytes is + not greater than the value of 'PIPE_BUF'. Note that the output + port is likely to block if too much data (typically equal to + 'PIPE_BUF') has been written but not yet read from the input port. + + getgroups + -- Scheme Procedure: getgroups + Return a vector of integers representing the current supplementary + group IDs. + + setgroups + -- Scheme Procedure: setgroups group_vec + Set the current set of supplementary group IDs to the integers in + the given vector VEC. The return value is unspecified. + + Generally only the superuser can set the process group IDs. + + getpw + -- Scheme Procedure: getpw [user] + Look up an entry in the user database. OBJ can be an integer, a + string, or omitted, giving the behaviour of getpwuid, getpwnam or + getpwent respectively. + + setpw + -- Scheme Procedure: setpw [arg] + If called with a true argument, initialize or reset the password + data stream. Otherwise, close the stream. The 'setpwent' and + 'endpwent' procedures are implemented on top of this. + + getgr + -- Scheme Procedure: getgr [name] + Look up an entry in the group database. OBJ can be an integer, a + string, or omitted, giving the behaviour of getgrgid, getgrnam or + getgrent respectively. + + setgr + -- Scheme Procedure: setgr [arg] + If called with a true argument, initialize or reset the group data + stream. Otherwise, close the stream. The 'setgrent' and + 'endgrent' procedures are implemented on top of this. + + kill + -- Scheme Procedure: kill pid sig + Sends a signal to the specified process or group of processes. + + PID specifies the processes to which the signal is sent: + + PID greater than 0 + The process whose identifier is PID. + PID equal to 0 + All processes in the current process group. + PID less than -1 + The process group whose identifier is -PID + PID equal to -1 + If the process is privileged, all processes except for some + special system processes. Otherwise, all processes with the + current effective user ID. + + SIG should be specified using a variable corresponding to the Unix + symbolic name, e.g., + + -- Variable: SIGHUP + Hang-up signal. + + -- Variable: SIGINT + Interrupt signal. + + waitpid + -- Scheme Procedure: waitpid pid [options] + This procedure collects status information from a child process + which has terminated or (optionally) stopped. Normally it will + suspend the calling process until this can be done. If more than + one child process is eligible then one will be chosen by the + operating system. + + The value of PID determines the behaviour: + + PID greater than 0 + Request status information from the specified child process. + PID equal to -1 or WAIT_ANY + Request status information for any child process. + PID equal to 0 or WAIT_MYPGRP + Request status information for any child process in the + current process group. + PID less than -1 + Request status information for any child process whose process + group ID is -PID. + + The OPTIONS argument, if supplied, should be the bitwise OR of the + values of zero or more of the following variables: + + -- Variable: WNOHANG + Return immediately even if there are no child processes to be + collected. + + -- Variable: WUNTRACED + Report status information for stopped processes as well as + terminated processes. + + The return value is a pair containing: + + 1. The process ID of the child process, or 0 if 'WNOHANG' was + specified and no process was collected. + 2. The integer status value. + + status:exit-val + -- Scheme Procedure: status:exit-val status + Return the exit status value, as would be set if a process ended + normally through a call to 'exit' or '_exit', if any, otherwise + '#f'. + + status:term-sig + -- Scheme Procedure: status:term-sig status + Return the signal number which terminated the process, if any, + otherwise '#f'. + + status:stop-sig + -- Scheme Procedure: status:stop-sig status + Return the signal number which stopped the process, if any, + otherwise '#f'. + + getppid + -- Scheme Procedure: getppid + Return an integer representing the process ID of the parent + process. + + getuid + -- Scheme Procedure: getuid + Return an integer representing the current real user ID. + + getgid + -- Scheme Procedure: getgid + Return an integer representing the current real group ID. + + geteuid + -- Scheme Procedure: geteuid + Return an integer representing the current effective user ID. If + the system does not support effective IDs, then the real ID is + returned. '(provided? 'EIDs)' reports whether the system supports + effective IDs. + + getegid + -- Scheme Procedure: getegid + Return an integer representing the current effective group ID. If + the system does not support effective IDs, then the real ID is + returned. '(provided? 'EIDs)' reports whether the system supports + effective IDs. + + setuid + -- Scheme Procedure: setuid id + Sets both the real and effective user IDs to the integer ID, + provided the process has appropriate privileges. The return value + is unspecified. + + setgid + -- Scheme Procedure: setgid id + Sets both the real and effective group IDs to the integer ID, + provided the process has appropriate privileges. The return value + is unspecified. + + seteuid + -- Scheme Procedure: seteuid id + Sets the effective user ID to the integer ID, provided the process + has appropriate privileges. If effective IDs are not supported, + the real ID is set instead - '(provided? 'EIDs)' reports whether + the system supports effective IDs. The return value is + unspecified. + + setegid + -- Scheme Procedure: setegid id + Sets the effective group ID to the integer ID, provided the process + has appropriate privileges. If effective IDs are not supported, + the real ID is set instead - '(provided? 'EIDs)' reports whether + the system supports effective IDs. The return value is + unspecified. + + getpgrp + -- Scheme Procedure: getpgrp + Return an integer representing the current process group ID. This + is the POSIX definition, not BSD. + + setpgid + -- Scheme Procedure: setpgid pid pgid + Move the process PID into the process group PGID. PID or PGID must + be integers: they can be zero to indicate the ID of the current + process. Fails on systems that do not support job control. The + return value is unspecified. + + setsid + -- Scheme Procedure: setsid + Creates a new session. The current process becomes the session + leader and is put in a new process group. The process will be + detached from its controlling terminal if it has one. The return + value is an integer representing the new process group ID. + + ttyname + -- Scheme Procedure: ttyname port + Return a string with the name of the serial terminal device + underlying PORT. + + ctermid + -- Scheme Procedure: ctermid + Return a string containing the file name of the controlling + terminal for the current process. + + tcgetpgrp + -- Scheme Procedure: tcgetpgrp port + Return the process group ID of the foreground process group + associated with the terminal open on the file descriptor underlying + PORT. + + If there is no foreground process group, the return value is a + number greater than 1 that does not match the process group ID of + any existing process group. This can happen if all of the + processes in the job that was formerly the foreground job have + terminated, and no other job has yet been moved into the + foreground. + + tcsetpgrp + -- Scheme Procedure: tcsetpgrp port pgid + Set the foreground process group ID for the terminal used by the + file descriptor underlying PORT to the integer PGID. The calling + process must be a member of the same session as PGID and must have + the same controlling terminal. The return value is unspecified. + + execl + -- Scheme Procedure: execl filename . args + Executes the file named by PATH as a new process image. The + remaining arguments are supplied to the process; from a C program + they are accessible as the 'argv' argument to 'main'. + Conventionally the first ARG is the same as PATH. All arguments + must be strings. + + If ARG is missing, PATH is executed with a null argument list, + which may have system-dependent side-effects. + + This procedure is currently implemented using the 'execv' system + call, but we call it 'execl' because of its Scheme calling + interface. + + execlp + -- Scheme Procedure: execlp filename . args + Similar to 'execl', however if FILENAME does not contain a slash + then the file to execute will be located by searching the + directories listed in the 'PATH' environment variable. + + This procedure is currently implemented using the 'execvp' system + call, but we call it 'execlp' because of its Scheme calling + interface. + + execle + -- Scheme Procedure: execle filename env . args + Similar to 'execl', but the environment of the new process is + specified by ENV, which must be a list of strings as returned by + the 'environ' procedure. + + This procedure is currently implemented using the 'execve' system + call, but we call it 'execle' because of its Scheme calling + interface. + + primitive-fork + -- Scheme Procedure: primitive-fork + Creates a new "child" process by duplicating the current "parent" + process. In the child the return value is 0. In the parent the + return value is the integer process ID of the child. + + This procedure has been renamed from 'fork' to avoid a naming + conflict with the scsh fork. + + uname + -- Scheme Procedure: uname + Return an object with some information about the computer system + the program is running on. + + environ + -- Scheme Procedure: environ [env] + If ENV is omitted, return the current environment (in the Unix + sense) as a list of strings. Otherwise set the current + environment, which is also the default environment for child + processes, to the supplied list of strings. Each member of ENV + should be of the form 'NAME=VALUE' and values of 'NAME' should not + be duplicated. If ENV is supplied then the return value is + unspecified. + + tmpnam + -- Scheme Procedure: tmpnam + Return a name in the file system that does not match any existing + file. However there is no guarantee that another process will not + create the file after 'tmpnam' is called. Care should be taken if + opening the file, e.g., use the 'O_EXCL' open flag or use + 'mkstemp!' instead. + + mkstemp! + -- Scheme Procedure: mkstemp! tmpl + Create a new unique file in the file system and return a new + buffered port open for reading and writing to the file. + + TMPL is a string specifying where the file should be created: it + must end with 'XXXXXX' and those 'X's will be changed in the string + to return the name of the file. ('port-filename' on the port also + gives the name.) + + POSIX doesn't specify the permissions mode of the file, on GNU and + most systems it's '#o600'. An application can use 'chmod' to relax + that if desired. For example '#o666' less 'umask', which is usual + for ordinary file creation, + + (let ((port (mkstemp! (string-copy "/tmp/myfile-XXXXXX")))) + (chmod port (logand #o666 (lognot (umask)))) + ...) + + utime + -- Scheme Procedure: utime pathname [actime [modtime]] + 'utime' sets the access and modification times for the file named + by PATH. If ACTIME or MODTIME is not supplied, then the current + time is used. ACTIME and MODTIME must be integer time values as + returned by the 'current-time' procedure. + (utime "foo" (- (current-time) 3600)) + will set the access time to one hour in the past and the + modification time to the current time. + + access? + -- Scheme Procedure: access? path how + Test accessibility of a file under the real UID and GID of the + calling process. The return is '#t' if PATH exists and the + permissions requested by HOW are all allowed, or '#f' if not. + + HOW is an integer which is one of the following values, or a + bitwise-OR ('logior') of multiple values. + + -- Variable: R_OK + Test for read permission. + -- Variable: W_OK + Test for write permission. + -- Variable: X_OK + Test for execute permission. + -- Variable: F_OK + Test for existence of the file. This is implied by each of + the other tests, so there's no need to combine it with them. + + It's important to note that 'access?' does not simply indicate what + will happen on attempting to read or write a file. In normal + circumstances it does, but in a set-UID or set-GID program it + doesn't because 'access?' tests the real ID, whereas an open or + execute attempt uses the effective ID. + + A program which will never run set-UID/GID can ignore the + difference between real and effective IDs, but for maximum + generality, especially in library functions, it's best not to use + 'access?' to predict the result of an open or execute, instead + simply attempt that and catch any exception. + + The main use for 'access?' is to let a set-UID/GID program + determine what the invoking user would have been allowed to do, + without the greater (or perhaps lesser) privileges afforded by the + effective ID. For more on this, see "Testing File Access" in The + GNU C Library Reference Manual. + + getpid + -- Scheme Procedure: getpid + Return an integer representing the current process ID. + + putenv + -- Scheme Procedure: putenv str + Modifies the environment of the current process, which is also the + default environment inherited by child processes. + + If STRING is of the form 'NAME=VALUE' then it will be written + directly into the environment, replacing any existing environment + string with name matching 'NAME'. If STRING does not contain an + equal sign, then any existing string with name matching STRING will + be removed. + + The return value is unspecified. + + setlocale + -- Scheme Procedure: setlocale category [locale] + If LOCALE is omitted, return the current value of the specified + locale category as a system-dependent string. CATEGORY should be + specified using the values 'LC_COLLATE', 'LC_ALL' etc. + + Otherwise the specified locale category is set to the string LOCALE + and the new value is returned as a system-dependent string. If + LOCALE is an empty string, the locale will be set using environment + variables. + + mknod + -- Scheme Procedure: mknod path type perms dev + Creates a new special file, such as a file corresponding to a + device. PATH specifies the name of the file. TYPE should be one + of the following symbols: regular, directory, symlink, + block-special, char-special, fifo, or socket. PERMS (an integer) + specifies the file permissions. DEV (an integer) specifies which + device the special file refers to. Its exact interpretation + depends on the kind of special file being created. + + E.g., + (mknod "/dev/fd0" 'block-special #o660 (+ (* 2 256) 2)) + + The return value is unspecified. + + nice + -- Scheme Procedure: nice incr + Increment the priority of the current process by INCR. A higher + priority value means that the process runs less often. The return + value is unspecified. + + sync + -- Scheme Procedure: sync + Flush the operating system disk buffers. The return value is + unspecified. + + crypt + -- Scheme Procedure: crypt key salt + Encrypt KEY using SALT as the salt value to the crypt(3) library + call. + + chroot + -- Scheme Procedure: chroot path + Change the root directory to that specified in PATH. This + directory will be used for path names beginning with '/'. The root + directory is inherited by all children of the current process. + Only the superuser may change the root directory. + + getlogin + -- Scheme Procedure: getlogin + Return a string containing the name of the user logged in on the + controlling terminal of the process, or '#f' if this information + cannot be obtained. + + cuserid + -- Scheme Procedure: cuserid + Return a string containing a user name associated with the + effective user id of the process. Return '#f' if this information + cannot be obtained. + + getpriority + -- Scheme Procedure: getpriority which who + Return the scheduling priority of the process, process group or + user, as indicated by WHICH and WHO. WHICH is one of the variables + 'PRIO_PROCESS', 'PRIO_PGRP' or 'PRIO_USER', and WHO is interpreted + relative to WHICH (a process identifier for 'PRIO_PROCESS', process + group identifier for 'PRIO_PGRP', and a user identifier for + 'PRIO_USER'. A zero value of WHO denotes the current process, + process group, or user. Return the highest priority (lowest + numerical value) of any of the specified processes. + + setpriority + -- Scheme Procedure: setpriority which who prio + Set the scheduling priority of the process, process group or user, + as indicated by WHICH and WHO. WHICH is one of the variables + 'PRIO_PROCESS', 'PRIO_PGRP' or 'PRIO_USER', and WHO is interpreted + relative to WHICH (a process identifier for 'PRIO_PROCESS', process + group identifier for 'PRIO_PGRP', and a user identifier for + 'PRIO_USER'. A zero value of WHO denotes the current process, + process group, or user. PRIO is a value in the range -20 and 20, + the default priority is 0; lower priorities cause more favorable + scheduling. Sets the priority of all of the specified processes. + Only the super-user may lower priorities. The return value is not + specified. + + getpass + -- Scheme Procedure: getpass prompt + Display PROMPT to the standard error output and read a password + from '/dev/tty'. If this file is not accessible, it reads from + standard input. The password may be up to 127 characters in + length. Additional characters and the terminating newline + character are discarded. While reading the password, echoing and + the generation of signals by special characters is disabled. + + flock + -- Scheme Procedure: flock file operation + Apply or remove an advisory lock on an open file. OPERATION + specifies the action to be done: + + -- Variable: LOCK_SH + Shared lock. More than one process may hold a shared lock for + a given file at a given time. + -- Variable: LOCK_EX + Exclusive lock. Only one process may hold an exclusive lock + for a given file at a given time. + -- Variable: LOCK_UN + Unlock the file. + -- Variable: LOCK_NB + Don't block when locking. This is combined with one of the + other operations using 'logior'. If 'flock' would block an + 'EWOULDBLOCK' error is thrown. + + The return value is not specified. FILE may be an open file + descriptor or an open file descriptor port. + + Note that 'flock' does not lock files across NFS. + + sethostname + -- Scheme Procedure: sethostname name + Set the host name of the current processor to NAME. May only be + used by the superuser. The return value is not specified. + + gethostname + -- Scheme Procedure: gethostname + Return the host name of the current processor. + + gethost + -- Scheme Procedure: gethost [host] + -- Scheme Procedure: gethostbyname hostname + -- Scheme Procedure: gethostbyaddr address + Look up a host by name or address, returning a host object. The + 'gethost' procedure will accept either a string name or an integer + address; if given no arguments, it behaves like 'gethostent' (see + below). If a name or address is supplied but the address can not + be found, an error will be thrown to one of the keys: + 'host-not-found', 'try-again', 'no-recovery' or 'no-data', + corresponding to the equivalent 'h_error' values. Unusual + conditions may result in errors thrown to the 'system-error' or + 'misc_error' keys. + + getnet + -- Scheme Procedure: getnet [net] + -- Scheme Procedure: getnetbyname net-name + -- Scheme Procedure: getnetbyaddr net-number + Look up a network by name or net number in the network database. + The NET-NAME argument must be a string, and the NET-NUMBER argument + must be an integer. 'getnet' will accept either type of argument, + behaving like 'getnetent' (see below) if no arguments are given. + + getproto + -- Scheme Procedure: getproto [protocol] + -- Scheme Procedure: getprotobyname name + -- Scheme Procedure: getprotobynumber number + Look up a network protocol by name or by number. 'getprotobyname' + takes a string argument, and 'getprotobynumber' takes an integer + argument. 'getproto' will accept either type, behaving like + 'getprotoent' (see below) if no arguments are supplied. + + getserv + -- Scheme Procedure: getserv [name [protocol]] + -- Scheme Procedure: getservbyname name protocol + -- Scheme Procedure: getservbyport port protocol + Look up a network service by name or by service number, and return + a network service object. The PROTOCOL argument specifies the name + of the desired protocol; if the protocol found in the network + service database does not match this name, a system error is + signalled. + + The 'getserv' procedure will take either a service name or number + as its first argument; if given no arguments, it behaves like + 'getservent' (see below). + + sethost + -- Scheme Procedure: sethost [stayopen] + If STAYOPEN is omitted, this is equivalent to 'endhostent'. + Otherwise it is equivalent to 'sethostent stayopen'. + + setnet + -- Scheme Procedure: setnet [stayopen] + If STAYOPEN is omitted, this is equivalent to 'endnetent'. + Otherwise it is equivalent to 'setnetent stayopen'. + + setproto + -- Scheme Procedure: setproto [stayopen] + If STAYOPEN is omitted, this is equivalent to 'endprotoent'. + Otherwise it is equivalent to 'setprotoent stayopen'. + + setserv + -- Scheme Procedure: setserv [stayopen] + If STAYOPEN is omitted, this is equivalent to 'endservent'. + Otherwise it is equivalent to 'setservent stayopen'. + + htons + -- Scheme Procedure: htons value + Convert a 16 bit quantity from host to network byte ordering. + VALUE is packed into 2 bytes, which are then converted and returned + as a new integer. + + ntohs + -- Scheme Procedure: ntohs value + Convert a 16 bit quantity from network to host byte ordering. + VALUE is packed into 2 bytes, which are then converted and returned + as a new integer. + + htonl + -- Scheme Procedure: htonl value + Convert a 32 bit quantity from host to network byte ordering. + VALUE is packed into 4 bytes, which are then converted and returned + as a new integer. + + ntohl + -- Scheme Procedure: ntohl value + Convert a 32 bit quantity from network to host byte ordering. + VALUE is packed into 4 bytes, which are then converted and returned + as a new integer. + + inet-aton + -- Scheme Procedure: inet-aton address + Convert an IPv4 Internet address from printable string (dotted + decimal notation) to an integer. E.g., + + (inet-aton "127.0.0.1") => 2130706433 + + inet-ntoa + -- Scheme Procedure: inet-ntoa inetid + Convert an IPv4 Internet address to a printable (dotted decimal + notation) string. E.g., + + (inet-ntoa 2130706433) => "127.0.0.1" + + inet-netof + -- Scheme Procedure: inet-netof address + Return the network number part of the given IPv4 Internet address. + E.g., + + (inet-netof 2130706433) => 127 + + inet-lnaof + -- Scheme Procedure: inet-lnaof address + Return the local-address-with-network part of the given IPv4 + Internet address, using the obsolete class A/B/C system. E.g., + + (inet-lnaof 2130706433) => 1 + + inet-makeaddr + -- Scheme Procedure: inet-makeaddr net lna + Make an IPv4 Internet address by combining the network number NET + with the local-address-within-network number LNA. E.g., + + (inet-makeaddr 127 1) => 2130706433 + + inet-pton + -- Scheme Procedure: inet-pton family address + Convert a string containing a printable network address to an + integer address. Note that unlike the C version of this function, + the result is an integer with normal host byte ordering. FAMILY + can be 'AF_INET' or 'AF_INET6'. E.g., + + (inet-pton AF_INET "127.0.0.1") => 2130706433 + (inet-pton AF_INET6 "::1") => 1 + + inet-ntop + -- Scheme Procedure: inet-ntop family address + Convert a network address into a printable string. Note that + unlike the C version of this function, the input is an integer with + normal host byte ordering. FAMILY can be 'AF_INET' or 'AF_INET6'. + E.g., + + (inet-ntop AF_INET 2130706433) => "127.0.0.1" + (inet-ntop AF_INET6 (- (expt 2 128) 1)) + => "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" + + socket + -- Scheme Procedure: socket family style proto + Return a new socket port of the type specified by FAMILY, STYLE and + PROTO. All three parameters are integers. Supported values for + FAMILY are 'AF_UNIX', 'AF_INET' and 'AF_INET6'. Typical values for + STYLE are 'SOCK_STREAM', 'SOCK_DGRAM' and 'SOCK_RAW'. + + PROTO can be obtained from a protocol name using 'getprotobyname'. + A value of zero specifies the default protocol, which is usually + right. + + A single socket port cannot by used for communication until it has + been connected to another socket. + + socketpair + -- Scheme Procedure: socketpair family style proto + Return a pair of connected (but unnamed) socket ports of the type + specified by FAMILY, STYLE and PROTO. Many systems support only + socket pairs of the 'AF_UNIX' family. Zero is likely to be the + only meaningful value for PROTO. + + getsockopt + -- Scheme Procedure: getsockopt sock level optname + Return an option value from socket port SOCK. + + LEVEL is an integer specifying a protocol layer, either + 'SOL_SOCKET' for socket level options, or a protocol number from + the 'IPPROTO' constants or 'getprotoent' (*note Network + Databases::). + + -- Variable: SOL_SOCKET + -- Variable: IPPROTO_IP + -- Variable: IPPROTO_TCP + -- Variable: IPPROTO_UDP + + OPTNAME is an integer specifying an option within the protocol + layer. + + For 'SOL_SOCKET' level the following OPTNAMEs are defined (when + provided by the system). For their meaning see *note + (libc)Socket-Level Options::, or 'man 7 socket'. + + -- Variable: SO_DEBUG + -- Variable: SO_REUSEADDR + -- Variable: SO_STYLE + -- Variable: SO_TYPE + -- Variable: SO_ERROR + -- Variable: SO_DONTROUTE + -- Variable: SO_BROADCAST + -- Variable: SO_SNDBUF + -- Variable: SO_RCVBUF + -- Variable: SO_KEEPALIVE + -- Variable: SO_OOBINLINE + -- Variable: SO_NO_CHECK + -- Variable: SO_PRIORITY + The value returned is an integer. + + -- Variable: SO_LINGER + The VALUE returned is a pair of integers '(ENABLE . TIMEOUT)'. + On old systems without timeout support (ie. without 'struct + linger'), only ENABLE has an effect but the value in Guile is + always a pair. + + setsockopt + -- Scheme Procedure: setsockopt sock level optname value + Set an option on socket port SOCK. The return value is + unspecified. + + LEVEL is an integer specifying a protocol layer, either + 'SOL_SOCKET' for socket level options, or a protocol number from + the 'IPPROTO' constants or 'getprotoent' (*note Network + Databases::). + + -- Variable: SOL_SOCKET + -- Variable: IPPROTO_IP + -- Variable: IPPROTO_TCP + -- Variable: IPPROTO_UDP + + OPTNAME is an integer specifying an option within the protocol + layer. + + For 'SOL_SOCKET' level the following OPTNAMEs are defined (when + provided by the system). For their meaning see *note + (libc)Socket-Level Options::, or 'man 7 socket'. + + -- Variable: SO_DEBUG + -- Variable: SO_REUSEADDR + -- Variable: SO_STYLE + -- Variable: SO_TYPE + -- Variable: SO_ERROR + -- Variable: SO_DONTROUTE + -- Variable: SO_BROADCAST + -- Variable: SO_SNDBUF + -- Variable: SO_RCVBUF + -- Variable: SO_KEEPALIVE + -- Variable: SO_OOBINLINE + -- Variable: SO_NO_CHECK + -- Variable: SO_PRIORITY + VALUE is an integer. + + -- Variable: SO_LINGER + VALUE is a pair of integers '(ENABLE . TIMEOUT)'. On old + systems without timeout support (ie. without 'struct linger'), + only ENABLE has an effect but the value in Guile is always a + pair. + + For IP level ('IPPROTO_IP') the following OPTNAMEs are defined + (when provided by the system). See 'man ip' for what they mean. + + -- Variable: IP_ADD_MEMBERSHIP + -- Variable: IP_DROP_MEMBERSHIP + These can be used only with 'setsockopt', not 'getsockopt'. + VALUE is a pair '(MULTIADDR . INTERFACEADDR)' of IPv4 + addresses (*note Network Address Conversion::). MULTIADDR is + a multicast address to be added to or dropped from the + interface INTERFACEADDR. INTERFACEADDR can be 'INADDR_ANY' to + have the system select the interface. INTERFACEADDR can also + be an interface index number, on systems supporting that. + + shutdown + -- Scheme Procedure: shutdown sock how + Sockets can be closed simply by using 'close-port'. The 'shutdown' + procedure allows reception or transmission on a connection to be + shut down individually, according to the parameter HOW: + + 0 + Stop receiving data for this socket. If further data arrives, + reject it. + 1 + Stop trying to transmit data from this socket. Discard any + data waiting to be sent. Stop looking for acknowledgement of + data already sent; don't retransmit it if it is lost. + 2 + Stop both reception and transmission. + + The return value is unspecified. + + connect + -- Scheme Procedure: connect sock fam_or_sockaddr [address . args] + Initiate a connection from a socket using a specified address + family to the address specified by ADDRESS and possibly ARGS. The + format required for ADDRESS and ARGS depends on the family of the + socket. + + For a socket of family 'AF_UNIX', only ADDRESS is specified and + must be a string with the filename where the socket is to be + created. + + For a socket of family 'AF_INET', ADDRESS must be an integer IPv4 + host address and ARGS must be a single integer port number. + + For a socket of family 'AF_INET6', ADDRESS must be an integer IPv6 + host address and ARGS may be up to three integers: port [flowinfo] + [scope_id], where flowinfo and scope_id default to zero. + + Alternatively, the second argument can be a socket address object + as returned by 'make-socket-address', in which case the no + additional arguments should be passed. + + The return value is unspecified. + + bind + -- Scheme Procedure: bind sock fam_or_sockaddr [address . args] + Assign an address to the socket port SOCK. Generally this only + needs to be done for server sockets, so they know where to look for + incoming connections. A socket without an address will be assigned + one automatically when it starts communicating. + + The format of ADDRESS and ARGS depends on the family of the socket. + + For a socket of family 'AF_UNIX', only ADDRESS is specified and + must be a string with the filename where the socket is to be + created. + + For a socket of family 'AF_INET', ADDRESS must be an integer IPv4 + address and ARGS must be a single integer port number. + + The values of the following variables can also be used for ADDRESS: + + -- Variable: INADDR_ANY + Allow connections from any address. + + -- Variable: INADDR_LOOPBACK + The address of the local host using the loopback device. + + -- Variable: INADDR_BROADCAST + The broadcast address on the local network. + + -- Variable: INADDR_NONE + No address. + + For a socket of family 'AF_INET6', ADDRESS must be an integer IPv6 + address and ARGS may be up to three integers: port [flowinfo] + [scope_id], where flowinfo and scope_id default to zero. + + Alternatively, the second argument can be a socket address object + as returned by 'make-socket-address', in which case the no + additional arguments should be passed. + + The return value is unspecified. + + listen + -- Scheme Procedure: listen sock backlog + Enable SOCK to accept connection requests. BACKLOG is an integer + specifying the maximum length of the queue for pending connections. + If the queue fills, new clients will fail to connect until the + server calls 'accept' to accept a connection from the queue. + + The return value is unspecified. + + make-socket-address + -- Scheme Procedure: make-socket-address family address . args + Return a Scheme address object that reflects ADDRESS, being an + address of family FAMILY, with the family-specific parameters ARGS + (see the description of 'connect' for details). + + accept + -- Scheme Procedure: accept sock + Accept a connection on a bound, listening socket. If there are no + pending connections in the queue, wait until one is available + unless the non-blocking option has been set on the socket. + + The return value is a pair in which the _car_ is a new socket port + for the connection and the _cdr_ is an object with address + information about the client which initiated the connection. + + SOCK does not become part of the connection and will continue to + accept new requests. + + getsockname + -- Scheme Procedure: getsockname sock + Return the address of SOCK, in the same form as the object returned + by 'accept'. On many systems the address of a socket in the + 'AF_FILE' namespace cannot be read. + + getpeername + -- Scheme Procedure: getpeername sock + Return the address that SOCK is connected to, in the same form as + the object returned by 'accept'. On many systems the address of a + socket in the 'AF_FILE' namespace cannot be read. + + recv! + -- Scheme Procedure: recv! sock buf [flags] + Receive data from a socket port. SOCK must already be bound to the + address from which data is to be received. BUF is a string into + which the data will be written. The size of BUF limits the amount + of data which can be received: in the case of packet protocols, if + a packet larger than this limit is encountered then some data will + be irrevocably lost. + + The optional FLAGS argument is a value or bitwise OR of MSG_OOB, + MSG_PEEK, MSG_DONTROUTE etc. + + The value returned is the number of bytes read from the socket. + + Note that the data is read directly from the socket file + descriptor: any unread buffered port data is ignored. + + send + -- Scheme Procedure: send sock message [flags] + Transmit the string MESSAGE on a socket port SOCK. SOCK must + already be bound to a destination address. The value returned is + the number of bytes transmitted - it's possible for this to be less + than the length of MESSAGE if the socket is set to be non-blocking. + The optional FLAGS argument is a value or bitwise OR of MSG_OOB, + MSG_PEEK, MSG_DONTROUTE etc. + + Note that the data is written directly to the socket file + descriptor: any unflushed buffered port data is ignored. + + recvfrom! + -- Scheme Procedure: recvfrom! sock str [flags [start [end]]] + Receive data from socket port SOCK (which must be already bound), + returning the originating address as well as the data. This is + usually for use on datagram sockets, but can be used on + stream-oriented sockets too. + + The data received is stored in the given STR, using either the + whole string or just the region between the optional START and END + positions. The size of STR limits the amount of data which can be + received. For datagram protocols, if a packet larger than this is + received then excess bytes are irrevocably lost. + + The return value is a pair. The 'car' is the number of bytes read. + The 'cdr' is a socket address object which is where the data come + from, or '#f' if the origin is unknown. + + The optional FLAGS argument is a or bitwise OR ('logior') of + 'MSG_OOB', 'MSG_PEEK', 'MSG_DONTROUTE' etc. + + Data is read directly from the socket file descriptor, any buffered + port data is ignored. + + On a GNU/Linux system 'recvfrom!' is not multi-threading, all + threads stop while a 'recvfrom!' call is in progress. An + application may need to use 'select', 'O_NONBLOCK' or + 'MSG_DONTWAIT' to avoid this. + + sendto + -- Scheme Procedure: sendto sock message fam_or_sockaddr [address . + args_and_flags] + Transmit the string MESSAGE on the socket port SOCK. The + destination address is specified using the FAM, ADDRESS and + ARGS_AND_FLAGS arguments, or just a socket address object returned + by 'make-socket-address', in a similar way to the 'connect' + procedure. ARGS_AND_FLAGS contains the usual connection arguments + optionally followed by a flags argument, which is a value or + bitwise OR of MSG_OOB, MSG_PEEK, MSG_DONTROUTE etc. + + The value returned is the number of bytes transmitted - it's + possible for this to be less than the length of MESSAGE if the + socket is set to be non-blocking. Note that the data is written + directly to the socket file descriptor: any unflushed buffered port + data is ignored. + + regexp? + -- Scheme Procedure: regexp? obj + Return '#t' if OBJ is a compiled regular expression, or '#f' + otherwise. + + make-regexp + -- Scheme Procedure: make-regexp pat . flags + Compile the regular expression described by PAT, and return the + compiled regexp structure. If PAT does not describe a legal + regular expression, 'make-regexp' throws a + 'regular-expression-syntax' error. + + The FLAGS arguments change the behavior of the compiled regular + expression. The following flags may be supplied: + + 'regexp/icase' + Consider uppercase and lowercase letters to be the same when + matching. + 'regexp/newline' + If a newline appears in the target string, then permit the '^' + and '$' operators to match immediately after or immediately + before the newline, respectively. Also, the '.' and '[^...]' + operators will never match a newline character. The intent of + this flag is to treat the target string as a buffer containing + many lines of text, and the regular expression as a pattern + that may match a single one of those lines. + 'regexp/basic' + Compile a basic ("obsolete") regexp instead of the extended + ("modern") regexps that are the default. Basic regexps do not + consider '|', '+' or '?' to be special characters, and require + the '{...}' and '(...)' metacharacters to be backslash-escaped + (*note Backslash Escapes::). There are several other + differences between basic and extended regular expressions, + but these are the most significant. + 'regexp/extended' + Compile an extended regular expression rather than a basic + regexp. This is the default behavior; this flag will not + usually be needed. If a call to 'make-regexp' includes both + 'regexp/basic' and 'regexp/extended' flags, the one which + comes last will override the earlier one. + + regexp-exec + -- Scheme Procedure: regexp-exec rx str [start [flags]] + Match the compiled regular expression RX against 'str'. If the + optional integer START argument is provided, begin matching from + that position in the string. Return a match structure describing + the results of the match, or '#f' if no match could be found. + + The FLAGS arguments change the matching behavior. The following + flags may be supplied: + + 'regexp/notbol' + Operator '^' always fails (unless 'regexp/newline' is used). + Use this when the beginning of the string should not be + considered the beginning of a line. + 'regexp/noteol' + Operator '$' always fails (unless 'regexp/newline' is used). + Use this when the end of the string should not be considered + the end of a line. + + +Tag Table: + +End Tag Table diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/and-let-star.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/and-let-star.scm new file mode 100755 index 0000000000000000000000000000000000000000..b8cb2a67961d31d16e74e9f1fd50b7b0fd5f1bcf --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/and-let-star.scm @@ -0,0 +1,49 @@ +;;;; and-let-star.scm --- and-let* syntactic form (draft SRFI-2) for Guile +;;;; written by Michael Livshin +;;;; +;;;; Copyright (C) 1999, 2001, 2004, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +(define-module (ice-9 and-let-star) + :export-syntax (and-let*)) + +(defmacro and-let* (vars . body) + + (define (expand vars body) + (cond + ((null? vars) + (if (null? body) + #t + `(begin ,@body))) + ((pair? vars) + (let ((exp (car vars))) + (cond + ((pair? exp) + (cond + ((null? (cdr exp)) + `(and ,(car exp) ,(expand (cdr vars) body))) + (else + (let ((var (car exp))) + `(let (,exp) + (and ,var ,(expand (cdr vars) body))))))) + (else + `(and ,exp ,(expand (cdr vars) body)))))) + (else + (error "not a proper list" vars)))) + + (expand vars body)) + +(cond-expand-provide (current-module) '(srfi-2)) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/boot-9.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/boot-9.scm new file mode 100755 index 0000000000000000000000000000000000000000..d1e6306c3621f91111b2e892db8a7364c9907777 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/boot-9.scm @@ -0,0 +1,3478 @@ +;;; installed-scm-file + +;;;; Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007 +;;;; Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; + + + +;;; Commentary: + +;;; This file is the first thing loaded into Guile. It adds many mundane +;;; definitions and a few that are interesting. +;;; +;;; The module system (hence the hierarchical namespace) are defined in this +;;; file. +;;; + +;;; Code: + + + +;;; {Features} +;;; + +(define (provide sym) + (if (not (memq sym *features*)) + (set! *features* (cons sym *features*)))) + +;; Return #t iff FEATURE is available to this Guile interpreter. In SLIB, +;; provided? also checks to see if the module is available. We should do that +;; too, but don't. + +(define (provided? feature) + (and (memq feature *features*) #t)) + +;; let format alias simple-format until the more complete version is loaded + +(define format simple-format) + +;; this is scheme wrapping the C code so the final pred call is a tail call, +;; per SRFI-13 spec +(define (string-any char_pred s . rest) + (let ((start (if (null? rest) + 0 (car rest))) + (end (if (or (null? rest) (null? (cdr rest))) + (string-length s) (cadr rest)))) + (if (and (procedure? char_pred) + (> end start) + (<= end (string-length s))) ;; let c-code handle range error + (or (string-any-c-code char_pred s start (1- end)) + (char_pred (string-ref s (1- end)))) + (string-any-c-code char_pred s start end)))) + +;; this is scheme wrapping the C code so the final pred call is a tail call, +;; per SRFI-13 spec +(define (string-every char_pred s . rest) + (let ((start (if (null? rest) + 0 (car rest))) + (end (if (or (null? rest) (null? (cdr rest))) + (string-length s) (cadr rest)))) + (if (and (procedure? char_pred) + (> end start) + (<= end (string-length s))) ;; let c-code handle range error + (and (string-every-c-code char_pred s start (1- end)) + (char_pred (string-ref s (1- end)))) + (string-every-c-code char_pred s start end)))) + +;; A variant of string-fill! that we keep for compatability +;; +(define (substring-fill! str start end fill) + (string-fill! str fill start end)) + + + +;;; {EVAL-CASE} +;;; + +;; (eval-case ((situation*) forms)* (else forms)?) +;; +;; Evaluate certain code based on the situation that eval-case is used +;; in. The only defined situation right now is `load-toplevel' which +;; triggers for code evaluated at the top-level, for example from the +;; REPL or when loading a file. + +(define eval-case + (procedure->memoizing-macro + (lambda (exp env) + (define (toplevel-env? env) + (or (not (pair? env)) (not (pair? (car env))))) + (define (syntax) + (error "syntax error in eval-case")) + (let loop ((clauses (cdr exp))) + (cond + ((null? clauses) + #f) + ((not (list? (car clauses))) + (syntax)) + ((eq? 'else (caar clauses)) + (or (null? (cdr clauses)) + (syntax)) + (cons 'begin (cdar clauses))) + ((not (list? (caar clauses))) + (syntax)) + ((and (toplevel-env? env) + (memq 'load-toplevel (caar clauses))) + (cons 'begin (cdar clauses))) + (else + (loop (cdr clauses)))))))) + + + +;;; {Defmacros} +;;; +;;; Depends on: features, eval-case +;;; + +(define macro-table (make-weak-key-hash-table 61)) +(define xformer-table (make-weak-key-hash-table 61)) + +(define (defmacro? m) (hashq-ref macro-table m)) +(define (assert-defmacro?! m) (hashq-set! macro-table m #t)) +(define (defmacro-transformer m) (hashq-ref xformer-table m)) +(define (set-defmacro-transformer! m t) (hashq-set! xformer-table m t)) + +(define defmacro:transformer + (lambda (f) + (let* ((xform (lambda (exp env) + (copy-tree (apply f (cdr exp))))) + (a (procedure->memoizing-macro xform))) + (assert-defmacro?! a) + (set-defmacro-transformer! a f) + a))) + + +(define defmacro + (let ((defmacro-transformer + (lambda (name parms . body) + (let ((transformer `(lambda ,parms ,@body))) + `(eval-case + ((load-toplevel) + (define ,name (defmacro:transformer ,transformer))) + (else + (error "defmacro can only be used at the top level"))))))) + (defmacro:transformer defmacro-transformer))) + +(define defmacro:syntax-transformer + (lambda (f) + (procedure->syntax + (lambda (exp env) + (copy-tree (apply f (cdr exp))))))) + + +;; XXX - should the definition of the car really be looked up in the +;; current module? + +(define (macroexpand-1 e) + (cond + ((pair? e) (let* ((a (car e)) + (val (and (symbol? a) (local-ref (list a))))) + (if (defmacro? val) + (apply (defmacro-transformer val) (cdr e)) + e))) + (#t e))) + +(define (macroexpand e) + (cond + ((pair? e) (let* ((a (car e)) + (val (and (symbol? a) (local-ref (list a))))) + (if (defmacro? val) + (macroexpand (apply (defmacro-transformer val) (cdr e))) + e))) + (#t e))) + +(provide 'defmacro) + + + +;;; {Deprecation} +;;; +;;; Depends on: defmacro +;;; + +(defmacro begin-deprecated forms + (if (include-deprecated-features) + (cons begin forms) + #f)) + + + +;;; {R4RS compliance} +;;; + +(primitive-load-path "ice-9/r4rs.scm") + + + +;;; {Simple Debugging Tools} +;;; + +;; peek takes any number of arguments, writes them to the +;; current ouput port, and returns the last argument. +;; It is handy to wrap around an expression to look at +;; a value each time is evaluated, e.g.: +;; +;; (+ 10 (troublesome-fn)) +;; => (+ 10 (pk 'troublesome-fn-returned (troublesome-fn))) +;; + +(define (peek . stuff) + (newline) + (display ";;; ") + (write stuff) + (newline) + (car (last-pair stuff))) + +(define pk peek) + +(define (warn . stuff) + (with-output-to-port (current-error-port) + (lambda () + (newline) + (display ";;; WARNING ") + (display stuff) + (newline) + (car (last-pair stuff))))) + + + +;;; {Trivial Functions} +;;; + +(define (identity x) x) +(define (and=> value procedure) (and value (procedure value))) +(define call/cc call-with-current-continuation) + +;;; apply-to-args is functionally redundant with apply and, worse, +;;; is less general than apply since it only takes two arguments. +;;; +;;; On the other hand, apply-to-args is a syntacticly convenient way to +;;; perform binding in many circumstances when the "let" family of +;;; of forms don't cut it. E.g.: +;;; +;;; (apply-to-args (return-3d-mouse-coords) +;;; (lambda (x y z) +;;; ...)) +;;; + +(define (apply-to-args args fn) (apply fn args)) + +(defmacro false-if-exception (expr) + `(catch #t (lambda () ,expr) + (lambda args #f))) + + + +;;; {General Properties} +;;; + +;; This is a more modern interface to properties. It will replace all +;; other property-like things eventually. + +(define (make-object-property) + (let ((prop (primitive-make-property #f))) + (make-procedure-with-setter + (lambda (obj) (primitive-property-ref prop obj)) + (lambda (obj val) (primitive-property-set! prop obj val))))) + + + +;;; {Symbol Properties} +;;; + +(define (symbol-property sym prop) + (let ((pair (assoc prop (symbol-pref sym)))) + (and pair (cdr pair)))) + +(define (set-symbol-property! sym prop val) + (let ((pair (assoc prop (symbol-pref sym)))) + (if pair + (set-cdr! pair val) + (symbol-pset! sym (acons prop val (symbol-pref sym)))))) + +(define (symbol-property-remove! sym prop) + (let ((pair (assoc prop (symbol-pref sym)))) + (if pair + (symbol-pset! sym (delq! pair (symbol-pref sym)))))) + + + +;;; {Arrays} +;;; + +(define (array-shape a) + (map (lambda (ind) (if (number? ind) (list 0 (+ -1 ind)) ind)) + (array-dimensions a))) + + + +;;; {Keywords} +;;; + +(define (kw-arg-ref args kw) + (let ((rem (member kw args))) + (and rem (pair? (cdr rem)) (cadr rem)))) + + + +;;; {Structs} +;;; + +(define (struct-layout s) + (struct-ref (struct-vtable s) vtable-index-layout)) + + + +;;; {Environments} +;;; + +(define the-environment + (procedure->syntax + (lambda (x e) + e))) + +(define the-root-environment (the-environment)) + +(define (environment-module env) + (let ((closure (and (pair? env) (car (last-pair env))))) + (and closure (procedure-property closure 'module)))) + + + +;;; {Records} +;;; + +;; Printing records: by default, records are printed as +;; +;; # +;; +;; You can change that by giving a custom printing function to +;; MAKE-RECORD-TYPE (after the list of field symbols). This function +;; will be called like +;; +;; ( object port) +;; +;; It should print OBJECT to PORT. + +(define (inherit-print-state old-port new-port) + (if (get-print-state old-port) + (port-with-print-state new-port (get-print-state old-port)) + new-port)) + +;; 0: type-name, 1: fields +(define record-type-vtable + (make-vtable-vtable "prpr" 0 + (lambda (s p) + (cond ((eq? s record-type-vtable) + (display "#" p)) + (else + (display "#" p)))))) + +(define (record-type? obj) + (and (struct? obj) (eq? record-type-vtable (struct-vtable obj)))) + +(define (make-record-type type-name fields . opt) + (let ((printer-fn (and (pair? opt) (car opt)))) + (let ((struct (make-struct record-type-vtable 0 + (make-struct-layout + (apply string-append + (map (lambda (f) "pw") fields))) + (or printer-fn + (lambda (s p) + (display "#<" p) + (display type-name p) + (let loop ((fields fields) + (off 0)) + (cond + ((not (null? fields)) + (display " " p) + (display (car fields) p) + (display ": " p) + (display (struct-ref s off) p) + (loop (cdr fields) (+ 1 off))))) + (display ">" p))) + type-name + (copy-tree fields)))) + ;; Temporary solution: Associate a name to the record type descriptor + ;; so that the object system can create a wrapper class for it. + (set-struct-vtable-name! struct (if (symbol? type-name) + type-name + (string->symbol type-name))) + struct))) + +(define (record-type-name obj) + (if (record-type? obj) + (struct-ref obj vtable-offset-user) + (error 'not-a-record-type obj))) + +(define (record-type-fields obj) + (if (record-type? obj) + (struct-ref obj (+ 1 vtable-offset-user)) + (error 'not-a-record-type obj))) + +(define (record-constructor rtd . opt) + (let ((field-names (if (pair? opt) (car opt) (record-type-fields rtd)))) + (local-eval `(lambda ,field-names + (make-struct ',rtd 0 ,@(map (lambda (f) + (if (memq f field-names) + f + #f)) + (record-type-fields rtd)))) + the-root-environment))) + +(define (record-predicate rtd) + (lambda (obj) (and (struct? obj) (eq? rtd (struct-vtable obj))))) + +(define (%record-type-error rtd obj) ;; private helper + (or (eq? rtd (record-type-descriptor obj)) + (scm-error 'wrong-type-arg "%record-type-check" + "Wrong type record (want `~S'): ~S" + (list (record-type-name rtd) obj) + #f))) + +(define (record-accessor rtd field-name) + (let* ((pos (list-index (record-type-fields rtd) field-name))) + (if (not pos) + (error 'no-such-field field-name)) + (local-eval `(lambda (obj) + (if (eq? (struct-vtable obj) ,rtd) + (struct-ref obj ,pos) + (%record-type-error ,rtd obj))) + the-root-environment))) + +(define (record-modifier rtd field-name) + (let* ((pos (list-index (record-type-fields rtd) field-name))) + (if (not pos) + (error 'no-such-field field-name)) + (local-eval `(lambda (obj val) + (if (eq? (struct-vtable obj) ,rtd) + (struct-set! obj ,pos val) + (%record-type-error ,rtd obj))) + the-root-environment))) + + +(define (record? obj) + (and (struct? obj) (record-type? (struct-vtable obj)))) + +(define (record-type-descriptor obj) + (if (struct? obj) + (struct-vtable obj) + (error 'not-a-record obj))) + +(provide 'record) + + + +;;; {Booleans} +;;; + +(define (->bool x) (not (not x))) + + + +;;; {Symbols} +;;; + +(define (symbol-append . args) + (string->symbol (apply string-append (map symbol->string args)))) + +(define (list->symbol . args) + (string->symbol (apply list->string args))) + +(define (symbol . args) + (string->symbol (apply string args))) + + + +;;; {Lists} +;;; + +(define (list-index l k) + (let loop ((n 0) + (l l)) + (and (not (null? l)) + (if (eq? (car l) k) + n + (loop (+ n 1) (cdr l)))))) + + + +;;; {and-map and or-map} +;;; +;;; (and-map fn lst) is like (and (fn (car lst)) (fn (cadr lst)) (fn...) ...) +;;; (or-map fn lst) is like (or (fn (car lst)) (fn (cadr lst)) (fn...) ...) +;;; + +;; and-map f l +;; +;; Apply f to successive elements of l until exhaustion or f returns #f. +;; If returning early, return #f. Otherwise, return the last value returned +;; by f. If f has never been called because l is empty, return #t. +;; +(define (and-map f lst) + (let loop ((result #t) + (l lst)) + (and result + (or (and (null? l) + result) + (loop (f (car l)) (cdr l)))))) + +;; or-map f l +;; +;; Apply f to successive elements of l until exhaustion or while f returns #f. +;; If returning early, return the return value of f. +;; +(define (or-map f lst) + (let loop ((result #f) + (l lst)) + (or result + (and (not (null? l)) + (loop (f (car l)) (cdr l)))))) + + + +(if (provided? 'posix) + (primitive-load-path "ice-9/posix.scm")) + +(if (provided? 'socket) + (primitive-load-path "ice-9/networking.scm")) + +;; For reference, Emacs file-exists-p uses stat in this same way. +;; ENHANCE-ME: Catching an exception from stat is a bit wasteful, do this in +;; C where all that's needed is to inspect the return from stat(). +(define file-exists? + (if (provided? 'posix) + (lambda (str) + (->bool (false-if-exception (stat str)))) + (lambda (str) + (let ((port (catch 'system-error (lambda () (open-file str OPEN_READ)) + (lambda args #f)))) + (if port (begin (close-port port) #t) + #f))))) + +(define file-is-directory? + (if (provided? 'posix) + (lambda (str) + (eq? (stat:type (stat str)) 'directory)) + (lambda (str) + (let ((port (catch 'system-error + (lambda () (open-file (string-append str "/.") + OPEN_READ)) + (lambda args #f)))) + (if port (begin (close-port port) #t) + #f))))) + +(define (has-suffix? str suffix) + (let ((sufl (string-length suffix)) + (sl (string-length str))) + (and (> sl sufl) + (string=? (substring str (- sl sufl) sl) suffix)))) + +(define (system-error-errno args) + (if (eq? (car args) 'system-error) + (car (list-ref args 4)) + #f)) + + + +;;; {Error Handling} +;;; + +(define (error . args) + (save-stack) + (if (null? args) + (scm-error 'misc-error #f "?" #f #f) + (let loop ((msg "~A") + (rest (cdr args))) + (if (not (null? rest)) + (loop (string-append msg " ~S") + (cdr rest)) + (scm-error 'misc-error #f msg args #f))))) + +;; bad-throw is the hook that is called upon a throw to a an unhandled +;; key (unless the throw has four arguments, in which case +;; it's usually interpreted as an error throw.) +;; If the key has a default handler (a throw-handler-default property), +;; it is applied to the throw. +;; +(define (bad-throw key . args) + (let ((default (symbol-property key 'throw-handler-default))) + (or (and default (apply default key args)) + (apply error "unhandled-exception:" key args)))) + + + +(define (tm:sec obj) (vector-ref obj 0)) +(define (tm:min obj) (vector-ref obj 1)) +(define (tm:hour obj) (vector-ref obj 2)) +(define (tm:mday obj) (vector-ref obj 3)) +(define (tm:mon obj) (vector-ref obj 4)) +(define (tm:year obj) (vector-ref obj 5)) +(define (tm:wday obj) (vector-ref obj 6)) +(define (tm:yday obj) (vector-ref obj 7)) +(define (tm:isdst obj) (vector-ref obj 8)) +(define (tm:gmtoff obj) (vector-ref obj 9)) +(define (tm:zone obj) (vector-ref obj 10)) + +(define (set-tm:sec obj val) (vector-set! obj 0 val)) +(define (set-tm:min obj val) (vector-set! obj 1 val)) +(define (set-tm:hour obj val) (vector-set! obj 2 val)) +(define (set-tm:mday obj val) (vector-set! obj 3 val)) +(define (set-tm:mon obj val) (vector-set! obj 4 val)) +(define (set-tm:year obj val) (vector-set! obj 5 val)) +(define (set-tm:wday obj val) (vector-set! obj 6 val)) +(define (set-tm:yday obj val) (vector-set! obj 7 val)) +(define (set-tm:isdst obj val) (vector-set! obj 8 val)) +(define (set-tm:gmtoff obj val) (vector-set! obj 9 val)) +(define (set-tm:zone obj val) (vector-set! obj 10 val)) + +(define (tms:clock obj) (vector-ref obj 0)) +(define (tms:utime obj) (vector-ref obj 1)) +(define (tms:stime obj) (vector-ref obj 2)) +(define (tms:cutime obj) (vector-ref obj 3)) +(define (tms:cstime obj) (vector-ref obj 4)) + +(define file-position ftell) +(define (file-set-position port offset . whence) + (let ((whence (if (eq? whence '()) SEEK_SET (car whence)))) + (seek port offset whence))) + +(define (move->fdes fd/port fd) + (cond ((integer? fd/port) + (dup->fdes fd/port fd) + (close fd/port) + fd) + (else + (primitive-move->fdes fd/port fd) + (set-port-revealed! fd/port 1) + fd/port))) + +(define (release-port-handle port) + (let ((revealed (port-revealed port))) + (if (> revealed 0) + (set-port-revealed! port (- revealed 1))))) + +(define (dup->port port/fd mode . maybe-fd) + (let ((port (fdopen (apply dup->fdes port/fd maybe-fd) + mode))) + (if (pair? maybe-fd) + (set-port-revealed! port 1)) + port)) + +(define (dup->inport port/fd . maybe-fd) + (apply dup->port port/fd "r" maybe-fd)) + +(define (dup->outport port/fd . maybe-fd) + (apply dup->port port/fd "w" maybe-fd)) + +(define (dup port/fd . maybe-fd) + (if (integer? port/fd) + (apply dup->fdes port/fd maybe-fd) + (apply dup->port port/fd (port-mode port/fd) maybe-fd))) + +(define (duplicate-port port modes) + (dup->port port modes)) + +(define (fdes->inport fdes) + (let loop ((rest-ports (fdes->ports fdes))) + (cond ((null? rest-ports) + (let ((result (fdopen fdes "r"))) + (set-port-revealed! result 1) + result)) + ((input-port? (car rest-ports)) + (set-port-revealed! (car rest-ports) + (+ (port-revealed (car rest-ports)) 1)) + (car rest-ports)) + (else + (loop (cdr rest-ports)))))) + +(define (fdes->outport fdes) + (let loop ((rest-ports (fdes->ports fdes))) + (cond ((null? rest-ports) + (let ((result (fdopen fdes "w"))) + (set-port-revealed! result 1) + result)) + ((output-port? (car rest-ports)) + (set-port-revealed! (car rest-ports) + (+ (port-revealed (car rest-ports)) 1)) + (car rest-ports)) + (else + (loop (cdr rest-ports)))))) + +(define (port->fdes port) + (set-port-revealed! port (+ (port-revealed port) 1)) + (fileno port)) + +(define (setenv name value) + (if value + (putenv (string-append name "=" value)) + (putenv name))) + +(define (unsetenv name) + "Remove the entry for NAME from the environment." + (putenv name)) + + + +;;; {Load Paths} +;;; + +;;; Here for backward compatability +;; +(define scheme-file-suffix (lambda () ".scm")) + +(define (in-vicinity vicinity file) + (let ((tail (let ((len (string-length vicinity))) + (if (zero? len) + #f + (string-ref vicinity (- len 1)))))) + (string-append vicinity + (if (or (not tail) + (eq? tail #\/)) + "" + "/") + file))) + + + +;;; {Help for scm_shell} +;;; +;;; The argument-processing code used by Guile-based shells generates +;;; Scheme code based on the argument list. This page contains help +;;; functions for the code it generates. +;;; + +(define (command-line) (program-arguments)) + +;; This is mostly for the internal use of the code generated by +;; scm_compile_shell_switches. + +(define (turn-on-debugging) + (debug-enable 'debug) + (debug-enable 'backtrace) + (read-enable 'positions)) + +(define (load-user-init) + (let* ((home (or (getenv "HOME") + (false-if-exception (passwd:dir (getpwuid (getuid)))) + "/")) ;; fallback for cygwin etc. + (init-file (in-vicinity home ".guile"))) + (if (file-exists? init-file) + (primitive-load init-file)))) + + + +;;; {Loading by paths} +;;; + +;;; Load a Scheme source file named NAME, searching for it in the +;;; directories listed in %load-path, and applying each of the file +;;; name extensions listed in %load-extensions. +(define (load-from-path name) + (start-stack 'load-stack + (primitive-load-path name))) + + + + +;;; {Transcendental Functions} +;;; +;;; Derived from "Transcen.scm", Complex trancendental functions for SCM. +;;; Written by Jerry D. Hedden, (C) FSF. +;;; See the file `COPYING' for terms applying to this program. +;;; + +(define expt + (let ((integer-expt integer-expt)) + (lambda (z1 z2) + (cond ((and (exact? z2) (integer? z2)) + (integer-expt z1 z2)) + ((and (real? z2) (real? z1) (>= z1 0)) + ($expt z1 z2)) + (else + (exp (* z2 (log z1)))))))) + +(define (sinh z) + (if (real? z) ($sinh z) + (let ((x (real-part z)) (y (imag-part z))) + (make-rectangular (* ($sinh x) ($cos y)) + (* ($cosh x) ($sin y)))))) +(define (cosh z) + (if (real? z) ($cosh z) + (let ((x (real-part z)) (y (imag-part z))) + (make-rectangular (* ($cosh x) ($cos y)) + (* ($sinh x) ($sin y)))))) +(define (tanh z) + (if (real? z) ($tanh z) + (let* ((x (* 2 (real-part z))) + (y (* 2 (imag-part z))) + (w (+ ($cosh x) ($cos y)))) + (make-rectangular (/ ($sinh x) w) (/ ($sin y) w))))) + +(define (asinh z) + (if (real? z) ($asinh z) + (log (+ z (sqrt (+ (* z z) 1)))))) + +(define (acosh z) + (if (and (real? z) (>= z 1)) + ($acosh z) + (log (+ z (sqrt (- (* z z) 1)))))) + +(define (atanh z) + (if (and (real? z) (> z -1) (< z 1)) + ($atanh z) + (/ (log (/ (+ 1 z) (- 1 z))) 2))) + +(define (sin z) + (if (real? z) ($sin z) + (let ((x (real-part z)) (y (imag-part z))) + (make-rectangular (* ($sin x) ($cosh y)) + (* ($cos x) ($sinh y)))))) +(define (cos z) + (if (real? z) ($cos z) + (let ((x (real-part z)) (y (imag-part z))) + (make-rectangular (* ($cos x) ($cosh y)) + (- (* ($sin x) ($sinh y))))))) +(define (tan z) + (if (real? z) ($tan z) + (let* ((x (* 2 (real-part z))) + (y (* 2 (imag-part z))) + (w (+ ($cos x) ($cosh y)))) + (make-rectangular (/ ($sin x) w) (/ ($sinh y) w))))) + +(define (asin z) + (if (and (real? z) (>= z -1) (<= z 1)) + ($asin z) + (* -i (asinh (* +i z))))) + +(define (acos z) + (if (and (real? z) (>= z -1) (<= z 1)) + ($acos z) + (+ (/ (angle -1) 2) (* +i (asinh (* +i z)))))) + +(define (atan z . y) + (if (null? y) + (if (real? z) ($atan z) + (/ (log (/ (- +i z) (+ +i z))) +2i)) + ($atan2 z (car y)))) + + + +;;; {Reader Extensions} +;;; +;;; Reader code for various "#c" forms. +;;; + +(read-hash-extend #\' (lambda (c port) + (read port))) + +(define read-eval? (make-fluid)) +(fluid-set! read-eval? #f) +(read-hash-extend #\. + (lambda (c port) + (if (fluid-ref read-eval?) + (eval (read port) (interaction-environment)) + (error + "#. read expansion found and read-eval? is #f.")))) + + + +;;; {Command Line Options} +;;; + +(define (get-option argv kw-opts kw-args return) + (cond + ((null? argv) + (return #f #f argv)) + + ((or (not (eq? #\- (string-ref (car argv) 0))) + (eq? (string-length (car argv)) 1)) + (return 'normal-arg (car argv) (cdr argv))) + + ((eq? #\- (string-ref (car argv) 1)) + (let* ((kw-arg-pos (or (string-index (car argv) #\=) + (string-length (car argv)))) + (kw (symbol->keyword (substring (car argv) 2 kw-arg-pos))) + (kw-opt? (member kw kw-opts)) + (kw-arg? (member kw kw-args)) + (arg (or (and (not (eq? kw-arg-pos (string-length (car argv)))) + (substring (car argv) + (+ kw-arg-pos 1) + (string-length (car argv)))) + (and kw-arg? + (begin (set! argv (cdr argv)) (car argv)))))) + (if (or kw-opt? kw-arg?) + (return kw arg (cdr argv)) + (return 'usage-error kw (cdr argv))))) + + (else + (let* ((char (substring (car argv) 1 2)) + (kw (symbol->keyword char))) + (cond + + ((member kw kw-opts) + (let* ((rest-car (substring (car argv) 2 (string-length (car argv)))) + (new-argv (if (= 0 (string-length rest-car)) + (cdr argv) + (cons (string-append "-" rest-car) (cdr argv))))) + (return kw #f new-argv))) + + ((member kw kw-args) + (let* ((rest-car (substring (car argv) 2 (string-length (car argv)))) + (arg (if (= 0 (string-length rest-car)) + (cadr argv) + rest-car)) + (new-argv (if (= 0 (string-length rest-car)) + (cddr argv) + (cdr argv)))) + (return kw arg new-argv))) + + (else (return 'usage-error kw argv))))))) + +(define (for-next-option proc argv kw-opts kw-args) + (let loop ((argv argv)) + (get-option argv kw-opts kw-args + (lambda (opt opt-arg argv) + (and opt (proc opt opt-arg argv loop)))))) + +(define (display-usage-report kw-desc) + (for-each + (lambda (kw) + (or (eq? (car kw) #t) + (eq? (car kw) 'else) + (let* ((opt-desc kw) + (help (cadr opt-desc)) + (opts (car opt-desc)) + (opts-proper (if (string? (car opts)) (cdr opts) opts)) + (arg-name (if (string? (car opts)) + (string-append "<" (car opts) ">") + "")) + (left-part (string-append + (with-output-to-string + (lambda () + (map (lambda (x) (display (keyword->symbol x)) (display " ")) + opts-proper))) + arg-name)) + (middle-part (if (and (< (string-length left-part) 30) + (< (string-length help) 40)) + (make-string (- 30 (string-length left-part)) #\ ) + "\n\t"))) + (display left-part) + (display middle-part) + (display help) + (newline)))) + kw-desc)) + + + +(define (transform-usage-lambda cases) + (let* ((raw-usage (delq! 'else (map car cases))) + (usage-sans-specials (map (lambda (x) + (or (and (not (list? x)) x) + (and (symbol? (car x)) #t) + (and (boolean? (car x)) #t) + x)) + raw-usage)) + (usage-desc (delq! #t usage-sans-specials)) + (kw-desc (map car usage-desc)) + (kw-opts (apply append (map (lambda (x) (and (not (string? (car x))) x)) kw-desc))) + (kw-args (apply append (map (lambda (x) (and (string? (car x)) (cdr x))) kw-desc))) + (transmogrified-cases (map (lambda (case) + (cons (let ((opts (car case))) + (if (or (boolean? opts) (eq? 'else opts)) + opts + (cond + ((symbol? (car opts)) opts) + ((boolean? (car opts)) opts) + ((string? (caar opts)) (cdar opts)) + (else (car opts))))) + (cdr case))) + cases))) + `(let ((%display-usage (lambda () (display-usage-report ',usage-desc)))) + (lambda (%argv) + (let %next-arg ((%argv %argv)) + (get-option %argv + ',kw-opts + ',kw-args + (lambda (%opt %arg %new-argv) + (case %opt + ,@ transmogrified-cases)))))))) + + + + +;;; {Low Level Modules} +;;; +;;; These are the low level data structures for modules. +;;; +;;; Every module object is of the type 'module-type', which is a record +;;; consisting of the following members: +;;; +;;; - eval-closure: the function that defines for its module the strategy that +;;; shall be followed when looking up symbols in the module. +;;; +;;; An eval-closure is a function taking two arguments: the symbol to be +;;; looked up and a boolean value telling whether a binding for the symbol +;;; should be created if it does not exist yet. If the symbol lookup +;;; succeeded (either because an existing binding was found or because a new +;;; binding was created), a variable object representing the binding is +;;; returned. Otherwise, the value #f is returned. Note that the eval +;;; closure does not take the module to be searched as an argument: During +;;; construction of the eval-closure, the eval-closure has to store the +;;; module it belongs to in its environment. This means, that any +;;; eval-closure can belong to only one module. +;;; +;;; The eval-closure of a module can be defined arbitrarily. However, three +;;; special cases of eval-closures are to be distinguished: During startup +;;; the module system is not yet activated. In this phase, no modules are +;;; defined and all bindings are automatically stored by the system in the +;;; pre-modules-obarray. Since no eval-closures exist at this time, the +;;; functions which require an eval-closure as their argument need to be +;;; passed the value #f. +;;; +;;; The other two special cases of eval-closures are the +;;; standard-eval-closure and the standard-interface-eval-closure. Both +;;; behave equally for the case that no new binding is to be created. The +;;; difference between the two comes in, when the boolean argument to the +;;; eval-closure indicates that a new binding shall be created if it is not +;;; found. +;;; +;;; Given that no new binding shall be created, both standard eval-closures +;;; define the following standard strategy of searching bindings in the +;;; module: First, the module's obarray is searched for the symbol. Second, +;;; if no binding for the symbol was found in the module's obarray, the +;;; module's binder procedure is exececuted. If this procedure did not +;;; return a binding for the symbol, the modules referenced in the module's +;;; uses list are recursively searched for a binding of the symbol. If the +;;; binding can not be found in these modules also, the symbol lookup has +;;; failed. +;;; +;;; If a new binding shall be created, the standard-interface-eval-closure +;;; immediately returns indicating failure. That is, it does not even try +;;; to look up the symbol. In contrast, the standard-eval-closure would +;;; first search the obarray, and if no binding was found there, would +;;; create a new binding in the obarray, therefore not calling the binder +;;; procedure or searching the modules in the uses list. +;;; +;;; The explanation of the following members obarray, binder and uses +;;; assumes that the symbol lookup follows the strategy that is defined in +;;; the standard-eval-closure and the standard-interface-eval-closure. +;;; +;;; - obarray: a hash table that maps symbols to variable objects. In this +;;; hash table, the definitions are found that are local to the module (that +;;; is, not imported from other modules). When looking up bindings in the +;;; module, this hash table is searched first. +;;; +;;; - binder: either #f or a function taking a module and a symbol argument. +;;; If it is a function it is called after the obarray has been +;;; unsuccessfully searched for a binding. It then can provide bindings +;;; that would otherwise not be found locally in the module. +;;; +;;; - uses: a list of modules from which non-local bindings can be inherited. +;;; These modules are the third place queried for bindings after the obarray +;;; has been unsuccessfully searched and the binder function did not deliver +;;; a result either. +;;; +;;; - transformer: either #f or a function taking a scheme expression as +;;; delivered by read. If it is a function, it will be called to perform +;;; syntax transformations (e. g. makro expansion) on the given scheme +;;; expression. The output of the transformer function will then be passed +;;; to Guile's internal memoizer. This means that the output must be valid +;;; scheme code. The only exception is, that the output may make use of the +;;; syntax extensions provided to identify the modules that a binding +;;; belongs to. +;;; +;;; - name: the name of the module. This is used for all kinds of printing +;;; outputs. In certain places the module name also serves as a way of +;;; identification. When adding a module to the uses list of another +;;; module, it is made sure that the new uses list will not contain two +;;; modules of the same name. +;;; +;;; - kind: classification of the kind of module. The value is (currently?) +;;; only used for printing. It has no influence on how a module is treated. +;;; Currently the following values are used when setting the module kind: +;;; 'module, 'directory, 'interface, 'custom-interface. If no explicit kind +;;; is set, it defaults to 'module. +;;; +;;; - duplicates-handlers +;;; +;;; - duplicates-interface +;;; +;;; - observers +;;; +;;; - weak-observers +;;; +;;; - observer-id +;;; +;;; In addition, the module may (must?) contain a binding for +;;; %module-public-interface... More explanations here... +;;; +;;; !!! warning: The interface to lazy binder procedures is going +;;; to be changed in an incompatible way to permit all the basic +;;; module ops to be virtualized. +;;; +;;; (make-module size use-list lazy-binding-proc) => module +;;; module-{obarray,uses,binder}[|-set!] +;;; (module? obj) => [#t|#f] +;;; (module-locally-bound? module symbol) => [#t|#f] +;;; (module-bound? module symbol) => [#t|#f] +;;; (module-symbol-locally-interned? module symbol) => [#t|#f] +;;; (module-symbol-interned? module symbol) => [#t|#f] +;;; (module-local-variable module symbol) => [# | #f] +;;; (module-variable module symbol) => [# | #f] +;;; (module-symbol-binding module symbol opt-value) +;;; => [ | opt-value | an error occurs ] +;;; (module-make-local-var! module symbol) => # +;;; (module-add! module symbol var) => unspecified +;;; (module-remove! module symbol) => unspecified +;;; (module-for-each proc module) => unspecified +;;; (make-scm-module) => module ; a lazy copy of the symhash module +;;; (set-current-module module) => unspecified +;;; (current-module) => # +;;; +;;; + + + +;;; {Printing Modules} +;;; + +;; This is how modules are printed. You can re-define it. +;; (Redefining is actually more complicated than simply redefining +;; %print-module because that would only change the binding and not +;; the value stored in the vtable that determines how record are +;; printed. Sigh.) + +(define (%print-module mod port) ; unused args: depth length style table) + (display "#<" port) + (display (or (module-kind mod) "module") port) + (let ((name (module-name mod))) + (if name + (begin + (display " " port) + (display name port)))) + (display " " port) + (display (number->string (object-address mod) 16) port) + (display ">" port)) + +;; module-type +;; +;; A module is characterized by an obarray in which local symbols +;; are interned, a list of modules, "uses", from which non-local +;; bindings can be inherited, and an optional lazy-binder which +;; is a (CLOSURE module symbol) which, as a last resort, can provide +;; bindings that would otherwise not be found locally in the module. +;; +;; NOTE: If you change anything here, you also need to change +;; libguile/modules.h. +;; +(define module-type + (make-record-type 'module + '(obarray uses binder eval-closure transformer name kind + duplicates-handlers duplicates-interface + observers weak-observers observer-id) + %print-module)) + +;; make-module &opt size uses binder +;; +;; Create a new module, perhaps with a particular size of obarray, +;; initial uses list, or binding procedure. +;; +(define make-module + (lambda args + + (define (parse-arg index default) + (if (> (length args) index) + (list-ref args index) + default)) + + (if (> (length args) 3) + (error "Too many args to make-module." args)) + + (let ((size (parse-arg 0 31)) + (uses (parse-arg 1 '())) + (binder (parse-arg 2 #f))) + + (if (not (integer? size)) + (error "Illegal size to make-module." size)) + (if (not (and (list? uses) + (and-map module? uses))) + (error "Incorrect use list." uses)) + (if (and binder (not (procedure? binder))) + (error + "Lazy-binder expected to be a procedure or #f." binder)) + + (let ((module (module-constructor (make-hash-table size) + uses binder #f #f #f #f #f #f + '() + (make-weak-value-hash-table 31) + 0))) + + ;; We can't pass this as an argument to module-constructor, + ;; because we need it to close over a pointer to the module + ;; itself. + (set-module-eval-closure! module (standard-eval-closure module)) + + module)))) + +(define module-constructor (record-constructor module-type)) +(define module-obarray (record-accessor module-type 'obarray)) +(define set-module-obarray! (record-modifier module-type 'obarray)) +(define module-uses (record-accessor module-type 'uses)) +(define set-module-uses! (record-modifier module-type 'uses)) +(define module-binder (record-accessor module-type 'binder)) +(define set-module-binder! (record-modifier module-type 'binder)) + +;; NOTE: This binding is used in libguile/modules.c. +(define module-eval-closure (record-accessor module-type 'eval-closure)) + +(define module-transformer (record-accessor module-type 'transformer)) +(define set-module-transformer! (record-modifier module-type 'transformer)) +(define module-name (record-accessor module-type 'name)) +(define set-module-name! (record-modifier module-type 'name)) +(define module-kind (record-accessor module-type 'kind)) +(define set-module-kind! (record-modifier module-type 'kind)) +(define module-duplicates-handlers + (record-accessor module-type 'duplicates-handlers)) +(define set-module-duplicates-handlers! + (record-modifier module-type 'duplicates-handlers)) +(define module-duplicates-interface + (record-accessor module-type 'duplicates-interface)) +(define set-module-duplicates-interface! + (record-modifier module-type 'duplicates-interface)) +(define module-observers (record-accessor module-type 'observers)) +(define set-module-observers! (record-modifier module-type 'observers)) +(define module-weak-observers (record-accessor module-type 'weak-observers)) +(define module-observer-id (record-accessor module-type 'observer-id)) +(define set-module-observer-id! (record-modifier module-type 'observer-id)) +(define module? (record-predicate module-type)) + +(define set-module-eval-closure! + (let ((setter (record-modifier module-type 'eval-closure))) + (lambda (module closure) + (setter module closure) + ;; Make it possible to lookup the module from the environment. + ;; This implementation is correct since an eval closure can belong + ;; to maximally one module. + (set-procedure-property! closure 'module module)))) + + + +;;; {Observer protocol} +;;; + +(define (module-observe module proc) + (set-module-observers! module (cons proc (module-observers module))) + (cons module proc)) + +(define (module-observe-weak module proc) + (let ((id (module-observer-id module))) + (hash-set! (module-weak-observers module) id proc) + (set-module-observer-id! module (+ 1 id)) + (cons module id))) + +(define (module-unobserve token) + (let ((module (car token)) + (id (cdr token))) + (if (integer? id) + (hash-remove! (module-weak-observers module) id) + (set-module-observers! module (delq1! id (module-observers module))))) + *unspecified*) + +(define module-defer-observers #f) +(define module-defer-observers-mutex (make-mutex)) +(define module-defer-observers-table (make-hash-table)) + +(define (module-modified m) + (if module-defer-observers + (hash-set! module-defer-observers-table m #t) + (module-call-observers m))) + +;;; This function can be used to delay calls to observers so that they +;;; can be called once only in the face of massive updating of modules. +;;; +(define (call-with-deferred-observers thunk) + (dynamic-wind + (lambda () + (lock-mutex module-defer-observers-mutex) + (set! module-defer-observers #t)) + thunk + (lambda () + (set! module-defer-observers #f) + (hash-for-each (lambda (m dummy) + (module-call-observers m)) + module-defer-observers-table) + (hash-clear! module-defer-observers-table) + (unlock-mutex module-defer-observers-mutex)))) + +(define (module-call-observers m) + (for-each (lambda (proc) (proc m)) (module-observers m)) + (hash-fold (lambda (id proc res) (proc m)) #f (module-weak-observers m))) + + + +;;; {Module Searching in General} +;;; +;;; We sometimes want to look for properties of a symbol +;;; just within the obarray of one module. If the property +;;; holds, then it is said to hold ``locally'' as in, ``The symbol +;;; DISPLAY is locally rebound in the module `safe-guile'.'' +;;; +;;; +;;; Other times, we want to test for a symbol property in the obarray +;;; of M and, if it is not found there, try each of the modules in the +;;; uses list of M. This is the normal way of testing for some +;;; property, so we state these properties without qualification as +;;; in: ``The symbol 'fnord is interned in module M because it is +;;; interned locally in module M2 which is a member of the uses list +;;; of M.'' +;;; + +;; module-search fn m +;; +;; return the first non-#f result of FN applied to M and then to +;; the modules in the uses of m, and so on recursively. If all applications +;; return #f, then so does this function. +;; +(define (module-search fn m v) + (define (loop pos) + (and (pair? pos) + (or (module-search fn (car pos) v) + (loop (cdr pos))))) + (or (fn m v) + (loop (module-uses m)))) + + +;;; {Is a symbol bound in a module?} +;;; +;;; Symbol S in Module M is bound if S is interned in M and if the binding +;;; of S in M has been set to some well-defined value. +;;; + +;; module-locally-bound? module symbol +;; +;; Is a symbol bound (interned and defined) locally in a given module? +;; +(define (module-locally-bound? m v) + (let ((var (module-local-variable m v))) + (and var + (variable-bound? var)))) + +;; module-bound? module symbol +;; +;; Is a symbol bound (interned and defined) anywhere in a given module +;; or its uses? +;; +(define (module-bound? m v) + (module-search module-locally-bound? m v)) + +;;; {Is a symbol interned in a module?} +;;; +;;; Symbol S in Module M is interned if S occurs in +;;; of S in M has been set to some well-defined value. +;;; +;;; It is possible to intern a symbol in a module without providing +;;; an initial binding for the corresponding variable. This is done +;;; with: +;;; (module-add! module symbol (make-undefined-variable)) +;;; +;;; In that case, the symbol is interned in the module, but not +;;; bound there. The unbound symbol shadows any binding for that +;;; symbol that might otherwise be inherited from a member of the uses list. +;;; + +(define (module-obarray-get-handle ob key) + ((if (symbol? key) hashq-get-handle hash-get-handle) ob key)) + +(define (module-obarray-ref ob key) + ((if (symbol? key) hashq-ref hash-ref) ob key)) + +(define (module-obarray-set! ob key val) + ((if (symbol? key) hashq-set! hash-set!) ob key val)) + +(define (module-obarray-remove! ob key) + ((if (symbol? key) hashq-remove! hash-remove!) ob key)) + +;; module-symbol-locally-interned? module symbol +;; +;; is a symbol interned (not neccessarily defined) locally in a given module +;; or its uses? Interned symbols shadow inherited bindings even if +;; they are not themselves bound to a defined value. +;; +(define (module-symbol-locally-interned? m v) + (not (not (module-obarray-get-handle (module-obarray m) v)))) + +;; module-symbol-interned? module symbol +;; +;; is a symbol interned (not neccessarily defined) anywhere in a given module +;; or its uses? Interned symbols shadow inherited bindings even if +;; they are not themselves bound to a defined value. +;; +(define (module-symbol-interned? m v) + (module-search module-symbol-locally-interned? m v)) + + +;;; {Mapping modules x symbols --> variables} +;;; + +;; module-local-variable module symbol +;; return the local variable associated with a MODULE and SYMBOL. +;; +;;; This function is very important. It is the only function that can +;;; return a variable from a module other than the mutators that store +;;; new variables in modules. Therefore, this function is the location +;;; of the "lazy binder" hack. +;;; +;;; If symbol is defined in MODULE, and if the definition binds symbol +;;; to a variable, return that variable object. +;;; +;;; If the symbols is not found at first, but the module has a lazy binder, +;;; then try the binder. +;;; +;;; If the symbol is not found at all, return #f. +;;; +(define (module-local-variable m v) +; (caddr +; (list m v + (let ((b (module-obarray-ref (module-obarray m) v))) + (or (and (variable? b) b) + (and (module-binder m) + ((module-binder m) m v #f))))) +;)) + +;; module-variable module symbol +;; +;; like module-local-variable, except search the uses in the +;; case V is not found in M. +;; +;; NOTE: This function is superseded with C code (see modules.c) +;;; when using the standard eval closure. +;; +(define (module-variable m v) + (module-search module-local-variable m v)) + + +;;; {Mapping modules x symbols --> bindings} +;;; +;;; These are similar to the mapping to variables, except that the +;;; variable is dereferenced. +;;; + +;; module-symbol-binding module symbol opt-value +;; +;; return the binding of a variable specified by name within +;; a given module, signalling an error if the variable is unbound. +;; If the OPT-VALUE is passed, then instead of signalling an error, +;; return OPT-VALUE. +;; +(define (module-symbol-local-binding m v . opt-val) + (let ((var (module-local-variable m v))) + (if (and var (variable-bound? var)) + (variable-ref var) + (if (not (null? opt-val)) + (car opt-val) + (error "Locally unbound variable." v))))) + +;; module-symbol-binding module symbol opt-value +;; +;; return the binding of a variable specified by name within +;; a given module, signalling an error if the variable is unbound. +;; If the OPT-VALUE is passed, then instead of signalling an error, +;; return OPT-VALUE. +;; +(define (module-symbol-binding m v . opt-val) + (let ((var (module-variable m v))) + (if (and var (variable-bound? var)) + (variable-ref var) + (if (not (null? opt-val)) + (car opt-val) + (error "Unbound variable." v))))) + + + + +;;; {Adding Variables to Modules} +;;; + +;; module-make-local-var! module symbol +;; +;; ensure a variable for V in the local namespace of M. +;; If no variable was already there, then create a new and uninitialzied +;; variable. +;; +;; This function is used in modules.c. +;; +(define (module-make-local-var! m v) + (or (let ((b (module-obarray-ref (module-obarray m) v))) + (and (variable? b) + (begin + ;; Mark as modified since this function is called when + ;; the standard eval closure defines a binding + (module-modified m) + b))) + + ;; Create a new local variable. + (let ((local-var (make-undefined-variable))) + (module-add! m v local-var) + local-var))) + +;; module-ensure-local-variable! module symbol +;; +;; Ensure that there is a local variable in MODULE for SYMBOL. If +;; there is no binding for SYMBOL, create a new uninitialized +;; variable. Return the local variable. +;; +(define (module-ensure-local-variable! module symbol) + (or (module-local-variable module symbol) + (let ((var (make-undefined-variable))) + (module-add! module symbol var) + var))) + +;; module-add! module symbol var +;; +;; ensure a particular variable for V in the local namespace of M. +;; +(define (module-add! m v var) + (if (not (variable? var)) + (error "Bad variable to module-add!" var)) + (module-obarray-set! (module-obarray m) v var) + (module-modified m)) + +;; module-remove! +;; +;; make sure that a symbol is undefined in the local namespace of M. +;; +(define (module-remove! m v) + (module-obarray-remove! (module-obarray m) v) + (module-modified m)) + +(define (module-clear! m) + (hash-clear! (module-obarray m)) + (module-modified m)) + +;; MODULE-FOR-EACH -- exported +;; +;; Call PROC on each symbol in MODULE, with arguments of (SYMBOL VARIABLE). +;; +(define (module-for-each proc module) + (hash-for-each proc (module-obarray module))) + +(define (module-map proc module) + (hash-map->list proc (module-obarray module))) + + + +;;; {Low Level Bootstrapping} +;;; + +;; make-root-module + +;; A root module uses the pre-modules-obarray as its obarray. This +;; special obarray accumulates all bindings that have been established +;; before the module system is fully booted. +;; +;; (The obarray continues to be used by code that has been closed over +;; before the module system has been booted.) + +(define (make-root-module) + (let ((m (make-module 0))) + (set-module-obarray! m (%get-pre-modules-obarray)) + m)) + +;; make-scm-module + +;; The root interface is a module that uses the same obarray as the +;; root module. It does not allow new definitions, tho. + +(define (make-scm-module) + (let ((m (make-module 0))) + (set-module-obarray! m (%get-pre-modules-obarray)) + (set-module-eval-closure! m (standard-interface-eval-closure m)) + m)) + + + + +;;; {Module-based Loading} +;;; + +(define (save-module-excursion thunk) + (let ((inner-module (current-module)) + (outer-module #f)) + (dynamic-wind (lambda () + (set! outer-module (current-module)) + (set-current-module inner-module) + (set! inner-module #f)) + thunk + (lambda () + (set! inner-module (current-module)) + (set-current-module outer-module) + (set! outer-module #f))))) + +(define basic-load load) + +(define (load-module filename . reader) + (save-module-excursion + (lambda () + (let ((oldname (and (current-load-port) + (port-filename (current-load-port))))) + (apply basic-load + (if (and oldname + (> (string-length filename) 0) + (not (char=? (string-ref filename 0) #\/)) + (not (string=? (dirname oldname) "."))) + (string-append (dirname oldname) "/" filename) + filename) + reader))))) + + + + +;;; {MODULE-REF -- exported} +;;; + +;; Returns the value of a variable called NAME in MODULE or any of its +;; used modules. If there is no such variable, then if the optional third +;; argument DEFAULT is present, it is returned; otherwise an error is signaled. +;; +(define (module-ref module name . rest) + (let ((variable (module-variable module name))) + (if (and variable (variable-bound? variable)) + (variable-ref variable) + (if (null? rest) + (error "No variable named" name 'in module) + (car rest) ; default value + )))) + +;; MODULE-SET! -- exported +;; +;; Sets the variable called NAME in MODULE (or in a module that MODULE uses) +;; to VALUE; if there is no such variable, an error is signaled. +;; +(define (module-set! module name value) + (let ((variable (module-variable module name))) + (if variable + (variable-set! variable value) + (error "No variable named" name 'in module)))) + +;; MODULE-DEFINE! -- exported +;; +;; Sets the variable called NAME in MODULE to VALUE; if there is no such +;; variable, it is added first. +;; +(define (module-define! module name value) + (let ((variable (module-local-variable module name))) + (if variable + (begin + (variable-set! variable value) + (module-modified module)) + (let ((variable (make-variable value))) + (module-add! module name variable))))) + +;; MODULE-DEFINED? -- exported +;; +;; Return #t iff NAME is defined in MODULE (or in a module that MODULE +;; uses) +;; +(define (module-defined? module name) + (let ((variable (module-variable module name))) + (and variable (variable-bound? variable)))) + +;; MODULE-USE! module interface +;; +;; Add INTERFACE to the list of interfaces used by MODULE. +;; +(define (module-use! module interface) + (set-module-uses! module + (cons interface + (filter (lambda (m) + (not (equal? (module-name m) + (module-name interface)))) + (module-uses module)))) + (module-modified module)) + +;; MODULE-USE-INTERFACES! module interfaces +;; +;; Same as MODULE-USE! but add multiple interfaces and check for duplicates +;; +(define (module-use-interfaces! module interfaces) + (let* ((duplicates-handlers? (or (module-duplicates-handlers module) + (default-duplicate-binding-procedures))) + (uses (module-uses module))) + ;; remove duplicates-interface + (set! uses (delq! (module-duplicates-interface module) uses)) + ;; remove interfaces to be added + (for-each (lambda (interface) + (set! uses + (filter (lambda (m) + (not (equal? (module-name m) + (module-name interface)))) + uses))) + interfaces) + ;; add interfaces to use list + (set-module-uses! module uses) + (for-each (lambda (interface) + (and duplicates-handlers? + ;; perform duplicate checking + (process-duplicates module interface)) + (set! uses (cons interface uses)) + (set-module-uses! module uses)) + interfaces) + ;; add duplicates interface + (if (module-duplicates-interface module) + (set-module-uses! module + (cons (module-duplicates-interface module) uses))) + (module-modified module))) + + + +;;; {Recursive Namespaces} +;;; +;;; A hierarchical namespace emerges if we consider some module to be +;;; root, and variables bound to modules as nested namespaces. +;;; +;;; The routines in this file manage variable names in hierarchical namespace. +;;; Each variable name is a list of elements, looked up in successively nested +;;; modules. +;;; +;;; (nested-ref some-root-module '(foo bar baz)) +;;; => +;;; +;;; +;;; There are: +;;; +;;; ;; a-root is a module +;;; ;; name is a list of symbols +;;; +;;; nested-ref a-root name +;;; nested-set! a-root name val +;;; nested-define! a-root name val +;;; nested-remove! a-root name +;;; +;;; +;;; (current-module) is a natural choice for a-root so for convenience there are +;;; also: +;;; +;;; local-ref name == nested-ref (current-module) name +;;; local-set! name val == nested-set! (current-module) name val +;;; local-define! name val == nested-define! (current-module) name val +;;; local-remove! name == nested-remove! (current-module) name +;;; + + +(define (nested-ref root names) + (let loop ((cur root) + (elts names)) + (cond + ((null? elts) cur) + ((not (module? cur)) #f) + (else (loop (module-ref cur (car elts) #f) (cdr elts)))))) + +(define (nested-set! root names val) + (let loop ((cur root) + (elts names)) + (if (null? (cdr elts)) + (module-set! cur (car elts) val) + (loop (module-ref cur (car elts)) (cdr elts))))) + +(define (nested-define! root names val) + (let loop ((cur root) + (elts names)) + (if (null? (cdr elts)) + (module-define! cur (car elts) val) + (loop (module-ref cur (car elts)) (cdr elts))))) + +(define (nested-remove! root names) + (let loop ((cur root) + (elts names)) + (if (null? (cdr elts)) + (module-remove! cur (car elts)) + (loop (module-ref cur (car elts)) (cdr elts))))) + +(define (local-ref names) (nested-ref (current-module) names)) +(define (local-set! names val) (nested-set! (current-module) names val)) +(define (local-define names val) (nested-define! (current-module) names val)) +(define (local-remove names) (nested-remove! (current-module) names)) + + + + +;;; {The (%app) module} +;;; +;;; The root of conventionally named objects not directly in the top level. +;;; +;;; (%app modules) +;;; (%app modules guile) +;;; +;;; The directory of all modules and the standard root module. +;;; + +(define (module-public-interface m) + (module-ref m '%module-public-interface #f)) +(define (set-module-public-interface! m i) + (module-define! m '%module-public-interface i)) +(define (set-system-module! m s) + (set-procedure-property! (module-eval-closure m) 'system-module s)) +(define the-root-module (make-root-module)) +(define the-scm-module (make-scm-module)) +(set-module-public-interface! the-root-module the-scm-module) +(set-module-name! the-root-module '(guile)) +(set-module-name! the-scm-module '(guile)) +(set-module-kind! the-scm-module 'interface) +(for-each set-system-module! (list the-root-module the-scm-module) '(#t #t)) + +;; NOTE: This binding is used in libguile/modules.c. +;; +(define (make-modules-in module name) + (if (null? name) + module + (cond + ((module-ref module (car name) #f) + => (lambda (m) (make-modules-in m (cdr name)))) + (else (let ((m (make-module 31))) + (set-module-kind! m 'directory) + (set-module-name! m (append (or (module-name module) + '()) + (list (car name)))) + (module-define! module (car name) m) + (make-modules-in m (cdr name))))))) + +(define (beautify-user-module! module) + (let ((interface (module-public-interface module))) + (if (or (not interface) + (eq? interface module)) + (let ((interface (make-module 31))) + (set-module-name! interface (module-name module)) + (set-module-kind! interface 'interface) + (set-module-public-interface! module interface)))) + (if (and (not (memq the-scm-module (module-uses module))) + (not (eq? module the-root-module))) + (set-module-uses! module + (append (module-uses module) (list the-scm-module))))) + +;; NOTE: This binding is used in libguile/modules.c. +;; +(define (resolve-module name . maybe-autoload) + (let ((full-name (append '(%app modules) name))) + (let ((already (nested-ref the-root-module full-name))) + (if already + ;; The module already exists... + (if (and (or (null? maybe-autoload) (car maybe-autoload)) + (not (module-public-interface already))) + ;; ...but we are told to load and it doesn't contain source, so + (begin + (try-load-module name) + already) + ;; simply return it. + already) + (begin + ;; Try to autoload it if we are told so + (if (or (null? maybe-autoload) (car maybe-autoload)) + (try-load-module name)) + ;; Get/create it. + (make-modules-in (current-module) full-name)))))) + +;; Cheat. These bindings are needed by modules.c, but we don't want +;; to move their real definition here because that would be unnatural. +;; +(define try-module-autoload #f) +(define process-define-module #f) +(define process-use-modules #f) +(define module-export! #f) + +;; This boots the module system. All bindings needed by modules.c +;; must have been defined by now. +;; +(set-current-module the-root-module) + +(define %app (make-module 31)) +(define app %app) ;; for backwards compatability +(local-define '(%app modules) (make-module 31)) +(local-define '(%app modules guile) the-root-module) + +;; (define-special-value '(%app modules new-ws) (lambda () (make-scm-module))) + +(define (try-load-module name) + (or (begin-deprecated (try-module-linked name)) + (try-module-autoload name) + (begin-deprecated (try-module-dynamic-link name)))) + +(define (purify-module! module) + "Removes bindings in MODULE which are inherited from the (guile) module." + (let ((use-list (module-uses module))) + (if (and (pair? use-list) + (eq? (car (last-pair use-list)) the-scm-module)) + (set-module-uses! module (reverse (cdr (reverse use-list))))))) + +;; Return a module that is an interface to the module designated by +;; NAME. +;; +;; `resolve-interface' takes four keyword arguments: +;; +;; #:select SELECTION +;; +;; SELECTION is a list of binding-specs to be imported; A binding-spec +;; is either a symbol or a pair of symbols (ORIG . SEEN), where ORIG +;; is the name in the used module and SEEN is the name in the using +;; module. Note that SEEN is also passed through RENAMER, below. The +;; default is to select all bindings. If you specify no selection but +;; a renamer, only the bindings that already exist in the used module +;; are made available in the interface. Bindings that are added later +;; are not picked up. +;; +;; #:hide BINDINGS +;; +;; BINDINGS is a list of bindings which should not be imported. +;; +;; #:prefix PREFIX +;; +;; PREFIX is a symbol that will be appended to each exported name. +;; The default is to not perform any renaming. +;; +;; #:renamer RENAMER +;; +;; RENAMER is a procedure that takes a symbol and returns its new +;; name. The default is not perform any renaming. +;; +;; Signal "no code for module" error if module name is not resolvable +;; or its public interface is not available. Signal "no binding" +;; error if selected binding does not exist in the used module. +;; +(define (resolve-interface name . args) + + (define (get-keyword-arg args kw def) + (cond ((memq kw args) + => (lambda (kw-arg) + (if (null? (cdr kw-arg)) + (error "keyword without value: " kw)) + (cadr kw-arg))) + (else + def))) + + (let* ((select (get-keyword-arg args #:select #f)) + (hide (get-keyword-arg args #:hide '())) + (renamer (or (get-keyword-arg args #:renamer #f) + (let ((prefix (get-keyword-arg args #:prefix #f))) + (and prefix (symbol-prefix-proc prefix))) + identity)) + (module (resolve-module name)) + (public-i (and module (module-public-interface module)))) + (and (or (not module) (not public-i)) + (error "no code for module" name)) + (if (and (not select) (null? hide) (eq? renamer identity)) + public-i + (let ((selection (or select (module-map (lambda (sym var) sym) + public-i))) + (custom-i (make-module 31))) + (set-module-kind! custom-i 'custom-interface) + (set-module-name! custom-i name) + ;; XXX - should use a lazy binder so that changes to the + ;; used module are picked up automatically. + (for-each (lambda (bspec) + (let* ((direct? (symbol? bspec)) + (orig (if direct? bspec (car bspec))) + (seen (if direct? bspec (cdr bspec))) + (var (or (module-local-variable public-i orig) + (module-local-variable module orig) + (error + ;; fixme: format manually for now + (simple-format + #f "no binding `~A' in module ~A" + orig name))))) + (if (memq orig hide) + (set! hide (delq! orig hide)) + (module-add! custom-i + (renamer seen) + var)))) + selection) + ;; Check that we are not hiding bindings which don't exist + (for-each (lambda (binding) + (if (not (module-local-variable public-i binding)) + (error + (simple-format + #f "no binding `~A' to hide in module ~A" + binding name)))) + hide) + custom-i)))) + +(define (symbol-prefix-proc prefix) + (lambda (symbol) + (symbol-append prefix symbol))) + +;; This function is called from "modules.c". If you change it, be +;; sure to update "modules.c" as well. + +(define (process-define-module args) + (let* ((module-id (car args)) + (module (resolve-module module-id #f)) + (kws (cdr args)) + (unrecognized (lambda (arg) + (error "unrecognized define-module argument" arg)))) + (beautify-user-module! module) + (let loop ((kws kws) + (reversed-interfaces '()) + (exports '()) + (re-exports '()) + (replacements '())) + + (if (null? kws) + (call-with-deferred-observers + (lambda () + (module-use-interfaces! module (reverse reversed-interfaces)) + (module-export! module exports) + (module-replace! module replacements) + (module-re-export! module re-exports))) + (case (car kws) + ((#:use-module #:use-syntax) + (or (pair? (cdr kws)) + (unrecognized kws)) + (let* ((interface-args (cadr kws)) + (interface (apply resolve-interface interface-args))) + (and (eq? (car kws) #:use-syntax) + (or (symbol? (caar interface-args)) + (error "invalid module name for use-syntax" + (car interface-args))) + (set-module-transformer! + module + (module-ref interface + (car (last-pair (car interface-args))) + #f))) + (loop (cddr kws) + (cons interface reversed-interfaces) + exports + re-exports + replacements))) + ((#:autoload) + (or (and (pair? (cdr kws)) (pair? (cddr kws))) + (unrecognized kws)) + (loop (cdddr kws) + (cons (make-autoload-interface module + (cadr kws) + (caddr kws)) + reversed-interfaces) + exports + re-exports + replacements)) + ((#:no-backtrace) + (set-system-module! module #t) + (loop (cdr kws) reversed-interfaces exports re-exports replacements)) + ((#:pure) + (purify-module! module) + (loop (cdr kws) reversed-interfaces exports re-exports replacements)) + ((#:duplicates) + (if (not (pair? (cdr kws))) + (unrecognized kws)) + (set-module-duplicates-handlers! + module + (lookup-duplicates-handlers (cadr kws))) + (loop (cddr kws) reversed-interfaces exports re-exports replacements)) + ((#:export #:export-syntax) + (or (pair? (cdr kws)) + (unrecognized kws)) + (loop (cddr kws) + reversed-interfaces + (append (cadr kws) exports) + re-exports + replacements)) + ((#:re-export #:re-export-syntax) + (or (pair? (cdr kws)) + (unrecognized kws)) + (loop (cddr kws) + reversed-interfaces + exports + (append (cadr kws) re-exports) + replacements)) + ((#:replace #:replace-syntax) + (or (pair? (cdr kws)) + (unrecognized kws)) + (loop (cddr kws) + reversed-interfaces + exports + re-exports + (append (cadr kws) replacements))) + (else + (unrecognized kws))))) + (run-hook module-defined-hook module) + module)) + +;; `module-defined-hook' is a hook that is run whenever a new module +;; is defined. Its members are called with one argument, the new +;; module. +(define module-defined-hook (make-hook 1)) + + + +;;; {Autoload} +;;; + +(define (make-autoload-interface module name bindings) + (let ((b (lambda (a sym definep) + (and (memq sym bindings) + (let ((i (module-public-interface (resolve-module name)))) + (if (not i) + (error "missing interface for module" name)) + (let ((autoload (memq a (module-uses module)))) + ;; Replace autoload-interface with actual interface if + ;; that has not happened yet. + (if (pair? autoload) + (set-car! autoload i))) + (module-local-variable i sym)))))) + (module-constructor (make-hash-table 0) '() b #f #f name 'autoload #f #f + '() (make-weak-value-hash-table 31) 0))) + +;;; {Compiled module} + +(define load-compiled #f) + + + +;;; {Autoloading modules} +;;; + +(define autoloads-in-progress '()) + +;; This function is called from "modules.c". If you change it, be +;; sure to update "modules.c" as well. + +(define (try-module-autoload module-name) + (let* ((reverse-name (reverse module-name)) + (name (symbol->string (car reverse-name))) + (dir-hint-module-name (reverse (cdr reverse-name))) + (dir-hint (apply string-append + (map (lambda (elt) + (string-append (symbol->string elt) "/")) + dir-hint-module-name)))) + (resolve-module dir-hint-module-name #f) + (and (not (autoload-done-or-in-progress? dir-hint name)) + (let ((didit #f)) + (define (load-file proc file) + (save-module-excursion (lambda () (proc file))) + (set! didit #t)) + (dynamic-wind + (lambda () (autoload-in-progress! dir-hint name)) + (lambda () + (let ((file (in-vicinity dir-hint name))) + (cond ((and load-compiled + (%search-load-path (string-append file ".go"))) + => (lambda (full) + (load-file load-compiled full))) + ((%search-load-path file) + => (lambda (full) + (with-fluids ((current-reader #f)) + (load-file primitive-load full))))))) + (lambda () (set-autoloaded! dir-hint name didit))) + didit)))) + + + +;;; {Dynamic linking of modules} +;;; + +(define autoloads-done '((guile . guile))) + +(define (autoload-done-or-in-progress? p m) + (let ((n (cons p m))) + (->bool (or (member n autoloads-done) + (member n autoloads-in-progress))))) + +(define (autoload-done! p m) + (let ((n (cons p m))) + (set! autoloads-in-progress + (delete! n autoloads-in-progress)) + (or (member n autoloads-done) + (set! autoloads-done (cons n autoloads-done))))) + +(define (autoload-in-progress! p m) + (let ((n (cons p m))) + (set! autoloads-done + (delete! n autoloads-done)) + (set! autoloads-in-progress (cons n autoloads-in-progress)))) + +(define (set-autoloaded! p m done?) + (if done? + (autoload-done! p m) + (let ((n (cons p m))) + (set! autoloads-done (delete! n autoloads-done)) + (set! autoloads-in-progress (delete! n autoloads-in-progress))))) + + + +;;; {Run-time options} +;;; + +(define define-option-interface + (let* ((option-name car) + (option-value cadr) + (option-documentation caddr) + + (print-option (lambda (option) + (display (option-name option)) + (if (< (string-length + (symbol->string (option-name option))) + 8) + (display #\tab)) + (display #\tab) + (display (option-value option)) + (display #\tab) + (display (option-documentation option)) + (newline))) + + ;; Below follow the macros defining the run-time option interfaces. + + (make-options (lambda (interface) + `(lambda args + (cond ((null? args) (,interface)) + ((list? (car args)) + (,interface (car args)) (,interface)) + (else (for-each ,print-option + (,interface #t))))))) + + (make-enable (lambda (interface) + `(lambda flags + (,interface (append flags (,interface))) + (,interface)))) + + (make-disable (lambda (interface) + `(lambda flags + (let ((options (,interface))) + (for-each (lambda (flag) + (set! options (delq! flag options))) + flags) + (,interface options) + (,interface)))))) + (procedure->memoizing-macro + (lambda (exp env) + (let* ((option-group (cadr exp)) + (interface (car option-group)) + (options/enable/disable (cadr option-group))) + `(begin + (define ,(car options/enable/disable) + ,(make-options interface)) + (define ,(cadr options/enable/disable) + ,(make-enable interface)) + (define ,(caddr options/enable/disable) + ,(make-disable interface)) + (defmacro ,(caaddr option-group) (opt val) + `(,,(car options/enable/disable) + (append (,,(car options/enable/disable)) + (list ',opt ,val)))))))))) + +(define-option-interface + (eval-options-interface + (eval-options eval-enable eval-disable) + (eval-set!))) + +(define-option-interface + (debug-options-interface + (debug-options debug-enable debug-disable) + (debug-set!))) + +(define-option-interface + (evaluator-traps-interface + (traps trap-enable trap-disable) + (trap-set!))) + +(define-option-interface + (read-options-interface + (read-options read-enable read-disable) + (read-set!))) + +(define-option-interface + (print-options-interface + (print-options print-enable print-disable) + (print-set!))) + + + +;;; {Running Repls} +;;; + +(define (repl read evaler print) + (let loop ((source (read (current-input-port)))) + (print (evaler source)) + (loop (read (current-input-port))))) + +;; A provisional repl that acts like the SCM repl: +;; +(define scm-repl-silent #f) +(define (assert-repl-silence v) (set! scm-repl-silent v)) + +(define *unspecified* (if #f #f)) +(define (unspecified? v) (eq? v *unspecified*)) + +(define scm-repl-print-unspecified #f) +(define (assert-repl-print-unspecified v) (set! scm-repl-print-unspecified v)) + +(define scm-repl-verbose #f) +(define (assert-repl-verbosity v) (set! scm-repl-verbose v)) + +(define scm-repl-prompt "guile> ") + +(define (set-repl-prompt! v) (set! scm-repl-prompt v)) + +(define (default-lazy-handler key . args) + (save-stack lazy-handler-dispatch) + (apply throw key args)) + +(define (lazy-handler-dispatch key . args) + (apply default-lazy-handler key args)) + +(define abort-hook (make-hook)) + +;; these definitions are used if running a script. +;; otherwise redefined in error-catching-loop. +(define (set-batch-mode?! arg) #t) +(define (batch-mode?) #t) + +(define (error-catching-loop thunk) + (let ((status #f) + (interactive #t)) + (define (loop first) + (let ((next + (catch #t + + (lambda () + (call-with-unblocked-asyncs + (lambda () + (with-traps + (lambda () + (first) + + ;; This line is needed because mark + ;; doesn't do closures quite right. + ;; Unreferenced locals should be + ;; collected. + (set! first #f) + (let loop ((v (thunk))) + (loop (thunk))) + #f))))) + + (lambda (key . args) + (case key + ((quit) + (set! status args) + #f) + + ((switch-repl) + (apply throw 'switch-repl args)) + + ((abort) + ;; This is one of the closures that require + ;; (set! first #f) above + ;; + (lambda () + (run-hook abort-hook) + (force-output (current-output-port)) + (display "ABORT: " (current-error-port)) + (write args (current-error-port)) + (newline (current-error-port)) + (if interactive + (begin + (if (and + (not has-shown-debugger-hint?) + (not (memq 'backtrace + (debug-options-interface))) + (stack? (fluid-ref the-last-stack))) + (begin + (newline (current-error-port)) + (display + "Type \"(backtrace)\" to get more information or \"(debug)\" to enter the debugger.\n" + (current-error-port)) + (set! has-shown-debugger-hint? #t))) + (force-output (current-error-port))) + (begin + (primitive-exit 1))) + (set! stack-saved? #f))) + + (else + ;; This is the other cons-leak closure... + (lambda () + (cond ((= (length args) 4) + (apply handle-system-error key args)) + (else + (apply bad-throw key args))))))) + + ;; Note that having just `lazy-handler-dispatch' + ;; here is connected with the mechanism that + ;; produces a nice backtrace upon error. If, for + ;; example, this is replaced with (lambda args + ;; (apply lazy-handler-dispatch args)), the stack + ;; cutting (in save-stack) goes wrong and ends up + ;; saving no stack at all, so there is no + ;; backtrace. + lazy-handler-dispatch))) + + (if next (loop next) status))) + (set! set-batch-mode?! (lambda (arg) + (cond (arg + (set! interactive #f) + (restore-signals)) + (#t + (error "sorry, not implemented"))))) + (set! batch-mode? (lambda () (not interactive))) + (call-with-blocked-asyncs + (lambda () (loop (lambda () #t)))))) + +;;(define the-last-stack (make-fluid)) Defined by scm_init_backtrace () +(define before-signal-stack (make-fluid)) +(define stack-saved? #f) + +(define (save-stack . narrowing) + (or stack-saved? + (cond ((not (memq 'debug (debug-options-interface))) + (fluid-set! the-last-stack #f) + (set! stack-saved? #t)) + (else + (fluid-set! + the-last-stack + (case (stack-id #t) + ((repl-stack) + (apply make-stack #t save-stack primitive-eval #t 0 narrowing)) + ((load-stack) + (apply make-stack #t save-stack 0 #t 0 narrowing)) + ((tk-stack) + (apply make-stack #t save-stack tk-stack-mark #t 0 narrowing)) + ((#t) + (apply make-stack #t save-stack 0 1 narrowing)) + (else + (let ((id (stack-id #t))) + (and (procedure? id) + (apply make-stack #t save-stack id #t 0 narrowing)))))) + (set! stack-saved? #t))))) + +(define before-error-hook (make-hook)) +(define after-error-hook (make-hook)) +(define before-backtrace-hook (make-hook)) +(define after-backtrace-hook (make-hook)) + +(define has-shown-debugger-hint? #f) + +(define (handle-system-error key . args) + (let ((cep (current-error-port))) + (cond ((not (stack? (fluid-ref the-last-stack)))) + ((memq 'backtrace (debug-options-interface)) + (let ((highlights (if (or (eq? key 'wrong-type-arg) + (eq? key 'out-of-range)) + (list-ref args 3) + '()))) + (run-hook before-backtrace-hook) + (newline cep) + (display "Backtrace:\n") + (display-backtrace (fluid-ref the-last-stack) cep + #f #f highlights) + (newline cep) + (run-hook after-backtrace-hook)))) + (run-hook before-error-hook) + (apply display-error (fluid-ref the-last-stack) cep args) + (run-hook after-error-hook) + (force-output cep) + (throw 'abort key))) + +(define (quit . args) + (apply throw 'quit args)) + +(define exit quit) + +;;(define has-shown-backtrace-hint? #f) Defined by scm_init_backtrace () + +;; Replaced by C code: +;;(define (backtrace) +;; (if (fluid-ref the-last-stack) +;; (begin +;; (newline) +;; (display-backtrace (fluid-ref the-last-stack) (current-output-port)) +;; (newline) +;; (if (and (not has-shown-backtrace-hint?) +;; (not (memq 'backtrace (debug-options-interface)))) +;; (begin +;; (display +;;"Type \"(debug-enable 'backtrace)\" if you would like a backtrace +;;automatically if an error occurs in the future.\n") +;; (set! has-shown-backtrace-hint? #t)))) +;; (display "No backtrace available.\n"))) + +(define (error-catching-repl r e p) + (error-catching-loop + (lambda () + (call-with-values (lambda () (e (r))) + (lambda the-values (for-each p the-values)))))) + +(define (gc-run-time) + (cdr (assq 'gc-time-taken (gc-stats)))) + +(define before-read-hook (make-hook)) +(define after-read-hook (make-hook)) +(define before-eval-hook (make-hook 1)) +(define after-eval-hook (make-hook 1)) +(define before-print-hook (make-hook 1)) +(define after-print-hook (make-hook 1)) + +;;; The default repl-reader function. We may override this if we've +;;; the readline library. +(define repl-reader + (lambda (prompt) + (display prompt) + (force-output) + (run-hook before-read-hook) + ((or (fluid-ref current-reader) read) (current-input-port)))) + +(define (scm-style-repl) + + (letrec ( + (start-gc-rt #f) + (start-rt #f) + (repl-report-start-timing (lambda () + (set! start-gc-rt (gc-run-time)) + (set! start-rt (get-internal-run-time)))) + (repl-report (lambda () + (display ";;; ") + (display (inexact->exact + (* 1000 (/ (- (get-internal-run-time) start-rt) + internal-time-units-per-second)))) + (display " msec (") + (display (inexact->exact + (* 1000 (/ (- (gc-run-time) start-gc-rt) + internal-time-units-per-second)))) + (display " msec in gc)\n"))) + + (consume-trailing-whitespace + (lambda () + (let ((ch (peek-char))) + (cond + ((eof-object? ch)) + ((or (char=? ch #\space) (char=? ch #\tab)) + (read-char) + (consume-trailing-whitespace)) + ((char=? ch #\newline) + (read-char)))))) + (-read (lambda () + (let ((val + (let ((prompt (cond ((string? scm-repl-prompt) + scm-repl-prompt) + ((thunk? scm-repl-prompt) + (scm-repl-prompt)) + (scm-repl-prompt "> ") + (else "")))) + (repl-reader prompt)))) + + ;; As described in R4RS, the READ procedure updates the + ;; port to point to the first character past the end of + ;; the external representation of the object. This + ;; means that it doesn't consume the newline typically + ;; found after an expression. This means that, when + ;; debugging Guile with GDB, GDB gets the newline, which + ;; it often interprets as a "continue" command, making + ;; breakpoints kind of useless. So, consume any + ;; trailing newline here, as well as any whitespace + ;; before it. + ;; But not if EOF, for control-D. + (if (not (eof-object? val)) + (consume-trailing-whitespace)) + (run-hook after-read-hook) + (if (eof-object? val) + (begin + (repl-report-start-timing) + (if scm-repl-verbose + (begin + (newline) + (display ";;; EOF -- quitting") + (newline))) + (quit 0))) + val))) + + (-eval (lambda (sourc) + (repl-report-start-timing) + (run-hook before-eval-hook sourc) + (let ((val (start-stack 'repl-stack + ;; If you change this procedure + ;; (primitive-eval), please also + ;; modify the repl-stack case in + ;; save-stack so that stack cutting + ;; continues to work. + (primitive-eval sourc)))) + (run-hook after-eval-hook sourc) + val))) + + + (-print (let ((maybe-print (lambda (result) + (if (or scm-repl-print-unspecified + (not (unspecified? result))) + (begin + (write result) + (newline)))))) + (lambda (result) + (if (not scm-repl-silent) + (begin + (run-hook before-print-hook result) + (maybe-print result) + (run-hook after-print-hook result) + (if scm-repl-verbose + (repl-report)) + (force-output)))))) + + (-quit (lambda (args) + (if scm-repl-verbose + (begin + (display ";;; QUIT executed, repl exitting") + (newline) + (repl-report))) + args)) + + (-abort (lambda () + (if scm-repl-verbose + (begin + (display ";;; ABORT executed.") + (newline) + (repl-report))) + (repl -read -eval -print)))) + + (let ((status (error-catching-repl -read + -eval + -print))) + (-quit status)))) + + + + +;;; {IOTA functions: generating lists of numbers} +;;; + +(define (iota n) + (let loop ((count (1- n)) (result '())) + (if (< count 0) result + (loop (1- count) (cons count result))))) + + + +;;; {collect} +;;; +;;; Similar to `begin' but returns a list of the results of all constituent +;;; forms instead of the result of the last form. +;;; (The definition relies on the current left-to-right +;;; order of evaluation of operands in applications.) +;;; + +(defmacro collect forms + (cons 'list forms)) + + + +;;; {with-fluids} +;;; + +;; with-fluids is a convenience wrapper for the builtin procedure +;; `with-fluids*'. The syntax is just like `let': +;; +;; (with-fluids ((fluid val) +;; ...) +;; body) + +(defmacro with-fluids (bindings . body) + (let ((fluids (map car bindings)) + (values (map cadr bindings))) + (if (and (= (length fluids) 1) (= (length values) 1)) + `(with-fluid* ,(car fluids) ,(car values) (lambda () ,@body)) + `(with-fluids* (list ,@fluids) (list ,@values) + (lambda () ,@body))))) + + + +;;; {Macros} +;;; + +;; actually....hobbit might be able to hack these with a little +;; coaxing +;; + +(define (primitive-macro? m) + (and (macro? m) + (not (macro-transformer m)))) + +(defmacro define-macro (first . rest) + (let ((name (if (symbol? first) first (car first))) + (transformer + (if (symbol? first) + (car rest) + `(lambda ,(cdr first) ,@rest)))) + `(eval-case + ((load-toplevel) + (define ,name (defmacro:transformer ,transformer))) + (else + (error "define-macro can only be used at the top level"))))) + + +(defmacro define-syntax-macro (first . rest) + (let ((name (if (symbol? first) first (car first))) + (transformer + (if (symbol? first) + (car rest) + `(lambda ,(cdr first) ,@rest)))) + `(eval-case + ((load-toplevel) + (define ,name (defmacro:syntax-transformer ,transformer))) + (else + (error "define-syntax-macro can only be used at the top level"))))) + + + +;;; {While} +;;; +;;; with `continue' and `break'. +;;; + +;; The inner `do' loop avoids re-establishing a catch every iteration, +;; that's only necessary if continue is actually used. A new key is +;; generated every time, so break and continue apply to their originating +;; `while' even when recursing. `while-helper' is an easy way to keep the +;; `key' binding away from the cond and body code. +;; +;; FIXME: This is supposed to have an `unquote' on the `do' the same used +;; for lambda and not, so as to protect against any user rebinding of that +;; symbol, but unfortunately an unquote breaks with ice-9 syncase, eg. +;; +;; (use-modules (ice-9 syncase)) +;; (while #f) +;; => ERROR: invalid syntax () +;; +;; This is probably a bug in syncase. +;; +(define-macro (while cond . body) + (define (while-helper proc) + (do ((key (make-symbol "while-key"))) + ((catch key + (lambda () + (proc (lambda () (throw key #t)) + (lambda () (throw key #f)))) + (lambda (key arg) arg))))) + `(,while-helper (,lambda (break continue) + (do () + ((,not ,cond)) + ,@body) + #t))) + + + + +;;; {Module System Macros} +;;; + +;; Return a list of expressions that evaluate to the appropriate +;; arguments for resolve-interface according to SPEC. + +(define (compile-interface-spec spec) + (define (make-keyarg sym key quote?) + (cond ((or (memq sym spec) + (memq key spec)) + => (lambda (rest) + (if quote? + (list key (list 'quote (cadr rest))) + (list key (cadr rest))))) + (else + '()))) + (define (map-apply func list) + (map (lambda (args) (apply func args)) list)) + (define keys + ;; sym key quote? + '((:select #:select #t) + (:hide #:hide #t) + (:prefix #:prefix #t) + (:renamer #:renamer #f))) + (if (not (pair? (car spec))) + `(',spec) + `(',(car spec) + ,@(apply append (map-apply make-keyarg keys))))) + +(define (keyword-like-symbol->keyword sym) + (symbol->keyword (string->symbol (substring (symbol->string sym) 1)))) + +(define (compile-define-module-args args) + ;; Just quote everything except #:use-module and #:use-syntax. We + ;; need to know about all arguments regardless since we want to turn + ;; symbols that look like keywords into real keywords, and the + ;; keyword args in a define-module form are not regular + ;; (i.e. no-backtrace doesn't take a value). + (let loop ((compiled-args `((quote ,(car args)))) + (args (cdr args))) + (cond ((null? args) + (reverse! compiled-args)) + ;; symbol in keyword position + ((symbol? (car args)) + (loop compiled-args + (cons (keyword-like-symbol->keyword (car args)) (cdr args)))) + ((memq (car args) '(#:no-backtrace #:pure)) + (loop (cons (car args) compiled-args) + (cdr args))) + ((null? (cdr args)) + (error "keyword without value:" (car args))) + ((memq (car args) '(#:use-module #:use-syntax)) + (loop (cons* `(list ,@(compile-interface-spec (cadr args))) + (car args) + compiled-args) + (cddr args))) + ((eq? (car args) #:autoload) + (loop (cons* `(quote ,(caddr args)) + `(quote ,(cadr args)) + (car args) + compiled-args) + (cdddr args))) + (else + (loop (cons* `(quote ,(cadr args)) + (car args) + compiled-args) + (cddr args)))))) + +(defmacro define-module args + `(eval-case + ((load-toplevel) + (let ((m (process-define-module + (list ,@(compile-define-module-args args))))) + (set-current-module m) + m)) + (else + (error "define-module can only be used at the top level")))) + +;; The guts of the use-modules macro. Add the interfaces of the named +;; modules to the use-list of the current module, in order. + +;; This function is called by "modules.c". If you change it, be sure +;; to change scm_c_use_module as well. + +(define (process-use-modules module-interface-args) + (let ((interfaces (map (lambda (mif-args) + (or (apply resolve-interface mif-args) + (error "no such module" mif-args))) + module-interface-args))) + (call-with-deferred-observers + (lambda () + (module-use-interfaces! (current-module) interfaces))))) + +(defmacro use-modules modules + `(eval-case + ((load-toplevel) + (process-use-modules + (list ,@(map (lambda (m) + `(list ,@(compile-interface-spec m))) + modules))) + *unspecified*) + (else + (error "use-modules can only be used at the top level")))) + +(defmacro use-syntax (spec) + `(eval-case + ((load-toplevel) + ,@(if (pair? spec) + `((process-use-modules (list + (list ,@(compile-interface-spec spec)))) + (set-module-transformer! (current-module) + ,(car (last-pair spec)))) + `((set-module-transformer! (current-module) ,spec))) + *unspecified*) + (else + (error "use-syntax can only be used at the top level")))) + +;; Dirk:FIXME:: This incorrect (according to R5RS) syntax needs to be changed +;; as soon as guile supports hygienic macros. +(define define-private define) + +(defmacro define-public args + (define (syntax) + (error "bad syntax" (list 'define-public args))) + (define (defined-name n) + (cond + ((symbol? n) n) + ((pair? n) (defined-name (car n))) + (else (syntax)))) + (cond + ((null? args) + (syntax)) + (#t + (let ((name (defined-name (car args)))) + `(begin + (define-private ,@args) + (eval-case ((load-toplevel) (export ,name)))))))) + +(defmacro defmacro-public args + (define (syntax) + (error "bad syntax" (list 'defmacro-public args))) + (define (defined-name n) + (cond + ((symbol? n) n) + (else (syntax)))) + (cond + ((null? args) + (syntax)) + (#t + (let ((name (defined-name (car args)))) + `(begin + (eval-case ((load-toplevel) (export-syntax ,name))) + (defmacro ,@args)))))) + +;; Export a local variable + +;; This function is called from "modules.c". If you change it, be +;; sure to update "modules.c" as well. + +(define (module-export! m names) + (let ((public-i (module-public-interface m))) + (for-each (lambda (name) + (let ((var (module-ensure-local-variable! m name))) + (module-add! public-i name var))) + names))) + +(define (module-replace! m names) + (let ((public-i (module-public-interface m))) + (for-each (lambda (name) + (let ((var (module-ensure-local-variable! m name))) + (set-object-property! var 'replace #t) + (module-add! public-i name var))) + names))) + +;; Re-export a imported variable +;; +(define (module-re-export! m names) + (let ((public-i (module-public-interface m))) + (for-each (lambda (name) + (let ((var (module-variable m name))) + (cond ((not var) + (error "Undefined variable:" name)) + ((eq? var (module-local-variable m name)) + (error "re-exporting local variable:" name)) + (else + (module-add! public-i name var))))) + names))) + +(defmacro export names + `(eval-case + ((load-toplevel) + (call-with-deferred-observers + (lambda () + (module-export! (current-module) ',names)))) + (else + (error "export can only be used at the top level")))) + +(defmacro re-export names + `(eval-case + ((load-toplevel) + (call-with-deferred-observers + (lambda () + (module-re-export! (current-module) ',names)))) + (else + (error "re-export can only be used at the top level")))) + +(defmacro export-syntax names + `(export ,@names)) + +(defmacro re-export-syntax names + `(re-export ,@names)) + +(define load load-module) + +;; The following macro allows one to write, for example, +;; +;; (@ (ice-9 pretty-print) pretty-print) +;; +;; to refer directly to the pretty-print variable in module (ice-9 +;; pretty-print). It works by looking up the variable and inserting +;; it directly into the code. This is understood by the evaluator. +;; Indeed, all references to global variables are memoized into such +;; variable objects. + +(define-macro (@ mod-name var-name) + (let ((var (module-variable (resolve-interface mod-name) var-name))) + (if (not var) + (error "no such public variable" (list '@ mod-name var-name))) + var)) + +;; The '@@' macro is like '@' but it can also access bindings that +;; have not been explicitely exported. + +(define-macro (@@ mod-name var-name) + (let ((var (module-variable (resolve-module mod-name) var-name))) + (if (not var) + (error "no such variable" (list '@@ mod-name var-name))) + var)) + + + +;;; {Parameters} +;;; + +(define make-mutable-parameter + (let ((make (lambda (fluid converter) + (lambda args + (if (null? args) + (fluid-ref fluid) + (fluid-set! fluid (converter (car args)))))))) + (lambda (init . converter) + (let ((fluid (make-fluid)) + (converter (if (null? converter) + identity + (car converter)))) + (fluid-set! fluid (converter init)) + (make fluid converter))))) + + + +;;; {Handling of duplicate imported bindings} +;;; + +;; Duplicate handlers take the following arguments: +;; +;; module importing module +;; name conflicting name +;; int1 old interface where name occurs +;; val1 value of binding in old interface +;; int2 new interface where name occurs +;; val2 value of binding in new interface +;; var previous resolution or #f +;; val value of previous resolution +;; +;; A duplicate handler can take three alternative actions: +;; +;; 1. return #f => leave responsibility to next handler +;; 2. exit with an error +;; 3. return a variable resolving the conflict +;; + +(define duplicate-handlers + (let ((m (make-module 7))) + + (define (check module name int1 val1 int2 val2 var val) + (scm-error 'misc-error + #f + "~A: `~A' imported from both ~A and ~A" + (list (module-name module) + name + (module-name int1) + (module-name int2)) + #f)) + + (define (warn module name int1 val1 int2 val2 var val) + (format (current-error-port) + "WARNING: ~A: `~A' imported from both ~A and ~A\n" + (module-name module) + name + (module-name int1) + (module-name int2)) + #f) + + (define (replace module name int1 val1 int2 val2 var val) + (let ((old (or (and var (object-property var 'replace) var) + (module-variable int1 name))) + (new (module-variable int2 name))) + (if (object-property old 'replace) + (and (or (eq? old new) + (not (object-property new 'replace))) + old) + (and (object-property new 'replace) + new)))) + + (define (warn-override-core module name int1 val1 int2 val2 var val) + (and (eq? int1 the-scm-module) + (begin + (format (current-error-port) + "WARNING: ~A: imported module ~A overrides core binding `~A'\n" + (module-name module) + (module-name int2) + name) + (module-local-variable int2 name)))) + + (define (first module name int1 val1 int2 val2 var val) + (or var (module-local-variable int1 name))) + + (define (last module name int1 val1 int2 val2 var val) + (module-local-variable int2 name)) + + (define (noop module name int1 val1 int2 val2 var val) + #f) + + (set-module-name! m 'duplicate-handlers) + (set-module-kind! m 'interface) + (module-define! m 'check check) + (module-define! m 'warn warn) + (module-define! m 'replace replace) + (module-define! m 'warn-override-core warn-override-core) + (module-define! m 'first first) + (module-define! m 'last last) + (module-define! m 'merge-generics noop) + (module-define! m 'merge-accessors noop) + m)) + +(define (lookup-duplicates-handlers handler-names) + (and handler-names + (map (lambda (handler-name) + (or (module-symbol-local-binding + duplicate-handlers handler-name #f) + (error "invalid duplicate handler name:" + handler-name))) + (if (list? handler-names) + handler-names + (list handler-names))))) + +(define default-duplicate-binding-procedures + (make-mutable-parameter #f)) + +(define default-duplicate-binding-handler + (make-mutable-parameter '(replace warn-override-core warn last) + (lambda (handler-names) + (default-duplicate-binding-procedures + (lookup-duplicates-handlers handler-names)) + handler-names))) + +(define (make-duplicates-interface) + (let ((m (make-module))) + (set-module-kind! m 'custom-interface) + (set-module-name! m 'duplicates) + m)) + +(define (process-duplicates module interface) + (let* ((duplicates-handlers (or (module-duplicates-handlers module) + (default-duplicate-binding-procedures))) + (duplicates-interface (module-duplicates-interface module))) + (module-for-each + (lambda (name var) + (cond ((module-import-interface module name) + => + (lambda (prev-interface) + (let ((var1 (module-local-variable prev-interface name)) + (var2 (module-local-variable interface name))) + (if (not (eq? var1 var2)) + (begin + (if (not duplicates-interface) + (begin + (set! duplicates-interface + (make-duplicates-interface)) + (set-module-duplicates-interface! + module + duplicates-interface))) + (let* ((var (module-local-variable duplicates-interface + name)) + (val (and var + (variable-bound? var) + (variable-ref var)))) + (let loop ((duplicates-handlers duplicates-handlers)) + (cond ((null? duplicates-handlers)) + (((car duplicates-handlers) + module + name + prev-interface + (and (variable-bound? var1) + (variable-ref var1)) + interface + (and (variable-bound? var2) + (variable-ref var2)) + var + val) + => + (lambda (var) + (module-add! duplicates-interface name var))) + (else + (loop (cdr duplicates-handlers))))))))))))) + interface))) + + + +;;; {`cond-expand' for SRFI-0 support.} +;;; +;;; This syntactic form expands into different commands or +;;; definitions, depending on the features provided by the Scheme +;;; implementation. +;;; +;;; Syntax: +;;; +;;; +;;; --> (cond-expand +) +;;; | (cond-expand * (else )) +;;; +;;; --> ( *) +;;; +;;; --> +;;; | (and *) +;;; | (or *) +;;; | (not ) +;;; +;;; --> +;;; +;;; Additionally, this implementation provides the +;;; s `guile' and `r5rs', so that programs can +;;; determine the implementation type and the supported standard. +;;; +;;; Currently, the following feature identifiers are supported: +;;; +;;; guile r5rs srfi-0 srfi-4 srfi-6 srfi-13 srfi-14 srfi-55 srfi-61 +;;; +;;; Remember to update the features list when adding more SRFIs. +;;; + +(define %cond-expand-features + ;; Adjust the above comment when changing this. + '(guile + r5rs + srfi-0 ;; cond-expand itself + srfi-4 ;; homogenous numeric vectors + srfi-6 ;; open-input-string etc, in the guile core + srfi-13 ;; string library + srfi-14 ;; character sets + srfi-55 ;; require-extension + srfi-61 ;; general cond clause + )) + +;; This table maps module public interfaces to the list of features. +;; +(define %cond-expand-table (make-hash-table 31)) + +;; Add one or more features to the `cond-expand' feature list of the +;; module `module'. +;; +(define (cond-expand-provide module features) + (let ((mod (module-public-interface module))) + (and mod + (hashq-set! %cond-expand-table mod + (append (hashq-ref %cond-expand-table mod '()) + features))))) + +(define cond-expand + (procedure->memoizing-macro + (lambda (exp env) + (let ((clauses (cdr exp)) + (syntax-error (lambda (cl) + (error "invalid clause in `cond-expand'" cl)))) + (letrec + ((test-clause + (lambda (clause) + (cond + ((symbol? clause) + (or (memq clause %cond-expand-features) + (let lp ((uses (module-uses (env-module env)))) + (if (pair? uses) + (or (memq clause + (hashq-ref %cond-expand-table + (car uses) '())) + (lp (cdr uses))) + #f)))) + ((pair? clause) + (cond + ((eq? 'and (car clause)) + (let lp ((l (cdr clause))) + (cond ((null? l) + #t) + ((pair? l) + (and (test-clause (car l)) (lp (cdr l)))) + (else + (syntax-error clause))))) + ((eq? 'or (car clause)) + (let lp ((l (cdr clause))) + (cond ((null? l) + #f) + ((pair? l) + (or (test-clause (car l)) (lp (cdr l)))) + (else + (syntax-error clause))))) + ((eq? 'not (car clause)) + (cond ((not (pair? (cdr clause))) + (syntax-error clause)) + ((pair? (cddr clause)) + ((syntax-error clause)))) + (not (test-clause (cadr clause)))) + (else + (syntax-error clause)))) + (else + (syntax-error clause)))))) + (let lp ((c clauses)) + (cond + ((null? c) + (error "Unfulfilled `cond-expand'")) + ((not (pair? c)) + (syntax-error c)) + ((not (pair? (car c))) + (syntax-error (car c))) + ((test-clause (caar c)) + `(begin ,@(cdar c))) + ((eq? (caar c) 'else) + (if (pair? (cdr c)) + (syntax-error c)) + `(begin ,@(cdar c))) + (else + (lp (cdr c)))))))))) + +;; This procedure gets called from the startup code with a list of +;; numbers, which are the numbers of the SRFIs to be loaded on startup. +;; +(define (use-srfis srfis) + (process-use-modules + (map (lambda (num) + (list (list 'srfi (string->symbol + (string-append "srfi-" (number->string num)))))) + srfis))) + + + +;;; srfi-55: require-extension +;;; + +(define-macro (require-extension extension-spec) + ;; This macro only handles the srfi extension, which, at present, is + ;; the only one defined by the standard. + (if (not (pair? extension-spec)) + (scm-error 'wrong-type-arg "require-extension" + "Not an extension: ~S" (list extension-spec) #f)) + (let ((extension (car extension-spec)) + (extension-args (cdr extension-spec))) + (case extension + ((srfi) + (let ((use-list '())) + (for-each + (lambda (i) + (if (not (integer? i)) + (scm-error 'wrong-type-arg "require-extension" + "Invalid srfi name: ~S" (list i) #f)) + (let ((srfi-sym (string->symbol + (string-append "srfi-" (number->string i))))) + (if (not (memq srfi-sym %cond-expand-features)) + (set! use-list (cons `(use-modules (srfi ,srfi-sym)) + use-list))))) + extension-args) + (if (pair? use-list) + ;; i.e. (begin (use-modules x) (use-modules y) (use-modules z)) + `(begin ,@(reverse! use-list))))) + (else + (scm-error + 'wrong-type-arg "require-extension" + "Not a recognized extension type: ~S" (list extension) #f))))) + + + +;;; {Load emacs interface support if emacs option is given.} +;;; + +(define (named-module-use! user usee) + (module-use! (resolve-module user) (resolve-interface usee))) + +(define (load-emacs-interface) + (and (provided? 'debug-extensions) + (debug-enable 'backtrace)) + (named-module-use! '(guile-user) '(ice-9 emacs))) + + + +(define using-readline? + (let ((using-readline? (make-fluid))) + (make-procedure-with-setter + (lambda () (fluid-ref using-readline?)) + (lambda (v) (fluid-set! using-readline? v))))) + +(define (top-repl) + (let ((guile-user-module (resolve-module '(guile-user)))) + + ;; Load emacs interface support if emacs option is given. + (if (and (module-defined? guile-user-module 'use-emacs-interface) + (module-ref guile-user-module 'use-emacs-interface)) + (load-emacs-interface)) + + ;; Use some convenient modules (in reverse order) + + (set-current-module guile-user-module) + (process-use-modules + (append + '(((ice-9 r5rs)) + ((ice-9 session)) + ((ice-9 debug))) + (if (provided? 'regex) + '(((ice-9 regex))) + '()) + (if (provided? 'threads) + '(((ice-9 threads))) + '()))) + ;; load debugger on demand + (module-use! guile-user-module + (make-autoload-interface guile-user-module + '(ice-9 debugger) '(debug))) + + + ;; Note: SIGFPE, SIGSEGV and SIGBUS are actually "query-only" (see + ;; scmsigs.c scm_sigaction_for_thread), so the handlers setup here have + ;; no effect. + (let ((old-handlers #f) + (signals (if (provided? 'posix) + `((,SIGINT . "User interrupt") + (,SIGFPE . "Arithmetic error") + (,SIGSEGV + . "Bad memory access (Segmentation violation)")) + '()))) + ;; no SIGBUS on mingw + (if (defined? 'SIGBUS) + (set! signals (acons SIGBUS "Bad memory access (bus error)" + signals))) + + (dynamic-wind + + ;; call at entry + (lambda () + (let ((make-handler (lambda (msg) + (lambda (sig) + ;; Make a backup copy of the stack + (fluid-set! before-signal-stack + (fluid-ref the-last-stack)) + (save-stack 2) + (scm-error 'signal + #f + msg + #f + (list sig)))))) + (set! old-handlers + (map (lambda (sig-msg) + (sigaction (car sig-msg) + (make-handler (cdr sig-msg)))) + signals)))) + + ;; the protected thunk. + (lambda () + (let ((status (scm-style-repl))) + (run-hook exit-hook) + status)) + + ;; call at exit. + (lambda () + (map (lambda (sig-msg old-handler) + (if (not (car old-handler)) + ;; restore original C handler. + (sigaction (car sig-msg) #f) + ;; restore Scheme handler, SIG_IGN or SIG_DFL. + (sigaction (car sig-msg) + (car old-handler) + (cdr old-handler)))) + signals old-handlers)))))) + +;;; This hook is run at the very end of an interactive session. +;;; +(define exit-hook (make-hook)) + + + +;;; {Deprecated stuff} +;;; + +(begin-deprecated + (define (feature? sym) + (issue-deprecation-warning + "`feature?' is deprecated. Use `provided?' instead.") + (provided? sym))) + +(begin-deprecated + (primitive-load-path "ice-9/deprecated.scm")) + + + +;;; Place the user in the guile-user module. +;;; + +(define-module (guile-user)) + +;;; boot-9.scm ends here diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/buffered-input.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/buffered-input.scm new file mode 100755 index 0000000000000000000000000000000000000000..11530e89777a4574d1a1b03f3b13b477fb9ed483 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/buffered-input.scm @@ -0,0 +1,112 @@ +;;;; buffered-input.scm --- construct a port from a buffered input reader +;;;; +;;;; Copyright (C) 2001, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +(define-module (ice-9 buffered-input) + #:export (make-buffered-input-port + make-line-buffered-input-port + set-buffered-input-continuation?!)) + +;; @code{buffered-input-continuation?} is a property of the ports +;; created by @code{make-line-buffered-input-port} that stores the +;; read continuation flag for each such port. +(define buffered-input-continuation? (make-object-property)) + +(define (set-buffered-input-continuation?! port val) + "Set the read continuation flag for @var{port} to @var{val}. + +See @code{make-buffered-input-port} for the meaning and use of this +flag." + (set! (buffered-input-continuation? port) val)) + +(define (make-buffered-input-port reader) + "Construct a line-buffered input port from the specified @var{reader}. +@var{reader} should be a procedure of one argument that somehow reads +a chunk of input and returns it as a string. + +The port created by @code{make-buffered-input-port} does @emph{not} +interpolate any additional characters between the strings returned by +@var{reader}. + +@var{reader} should take a boolean @var{continuation?} argument. +@var{continuation?} indicates whether @var{reader} is being called to +start a logically new read operation (in which case +@var{continuation?} is @code{#f}) or to continue a read operation for +which some input has already been read (in which case +@var{continuation?} is @code{#t}). Some @var{reader} implementations +use the @var{continuation?} argument to determine what prompt to +display to the user. + +The new/continuation distinction is largely an application-level +concept: @code{set-buffered-input-continuation?!} allows an +application to specify when a read operation is considered to be new. +But note that if there is non-whitespace data already buffered in the +port when a new read operation starts, this data will be read before +the first call to @var{reader}, and so @var{reader} will be called +with @var{continuation?} set to @code{#t}." + (let ((read-string "") + (string-index -1)) + (letrec ((get-character + (lambda () + (cond + ((eof-object? read-string) + read-string) + ((>= string-index (string-length read-string)) + (set! string-index -1) + (get-character)) + ((= string-index -1) + (set! read-string (reader (buffered-input-continuation? port))) + (set! string-index 0) + (if (not (eof-object? read-string)) + (get-character) + read-string)) + (else + (let ((res (string-ref read-string string-index))) + (set! string-index (+ 1 string-index)) + (if (not (char-whitespace? res)) + (set! (buffered-input-continuation? port) #t)) + res))))) + (input-waiting + (lambda () + (if (eof-object? read-string) + 1 + (- (string-length read-string) string-index)))) + (port #f)) + (set! port (make-soft-port (vector #f #f #f get-character #f input-waiting) "r")) + (set! (buffered-input-continuation? port) #f) + port))) + +(define (make-line-buffered-input-port reader) + "Construct a line-buffered input port from the specified @var{reader}. +@var{reader} should be a procedure of one argument that somehow reads +a line of input and returns it as a string @emph{without} the +terminating newline character. + +The port created by @code{make-line-buffered-input-port} automatically +interpolates a newline character after each string returned by +@var{reader}. + +@var{reader} should take a boolean @var{continuation?} argument. For +the meaning and use of this argument, see +@code{make-buffered-input-port}." + (make-buffered-input-port (lambda (continuation?) + (let ((str (reader continuation?))) + (if (eof-object? str) + str + (string-append str "\n")))))) + +;;; buffered-input.scm ends here diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/calling.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/calling.scm new file mode 100755 index 0000000000000000000000000000000000000000..07f7a78057a03058d39c7da7903109fe8c8ae1e5 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/calling.scm @@ -0,0 +1,326 @@ +;;;; calling.scm --- Calling Conventions +;;;; +;;;; Copyright (C) 1995, 1996, 1997, 2000, 2001, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; + +(define-module (ice-9 calling) + :export-syntax (with-excursion-function + with-getter-and-setter + with-getter + with-delegating-getter-and-setter + with-excursion-getter-and-setter + with-configuration-getter-and-setter + with-delegating-configuration-getter-and-setter + let-with-configuration-getter-and-setter)) + +;;;; +;;; +;;; This file contains a number of macros that support +;;; common calling conventions. + +;;; +;;; with-excursion-function proc +;;; is an unevaluated list of names that are bound in the caller. +;;; proc is a procedure, called: +;;; (proc excursion) +;;; +;;; excursion is a procedure isolates all changes to +;;; in the dynamic scope of the call to proc. In other words, +;;; the values of are saved when proc is entered, and when +;;; proc returns, those values are restored. Values are also restored +;;; entering and leaving the call to proc non-locally, such as using +;;; call-with-current-continuation, error, or throw. +;;; +(defmacro with-excursion-function (vars proc) + `(,proc ,(excursion-function-syntax vars))) + + + +;;; with-getter-and-setter proc +;;; is an unevaluated list of names that are bound in the caller. +;;; proc is a procedure, called: +;;; (proc getter setter) +;;; +;;; getter and setter are procedures used to access +;;; or modify . +;;; +;;; setter, called with keywords arguments, modifies the named +;;; values. If "foo" and "bar" are among , then: +;;; +;;; (setter :foo 1 :bar 2) +;;; == (set! foo 1 bar 2) +;;; +;;; getter, called with just keywords, returns +;;; a list of the corresponding values. For example, +;;; if "foo" and "bar" are among the , then +;;; +;;; (getter :foo :bar) +;;; => ( ) +;;; +;;; getter, called with no arguments, returns a list of all accepted +;;; keywords and the corresponding values. If "foo" and "bar" are +;;; the *only* , then: +;;; +;;; (getter) +;;; => (:foo :bar ) +;;; +;;; The unusual calling sequence of a getter supports too handy +;;; idioms: +;;; +;;; (apply setter (getter)) ;; save and restore +;;; +;;; (apply-to-args (getter :foo :bar) ;; fetch and bind +;;; (lambda (foo bar) ....)) +;;; +;;; ;; [ "apply-to-args" is just like two-argument "apply" except that it +;;; ;; takes its arguments in a different order. +;;; +;;; +(defmacro with-getter-and-setter (vars proc) + `(,proc ,@ (getter-and-setter-syntax vars))) + +;;; with-getter vars proc +;;; A short-hand for a call to with-getter-and-setter. +;;; The procedure is called: +;;; (proc getter) +;;; +(defmacro with-getter (vars proc) + `(,proc ,(car (getter-and-setter-syntax vars)))) + + +;;; with-delegating-getter-and-setter get-delegate set-delegate proc +;;; Compose getters and setters. +;;; +;;; is an unevaluated list of names that are bound in the caller. +;;; +;;; get-delegate is called by the new getter to extend the set of +;;; gettable variables beyond just +;;; set-delegate is called by the new setter to extend the set of +;;; gettable variables beyond just +;;; +;;; proc is a procedure that is called +;;; (proc getter setter) +;;; +(defmacro with-delegating-getter-and-setter (vars get-delegate set-delegate proc) + `(,proc ,@ (delegating-getter-and-setter-syntax vars get-delegate set-delegate))) + + +;;; with-excursion-getter-and-setter proc +;;; is an unevaluated list of names that are bound in the caller. +;;; proc is called: +;;; +;;; (proc excursion getter setter) +;;; +;;; See also: +;;; with-getter-and-setter +;;; with-excursion-function +;;; +(defmacro with-excursion-getter-and-setter (vars proc) + `(,proc ,(excursion-function-syntax vars) + ,@ (getter-and-setter-syntax vars))) + + +(define (excursion-function-syntax vars) + (let ((saved-value-names (map gensym vars)) + (tmp-var-name (gensym "temp")) + (swap-fn-name (gensym "swap")) + (thunk-name (gensym "thunk"))) + `(lambda (,thunk-name) + (letrec ((,tmp-var-name #f) + (,swap-fn-name + (lambda () ,@ (map (lambda (n sn) + `(begin (set! ,tmp-var-name ,n) + (set! ,n ,sn) + (set! ,sn ,tmp-var-name))) + vars saved-value-names))) + ,@ (map (lambda (sn n) `(,sn ,n)) saved-value-names vars)) + (dynamic-wind + ,swap-fn-name + ,thunk-name + ,swap-fn-name))))) + + +(define (getter-and-setter-syntax vars) + (let ((args-name (gensym "args")) + (an-arg-name (gensym "an-arg")) + (new-val-name (gensym "new-value")) + (loop-name (gensym "loop")) + (kws (map symbol->keyword vars))) + (list `(lambda ,args-name + (let ,loop-name ((,args-name ,args-name)) + (if (null? ,args-name) + ,(if (null? kws) + ''() + `(let ((all-vals (,loop-name ',kws))) + (let ,loop-name ((vals all-vals) + (kws ',kws)) + (if (null? vals) + '() + `(,(car kws) ,(car vals) ,@(,loop-name (cdr vals) (cdr kws))))))) + (map (lambda (,an-arg-name) + (case ,an-arg-name + ,@ (append + (map (lambda (kw v) `((,kw) ,v)) kws vars) + `((else (throw 'bad-get-option ,an-arg-name)))))) + ,args-name)))) + + `(lambda ,args-name + (let ,loop-name ((,args-name ,args-name)) + (or (null? ,args-name) + (null? (cdr ,args-name)) + (let ((,an-arg-name (car ,args-name)) + (,new-val-name (cadr ,args-name))) + (case ,an-arg-name + ,@ (append + (map (lambda (kw v) `((,kw) (set! ,v ,new-val-name))) kws vars) + `((else (throw 'bad-set-option ,an-arg-name))))) + (,loop-name (cddr ,args-name))))))))) + +(define (delegating-getter-and-setter-syntax vars get-delegate set-delegate) + (let ((args-name (gensym "args")) + (an-arg-name (gensym "an-arg")) + (new-val-name (gensym "new-value")) + (loop-name (gensym "loop")) + (kws (map symbol->keyword vars))) + (list `(lambda ,args-name + (let ,loop-name ((,args-name ,args-name)) + (if (null? ,args-name) + (append! + ,(if (null? kws) + ''() + `(let ((all-vals (,loop-name ',kws))) + (let ,loop-name ((vals all-vals) + (kws ',kws)) + (if (null? vals) + '() + `(,(car kws) ,(car vals) ,@(,loop-name (cdr vals) (cdr kws))))))) + (,get-delegate)) + (map (lambda (,an-arg-name) + (case ,an-arg-name + ,@ (append + (map (lambda (kw v) `((,kw) ,v)) kws vars) + `((else (car (,get-delegate ,an-arg-name))))))) + ,args-name)))) + + `(lambda ,args-name + (let ,loop-name ((,args-name ,args-name)) + (or (null? ,args-name) + (null? (cdr ,args-name)) + (let ((,an-arg-name (car ,args-name)) + (,new-val-name (cadr ,args-name))) + (case ,an-arg-name + ,@ (append + (map (lambda (kw v) `((,kw) (set! ,v ,new-val-name))) kws vars) + `((else (,set-delegate ,an-arg-name ,new-val-name))))) + (,loop-name (cddr ,args-name))))))))) + + + + +;;; with-configuration-getter-and-setter proc +;;; +;;; Create a getter and setter that can trigger arbitrary computation. +;;; +;;; is a list of variable specifiers, explained below. +;;; proc is called: +;;; +;;; (proc getter setter) +;;; +;;; Each element of the list is of the form: +;;; +;;; ( getter-hook setter-hook) +;;; +;;; Both hook elements are evaluated; the variable name is not. +;;; Either hook may be #f or procedure. +;;; +;;; A getter hook is a thunk that returns a value for the corresponding +;;; variable. If omitted (#f is passed), the binding of is +;;; returned. +;;; +;;; A setter hook is a procedure of one argument that accepts a new value +;;; for the corresponding variable. If omitted, the binding of +;;; is simply set using set!. +;;; +(defmacro with-configuration-getter-and-setter (vars-etc proc) + `((lambda (simpler-get simpler-set body-proc) + (with-delegating-getter-and-setter () + simpler-get simpler-set body-proc)) + + (lambda (kw) + (case kw + ,@(map (lambda (v) `((,(symbol->keyword (car v))) + ,(cond + ((cadr v) => list) + (else `(list ,(car v)))))) + vars-etc))) + + (lambda (kw new-val) + (case kw + ,@(map (lambda (v) `((,(symbol->keyword (car v))) + ,(cond + ((caddr v) => (lambda (proc) `(,proc new-val))) + (else `(set! ,(car v) new-val))))) + vars-etc))) + + ,proc)) + +(defmacro with-delegating-configuration-getter-and-setter (vars-etc delegate-get delegate-set proc) + `((lambda (simpler-get simpler-set body-proc) + (with-delegating-getter-and-setter () + simpler-get simpler-set body-proc)) + + (lambda (kw) + (case kw + ,@(append! (map (lambda (v) `((,(symbol->keyword (car v))) + ,(cond + ((cadr v) => list) + (else `(list ,(car v)))))) + vars-etc) + `((else (,delegate-get kw)))))) + + (lambda (kw new-val) + (case kw + ,@(append! (map (lambda (v) `((,(symbol->keyword (car v))) + ,(cond + ((caddr v) => (lambda (proc) `(,proc new-val))) + (else `(set! ,(car v) new-val))))) + vars-etc) + `((else (,delegate-set kw new-val)))))) + + ,proc)) + + +;;; let-configuration-getter-and-setter proc +;;; +;;; This procedure is like with-configuration-getter-and-setter (q.v.) +;;; except that each element of is: +;;; +;;; ( initial-value getter-hook setter-hook) +;;; +;;; Unlike with-configuration-getter-and-setter, let-configuration-getter-and-setter +;;; introduces bindings for the variables named in . +;;; It is short-hand for: +;;; +;;; (let (( initial-value-1) +;;; ( initial-value-2) +;;; ...) +;;; (with-configuration-getter-and-setter (( v1-get v1-set) ...) proc)) +;;; +(defmacro let-with-configuration-getter-and-setter (vars-etc proc) + `(let ,(map (lambda (v) `(,(car v) ,(cadr v))) vars-etc) + (with-configuration-getter-and-setter ,(map (lambda (v) `(,(car v) ,(caddr v) ,(cadddr v))) vars-etc) + ,proc))) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/channel.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/channel.scm new file mode 100755 index 0000000000000000000000000000000000000000..8cbb001906fd23e171b57bd94a2baad4cc24896d --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/channel.scm @@ -0,0 +1,170 @@ +;;; Guile object channel + +;; Copyright (C) 2001, 2006 Free Software Foundation, Inc. + +;; This library is free software; you can redistribute it and/or +;; modify it under the terms of the GNU Lesser General Public +;; License as published by the Free Software Foundation; either +;; version 2.1 of the License, or (at your option) any later version. +;; +;; This library is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; Lesser General Public License for more details. +;; +;; You should have received a copy of the GNU Lesser General Public +;; License along with this library; if not, write to the Free Software +;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +;;; Commentary: + +;; Now you can use Guile's modules in Emacs Lisp like this: +;; +;; (guile-import current-module) +;; (guile-import module-ref) +;; +;; (setq assq (module-ref (current-module) 'assq)) +;; => ("" %%1%% . "#") +;; +;; (guile-use-modules (ice-9 documentation)) +;; +;; (object-documentation assq) +;; => +;; " - primitive: assq key alist +;; - primitive: assv key alist +;; - primitive: assoc key alist +;; Fetches the entry in ALIST that is associated with KEY. To decide +;; whether the argument KEY matches a particular entry in ALIST, +;; `assq' compares keys with `eq?', `assv' uses `eqv?' and `assoc' +;; uses `equal?'. If KEY cannot be found in ALIST (according to +;; whichever equality predicate is in use), then `#f' is returned. +;; These functions return the entire alist entry found (i.e. both the +;; key and the value)." +;; +;; Probably we can use GTK in Emacs Lisp. Can anybody try it? +;; +;; I have also implemented Guile Scheme mode and Scheme Interaction mode. +;; Just put the following lines in your ~/.emacs: +;; +;; (require 'guile-scheme) +;; (setq initial-major-mode 'scheme-interaction-mode) +;; +;; Currently, the following commands are available: +;; +;; M-TAB guile-scheme-complete-symbol +;; M-C-x guile-scheme-eval-define +;; C-x C-e guile-scheme-eval-last-sexp +;; C-c C-b guile-scheme-eval-buffer +;; C-c C-r guile-scheme-eval-region +;; C-c : guile-scheme-eval-expression +;; +;; I'll write more commands soon, or if you want to hack, please take +;; a look at the following files: +;; +;; guile-core/ice-9/channel.scm ;; object channel +;; guile-core/emacs/guile.el ;; object adapter +;; guile-core/emacs/guile-emacs.scm ;; Guile <-> Emacs channels +;; guile-core/emacs/guile-scheme.el ;; Guile Scheme mode +;; +;; As always, there are more than one bugs ;) + +;;; Code: + +(define-module (ice-9 channel) + :export (make-object-channel + channel-open + channel-print-value + channel-print-token)) + +;;; +;;; Channel type +;;; + +(define channel-type + (make-record-type 'channel '(stdin stdout printer token-module))) + +(define make-channel (record-constructor channel-type)) + +(define (make-object-channel printer) + (make-channel (current-input-port) + (current-output-port) + printer + (make-module))) + +(define channel-stdin (record-accessor channel-type 'stdin)) +(define channel-stdout (record-accessor channel-type 'stdout)) +(define channel-printer (record-accessor channel-type 'printer)) +(define channel-token-module (record-accessor channel-type 'token-module)) + +;;; +;;; Channel +;;; + +(define (channel-open ch) + (let ((stdin (channel-stdin ch)) + (stdout (channel-stdout ch)) + (printer (channel-printer ch)) + (token-module (channel-token-module ch))) + (let loop () + (catch #t + (lambda () + (channel:prompt stdout) + (let ((cmd (read stdin))) + (if (eof-object? cmd) + (throw 'quit) + (case cmd + ((eval) + (module-use! (current-module) token-module) + (printer ch (eval (read stdin) (current-module)))) + ((destroy) + (let ((token (read stdin))) + (if (module-defined? token-module token) + (module-remove! token-module token) + (channel:error stdout "Invalid token: ~S" token)))) + ((quit) + (throw 'quit)) + (else + (channel:error stdout "Unknown command: ~S" cmd))))) + (loop)) + (lambda (key . args) + (case key + ((quit) (throw 'quit)) + (else + (format stdout "exception = ~S\n" + (list key (apply format #f (cadr args) (caddr args)))) + (loop)))))))) + +(define (channel-print-value ch val) + (format (channel-stdout ch) "value = ~S\n" val)) + +(define (channel-print-token ch val) + (let* ((token (symbol-append (gensym "%%") '%%)) + (pair (cons token (object->string val)))) + (format (channel-stdout ch) "token = ~S\n" pair) + (module-define! (channel-token-module ch) token val))) + +(define (channel:prompt port) + (display "channel> " port) + (force-output port)) + +(define (channel:error port msg . args) + (display "ERROR: " port) + (apply format port msg args) + (newline port)) + +;;; +;;; Guile 1.4 compatibility +;;; + +(define guile:eval eval) +(define eval + (if (= (car (procedure-property guile:eval 'arity)) 1) + (lambda (x e) (guile:eval x)) + guile:eval)) + +(define object->string + (if (defined? 'object->string) + object->string + (lambda (x) (format #f "~S" x)))) + +;;; channel.scm ends here diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/common-list.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/common-list.scm new file mode 100755 index 0000000000000000000000000000000000000000..7d62bc319b0e2ff22500b78a32da69c3e6d2b44a --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/common-list.scm @@ -0,0 +1,278 @@ +;;;; common-list.scm --- COMMON LISP list functions for Scheme +;;;; +;;;; Copyright (C) 1995, 1996, 1997, 2001, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; + +;;; Commentary: + +;; These procedures are exported: +;; (adjoin e l) +;; (union l1 l2) +;; (intersection l1 l2) +;; (set-difference l1 l2) +;; (reduce-init p init l) +;; (reduce p l) +;; (some pred l . rest) +;; (every pred l . rest) +;; (notany pred . ls) +;; (notevery pred . ls) +;; (count-if pred l) +;; (find-if pred l) +;; (member-if pred l) +;; (remove-if pred l) +;; (remove-if-not pred l) +;; (delete-if! pred l) +;; (delete-if-not! pred l) +;; (butlast lst n) +;; (and? . args) +;; (or? . args) +;; (has-duplicates? lst) +;; (pick p l) +;; (pick-mappings p l) +;; (uniq l) +;; +;; See docstrings for each procedure for more info. See also module +;; `(srfi srfi-1)' for a complete list handling library. + +;;; Code: + +(define-module (ice-9 common-list) + :export (adjoin union intersection set-difference reduce-init reduce + some every notany notevery count-if find-if member-if remove-if + remove-if-not delete-if! delete-if-not! butlast and? or? + has-duplicates? pick pick-mappings uniq)) + +;;"comlist.scm" Implementation of COMMON LISP list functions for Scheme +; Copyright (C) 1991, 1993, 1995 Aubrey Jaffer. +; +;Permission to copy this software, to redistribute it, and to use it +;for any purpose is granted, subject to the following restrictions and +;understandings. +; +;1. Any copy made of this software must include this copyright notice +;in full. +; +;2. I have made no warrantee or representation that the operation of +;this software will be error-free, and I am under no obligation to +;provide any services, by way of maintenance, update, or otherwise. +; +;3. In conjunction with products arising from the use of this +;material, there shall be no use of my name in any advertising, +;promotional, or sales literature without prior written consent in +;each case. + +(define (adjoin e l) + "Return list L, possibly with element E added if it is not already in L." + (if (memq e l) l (cons e l))) + +(define (union l1 l2) + "Return a new list that is the union of L1 and L2. +Elements that occur in both lists occur only once in +the result list." + (cond ((null? l1) l2) + ((null? l2) l1) + (else (union (cdr l1) (adjoin (car l1) l2))))) + +(define (intersection l1 l2) + "Return a new list that is the intersection of L1 and L2. +Only elements that occur in both lists occur in the result list." + (if (null? l2) l2 + (let loop ((l1 l1) (result '())) + (cond ((null? l1) (reverse! result)) + ((memv (car l1) l2) (loop (cdr l1) (cons (car l1) result))) + (else (loop (cdr l1) result)))))) + +(define (set-difference l1 l2) + "Return elements from list L1 that are not in list L2." + (let loop ((l1 l1) (result '())) + (cond ((null? l1) (reverse! result)) + ((memv (car l1) l2) (loop (cdr l1) result)) + (else (loop (cdr l1) (cons (car l1) result)))))) + +(define (reduce-init p init l) + "Same as `reduce' except it implicitly inserts INIT at the start of L." + (if (null? l) + init + (reduce-init p (p init (car l)) (cdr l)))) + +(define (reduce p l) + "Combine all the elements of sequence L using a binary operation P. +The combination is left-associative. For example, using +, one can +add up all the elements. `reduce' allows you to apply a function which +accepts only two arguments to more than 2 objects. Functional +programmers usually refer to this as foldl." + (cond ((null? l) l) + ((null? (cdr l)) (car l)) + (else (reduce-init p (car l) (cdr l))))) + +(define (some pred l . rest) + "PRED is a boolean function of as many arguments as there are list +arguments to `some', i.e., L plus any optional arguments. PRED is +applied to successive elements of the list arguments in order. As soon +as one of these applications returns a true value, return that value. +If no application returns a true value, return #f. +All the lists should have the same length." + (cond ((null? rest) + (let mapf ((l l)) + (and (not (null? l)) + (or (pred (car l)) (mapf (cdr l)))))) + (else (let mapf ((l l) (rest rest)) + (and (not (null? l)) + (or (apply pred (car l) (map car rest)) + (mapf (cdr l) (map cdr rest)))))))) + +(define (every pred l . rest) + "Return #t iff every application of PRED to L, etc., returns #t. +Analogous to `some' except it returns #t if every application of +PRED is #t and #f otherwise." + (cond ((null? rest) + (let mapf ((l l)) + (or (null? l) + (and (pred (car l)) (mapf (cdr l)))))) + (else (let mapf ((l l) (rest rest)) + (or (null? l) + (and (apply pred (car l) (map car rest)) + (mapf (cdr l) (map cdr rest)))))))) + +(define (notany pred . ls) + "Return #t iff every application of PRED to L, etc., returns #f. +Analogous to some but returns #t if no application of PRED returns a +true value or #f as soon as any one does." + (not (apply some pred ls))) + +(define (notevery pred . ls) + "Return #t iff there is an application of PRED to L, etc., that returns #f. +Analogous to some but returns #t as soon as an application of PRED returns #f, +or #f otherwise." + (not (apply every pred ls))) + +(define (count-if pred l) + "Return the number of elements in L for which (PRED element) returns true." + (let loop ((n 0) (l l)) + (cond ((null? l) n) + ((pred (car l)) (loop (+ n 1) (cdr l))) + (else (loop n (cdr l)))))) + +(define (find-if pred l) + "Search for the first element in L for which (PRED element) returns true. +If found, return that element, otherwise return #f." + (cond ((null? l) #f) + ((pred (car l)) (car l)) + (else (find-if pred (cdr l))))) + +(define (member-if pred l) + "Return the first sublist of L for whose car PRED is true." + (cond ((null? l) #f) + ((pred (car l)) l) + (else (member-if pred (cdr l))))) + +(define (remove-if pred l) + "Remove all elements from L where (PRED element) is true. +Return everything that's left." + (let loop ((l l) (result '())) + (cond ((null? l) (reverse! result)) + ((pred (car l)) (loop (cdr l) result)) + (else (loop (cdr l) (cons (car l) result)))))) + +(define (remove-if-not pred l) + "Remove all elements from L where (PRED element) is #f. +Return everything that's left." + (let loop ((l l) (result '())) + (cond ((null? l) (reverse! result)) + ((not (pred (car l))) (loop (cdr l) result)) + (else (loop (cdr l) (cons (car l) result)))))) + +(define (delete-if! pred l) + "Destructive version of `remove-if'." + (let delete-if ((l l)) + (cond ((null? l) '()) + ((pred (car l)) (delete-if (cdr l))) + (else + (set-cdr! l (delete-if (cdr l))) + l)))) + +(define (delete-if-not! pred l) + "Destructive version of `remove-if-not'." + (let delete-if-not ((l l)) + (cond ((null? l) '()) + ((not (pred (car l))) (delete-if-not (cdr l))) + (else + (set-cdr! l (delete-if-not (cdr l))) + l)))) + +(define (butlast lst n) + "Return all but the last N elements of LST." + (letrec ((l (- (length lst) n)) + (bl (lambda (lst n) + (cond ((null? lst) lst) + ((positive? n) + (cons (car lst) (bl (cdr lst) (+ -1 n)))) + (else '()))))) + (bl lst (if (negative? n) + (error "negative argument to butlast" n) + l)))) + +(define (and? . args) + "Return #t iff all of ARGS are true." + (cond ((null? args) #t) + ((car args) (apply and? (cdr args))) + (else #f))) + +(define (or? . args) + "Return #t iff any of ARGS is true." + (cond ((null? args) #f) + ((car args) #t) + (else (apply or? (cdr args))))) + +(define (has-duplicates? lst) + "Return #t iff 2 members of LST are equal?, else #f." + (cond ((null? lst) #f) + ((member (car lst) (cdr lst)) #t) + (else (has-duplicates? (cdr lst))))) + +(define (pick p l) + "Apply P to each element of L, returning a list of elts +for which P returns a non-#f value." + (let loop ((s '()) + (l l)) + (cond + ((null? l) s) + ((p (car l)) (loop (cons (car l) s) (cdr l))) + (else (loop s (cdr l)))))) + +(define (pick-mappings p l) + "Apply P to each element of L, returning a list of the +non-#f return values of P." + (let loop ((s '()) + (l l)) + (cond + ((null? l) s) + ((p (car l)) => (lambda (mapping) (loop (cons mapping s) (cdr l)))) + (else (loop s (cdr l)))))) + +(define (uniq l) + "Return a list containing elements of L, with duplicates removed." + (let loop ((acc '()) + (l l)) + (if (null? l) + (reverse! acc) + (loop (if (memq (car l) acc) + acc + (cons (car l) acc)) + (cdr l))))) + +;;; common-list.scm ends here diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/debug.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/debug.scm new file mode 100755 index 0000000000000000000000000000000000000000..0e751590da0f4678ad9a66c6e9bcf5ad32f9d46a --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/debug.scm @@ -0,0 +1,134 @@ +;;;; Copyright (C) 1996, 1997, 1998, 1999, 2001, 2006 Free Software Foundation +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; +;;;; The author can be reached at djurfeldt@nada.kth.se +;;;; Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN +;;;; + + +(define-module (ice-9 debug) + :export (frame-number->index trace untrace trace-stack untrace-stack)) + + +;;; {Misc} +;;; +(define (frame-number->index n . stack) + (let ((stack (if (null? stack) + (fluid-ref the-last-stack) + (car stack)))) + (if (memq 'backwards (debug-options)) + n + (- (stack-length stack) n 1)))) + + +;;; {Trace} +;;; +;;; This code is just an experimental prototype (e. g., it is not +;;; thread safe), but since it's at the same time useful, it's +;;; included anyway. +;;; +(define traced-procedures '()) + +(define (trace . args) + (if (null? args) + (nameify traced-procedures) + (begin + (for-each (lambda (proc) + (if (not (procedure? proc)) + (error "trace: Wrong type argument:" proc)) + (set-procedure-property! proc 'trace #t) + (if (not (memq proc traced-procedures)) + (set! traced-procedures + (cons proc traced-procedures)))) + args) + (trap-set! apply-frame-handler trace-entry) + (trap-set! exit-frame-handler trace-exit) + ;; We used to reset `trace-level' here to 0, but this is wrong + ;; if `trace' itself is being traced, since `trace-exit' will + ;; then decrement `trace-level' to -1! It shouldn't actually + ;; be necessary to set `trace-level' here at all. + (debug-enable 'trace) + (nameify args)))) + +(define (untrace . args) + (if (and (null? args) + (not (null? traced-procedures))) + (apply untrace traced-procedures) + (begin + (for-each (lambda (proc) + (set-procedure-property! proc 'trace #f) + (set! traced-procedures (delq! proc traced-procedures))) + args) + (if (null? traced-procedures) + (debug-disable 'trace)) + (nameify args)))) + +(define (nameify ls) + (map (lambda (proc) + (let ((name (procedure-name proc))) + (or name proc))) + ls)) + +(define trace-level 0) +(add-hook! abort-hook (lambda () (set! trace-level 0))) + +(define traced-stack-ids (list 'repl-stack)) +(define trace-all-stacks? #f) + +(define (trace-stack id) + "Add ID to the set of stack ids for which tracing is active. +If `#t' is in this set, tracing is active regardless of stack context. +To remove ID again, use `untrace-stack'. If you add the same ID twice +using `trace-stack', you will need to remove it twice." + (set! traced-stack-ids (cons id traced-stack-ids)) + (set! trace-all-stacks? (memq #t traced-stack-ids))) + +(define (untrace-stack id) + "Remove ID from the set of stack ids for which tracing is active." + (set! traced-stack-ids (delq1! id traced-stack-ids)) + (set! trace-all-stacks? (memq #t traced-stack-ids))) + +(define (trace-entry key cont tail) + (if (or trace-all-stacks? + (memq (stack-id cont) traced-stack-ids)) + (let ((cep (current-error-port)) + (frame (last-stack-frame cont))) + (if (not tail) + (set! trace-level (+ trace-level 1))) + (let indent ((n trace-level)) + (cond ((> n 1) (display "| " cep) (indent (- n 1))))) + (display-application frame cep) + (newline cep))) + ;; It's not necessary to call the continuation since + ;; execution will continue if the handler returns + ;(cont #f) + ) + +(define (trace-exit key cont retval) + (if (or trace-all-stacks? + (memq (stack-id cont) traced-stack-ids)) + (let ((cep (current-error-port))) + (set! trace-level (- trace-level 1)) + (let indent ((n trace-level)) + (cond ((> n 0) (display "| " cep) (indent (- n 1))))) + (write retval cep) + (newline cep)))) + + +;;; A fix to get the error handling working together with the module system. +;;; +;;; XXX - Still needed? +(module-set! the-root-module 'debug-options debug-options) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/debugger.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugger.scm new file mode 100755 index 0000000000000000000000000000000000000000..0ad01488146085e1aeeb3cee79283d8eddcf4b94 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugger.scm @@ -0,0 +1,146 @@ +;;;; Guile Debugger + +;;; Copyright (C) 1999, 2001, 2002, 2006 Free Software Foundation, Inc. +;;; +;; This library is free software; you can redistribute it and/or +;; modify it under the terms of the GNU Lesser General Public +;; License as published by the Free Software Foundation; either +;; version 2.1 of the License, or (at your option) any later version. +;; +;; This library is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; Lesser General Public License for more details. +;; +;; You should have received a copy of the GNU Lesser General Public +;; License along with this library; if not, write to the Free Software +;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +(define-module (ice-9 debugger) + #:use-module (ice-9 debugger command-loop) + #:use-module (ice-9 debugger state) + #:use-module (ice-9 debugger utils) + #:use-module (ice-9 format) + #:export (debug-stack + debug + debug-last-error + debugger-error + debugger-quit + debugger-input-port + debugger-output-port + debug-on-error) + #:no-backtrace) + +;;; The old (ice-9 debugger) has been factored into its constituent +;;; parts: +;;; +;;; (ice-9 debugger) - public interface to all of the following +;;; +;;; (... commands) - procedures implementing the guts of the commands +;;; provided by the interactive debugger +;;; +;;; (... command-loop) - binding these commands into the interactive +;;; debugger command loop +;;; +;;; (... state) - implementation of an object that tracks current +;;; debugger state +;;; +;;; (... utils) - utilities for printing out frame and stack +;;; information in various formats +;;; +;;; The division between (... commands) and (... command-loop) exists +;;; because I (NJ) have another generic command loop implementation +;;; under development, and I want to be able to switch easily between +;;; that and the command loop implementation here. Thus the +;;; procedures in this file delegate to a debugger command loop +;;; implementation via the `debugger-command-loop-*' interface. The +;;; (ice-9 debugger command-loop) implementation can be replaced by +;;; any other that implements the `debugger-command-loop-*' interface +;;; simply by changing the relevant #:use-module line above. +;;; +;;; - Neil Jerram 2002-10-26, updated 2005-07-09 + +(define *not-yet-introduced* #t) + +(define (debug-stack stack . flags) + "Invoke the Guile debugger to explore the specified @var{stack}. + +@var{flags}, if present, are keywords indicating characteristics of +the debugging session: the valid keywords are as follows. + +@table @code +@item #:continuable +Indicates that the debugger is being invoked from a context (such as +an evaluator trap handler) where it is possible to return from the +debugger and continue normal code execution. This enables the +@dfn{continuing execution} commands, for example @code{continue} and +@code{step}. + +@item #:with-introduction +Indicates that the debugger should display an introductory message. +@end table" + (start-stack 'debugger + (let ((state (apply make-state stack 0 flags))) + (with-input-from-port (debugger-input-port) + (lambda () + (with-output-to-port (debugger-output-port) + (lambda () + (if (or *not-yet-introduced* + (memq #:with-introduction flags)) + (let ((ssize (stack-length stack))) + (display "This is the Guile debugger -- for help, type `help'.\n") + (set! *not-yet-introduced* #f) + (if (= ssize 1) + (display "There is 1 frame on the stack.\n\n") + (format #t "There are ~A frames on the stack.\n\n" ssize)))) + (write-state-short state) + (debugger-command-loop state)))))))) + +(define (debug) + "Invoke the Guile debugger to explore the context of the last error." + (let ((stack (fluid-ref the-last-stack))) + (if stack + (debug-stack stack) + (display "Nothing to debug.\n")))) + +(define debug-last-error debug) + +(define (debugger-error message) + "Signal a debugger usage error with message @var{message}." + (debugger-command-loop-error message)) + +(define (debugger-quit) + "Exit the debugger." + (debugger-command-loop-quit)) + +;;; {Debugger Input and Output Ports} + +(define debugger-input-port + (let ((input-port (current-input-port))) + (make-procedure-with-setter + (lambda () input-port) + (lambda (port) (set! input-port port))))) + +(define debugger-output-port + (let ((output-port (current-output-port))) + (make-procedure-with-setter + (lambda () output-port) + (lambda (port) (set! output-port port))))) + +;;; {Debug on Error} + +(define (debug-on-error syms) + "Enable or disable debug on error." + (set! lazy-handler-dispatch + (if syms + (lambda (key . args) + (if (memq key syms) + (begin + (debug-stack (make-stack #t lazy-handler-dispatch) + #:with-introduction + #:continuable) + (throw 'abort key))) + (apply default-lazy-handler key args)) + default-lazy-handler))) + +;;; (ice-9 debugger) ends here. diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/command-loop.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/command-loop.scm new file mode 100755 index 0000000000000000000000000000000000000000..62a08ea6542cf2d9fe1e82b0a576bed3eef12f64 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/command-loop.scm @@ -0,0 +1,542 @@ +;;;; Guile Debugger command loop + +;;; Copyright (C) 1999, 2001, 2002, 2003, 2006 Free Software Foundation, Inc. +;;; +;; This library is free software; you can redistribute it and/or +;; modify it under the terms of the GNU Lesser General Public +;; License as published by the Free Software Foundation; either +;; version 2.1 of the License, or (at your option) any later version. +;; +;; This library is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; Lesser General Public License for more details. +;; +;; You should have received a copy of the GNU Lesser General Public +;; License along with this library; if not, write to the Free Software +;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +(define-module (ice-9 debugger command-loop) + #:use-module ((ice-9 debugger commands) :prefix debugger:) + #:export (debugger-command-loop + debugger-command-loop-error + debugger-command-loop-quit) + #:no-backtrace) + +;;; {Interface used by (ice-9 debugger).} + +(define (debugger-command-loop state) + (read-and-dispatch-commands state (current-input-port))) + +(define (debugger-command-loop-error message) + (user-error message)) + +(define (debugger-command-loop-quit) + (throw 'exit-debugger)) + +;;; {Implementation.} + +(define debugger-prompt "debug> ") + +(define (debugger-handler key . args) + (case key + ((exit-debugger) #f) + ((signal) + ;; Restore stack + (fluid-set! the-last-stack (fluid-ref before-signal-stack)) + (apply display-error #f (current-error-port) args)) + (else + (display "Internal debugger error:\n") + (save-stack debugger-handler) + (apply throw key args))) + (throw 'exit-debugger)) ;Pop the stack + +(define (read-and-dispatch-commands state port) + (catch 'exit-debugger + (lambda () + (lazy-catch #t + (lambda () + (with-fluids ((last-command #f)) + (let loop () + (read-and-dispatch-command state port) + (loop)))) + debugger-handler)) + (lambda args + *unspecified*))) + +(define set-readline-prompt! #f) + +(define (read-and-dispatch-command state port) + (if (using-readline?) + (begin + ;; Import set-readline-prompt! if we haven't already. + (or set-readline-prompt! + (set! set-readline-prompt! + (module-ref (resolve-module '(ice-9 readline)) + 'set-readline-prompt!))) + (set-readline-prompt! debugger-prompt debugger-prompt)) + (display debugger-prompt)) + (force-output) ;This should not be necessary... + (let ((token (read-token port))) + (cond ((eof-object? token) + (throw 'exit-debugger)) + ((not token) + (discard-rest-of-line port) + (catch-user-errors port (lambda () (run-last-command state)))) + (else + (catch-user-errors port + (lambda () + (dispatch-command token command-table state port))))))) + +(define (run-last-command state) + (let ((procedure (fluid-ref last-command))) + (if procedure + (procedure state)))) + +(define (catch-user-errors port thunk) + (catch 'debugger-user-error + thunk + (lambda (key . objects) + (apply user-warning objects) + (discard-rest-of-line port)))) + +(define last-command (make-fluid)) + +(define (user-warning . objects) + (for-each (lambda (object) + (display object)) + objects) + (newline)) + +(define (user-error . objects) + (apply throw 'debugger-user-error objects)) + +;;;; Command dispatch + +(define (dispatch-command string table state port) + (let ((value (command-table-value table string))) + (if value + (dispatch-command/value value state port) + (user-error "Unknown command: " string)))) + +(define (dispatch-command/value value state port) + (cond ((command? value) + (dispatch-command/command value state port)) + ((command-table? value) + (dispatch-command/table value state port)) + ((list? value) + (dispatch-command/name value state port)) + (else + (error "Unrecognized command-table value: " value)))) + +(define (dispatch-command/command command state port) + (let ((procedure (command-procedure command)) + (arguments ((command-parser command) port))) + (let ((procedure (lambda (state) (apply procedure state arguments)))) + (warn-about-extra-args port) + (fluid-set! last-command procedure) + (procedure state)))) + +(define (warn-about-extra-args port) + ;; **** modify this to show the arguments. + (let ((char (skip-whitespace port))) + (cond ((eof-object? char) #f) + ((char=? #\newline char) (read-char port)) + (else + (user-warning "Extra arguments at end of line: " + (read-rest-of-line port)))))) + +(define (dispatch-command/table table state port) + (let ((token (read-token port))) + (if (or (eof-object? token) + (not token)) + (user-error "Command name too short.") + (dispatch-command token table state port)))) + +(define (dispatch-command/name name state port) + (let ((value (lookup-command name))) + (cond ((not value) + (apply user-error "Unknown command name: " name)) + ((command-table? value) + (apply user-error "Partial command name: " name)) + (else + (dispatch-command/value value state port))))) + +;;;; Command definition + +(define (define-command name argument-template procedure) + (let ((name (canonicalize-command-name name))) + (add-command name + (make-command name + (argument-template->parser argument-template) + (procedure-documentation procedure) + procedure) + command-table) + name)) + +(define (define-command-alias name1 name2) + (let ((name1 (canonicalize-command-name name1))) + (add-command name1 (canonicalize-command-name name2) command-table) + name1)) + +(define (argument-template->parser template) + ;; Deliberately handles only cases that occur in "commands.scm". + (cond ((eq? 'tokens template) + (lambda (port) + (let loop ((tokens '())) + (let ((token (read-token port))) + (if (or (eof-object? token) + (not token)) + (list (reverse! tokens)) + (loop (cons token tokens))))))) + ((null? template) + (lambda (port) + '())) + ((and (pair? template) + (null? (cdr template)) + (eq? 'object (car template))) + (lambda (port) + (list (read port)))) + ((and (pair? template) + (equal? ''optional (car template)) + (pair? (cdr template)) + (null? (cddr template))) + (case (cadr template) + ((token) + (lambda (port) + (let ((token (read-token port))) + (if (or (eof-object? token) + (not token)) + (list #f) + (list token))))) + ((exact-integer) + (lambda (port) + (list (parse-optional-exact-integer port)))) + ((exact-nonnegative-integer) + (lambda (port) + (list (parse-optional-exact-nonnegative-integer port)))) + ((object) + (lambda (port) + (list (parse-optional-object port)))) + (else + (error "Malformed argument template: " template)))) + (else + (error "Malformed argument template: " template)))) + +(define (parse-optional-exact-integer port) + (let ((object (parse-optional-object port))) + (if (or (not object) + (and (integer? object) + (exact? object))) + object + (user-error "Argument not an exact integer: " object)))) + +(define (parse-optional-exact-nonnegative-integer port) + (let ((object (parse-optional-object port))) + (if (or (not object) + (and (integer? object) + (exact? object) + (not (negative? object)))) + object + (user-error "Argument not an exact non-negative integer: " object)))) + +(define (parse-optional-object port) + (let ((terminator (skip-whitespace port))) + (if (or (eof-object? terminator) + (eq? #\newline terminator)) + #f + (let ((object (read port))) + (if (eof-object? object) + #f + object))))) + +;;;; Command tables + +(define (lookup-command name) + (let loop ((table command-table) (strings name)) + (let ((value (command-table-value table (car strings)))) + (cond ((or (not value) (null? (cdr strings))) value) + ((command-table? value) (loop value (cdr strings))) + (else #f))))) + +(define (command-table-value table string) + (let ((entry (command-table-entry table string))) + (and entry + (caddr entry)))) + +(define (command-table-entry table string) + (let loop ((entries (command-table-entries table))) + (and (not (null? entries)) + (let ((entry (car entries))) + (if (and (<= (cadr entry) + (string-length string) + (string-length (car entry))) + (= (string-length string) + (match-strings (car entry) string))) + entry + (loop (cdr entries))))))) + +(define (match-strings s1 s2) + (let ((n (min (string-length s1) (string-length s2)))) + (let loop ((i 0)) + (cond ((= i n) i) + ((char=? (string-ref s1 i) (string-ref s2 i)) (loop (+ i 1))) + (else i))))) + +(define (write-command-name name) + (display (car name)) + (for-each (lambda (string) + (write-char #\space) + (display string)) + (cdr name))) + +(define (add-command name value table) + (let loop ((strings name) (table table)) + (let ((entry + (or (let loop ((entries (command-table-entries table))) + (and (not (null? entries)) + (if (string=? (car strings) (caar entries)) + (car entries) + (loop (cdr entries))))) + (let ((entry (list (car strings) #f #f))) + (let ((entries + (let ((entries (command-table-entries table))) + (if (or (null? entries) + (stringstring (reverse! chars)))))) + (skip-whitespace port) + (loop '()))) + +(define (skip-whitespace port) + (let ((char (peek-char port))) + (cond ((or (eof-object? char) + (char=? #\newline char)) + char) + ((char-whitespace? char) + (read-char port) + (skip-whitespace port)) + ((char=? #\# char) + (read-char port) + (skip-comment port)) + (else char)))) + +(define (skip-comment port) + (let ((char (peek-char port))) + (if (or (eof-object? char) + (char=? #\newline char)) + char + (begin + (read-char port) + (skip-comment port))))) + +(define (read-rest-of-line port) + (let loop ((chars '())) + (let ((char (read-char port))) + (if (or (eof-object? char) + (char=? #\newline char)) + (list->string (reverse! chars)) + (loop (cons char chars)))))) + +(define (discard-rest-of-line port) + (let loop () + (if (not (let ((char (read-char port))) + (or (eof-object? char) + (char=? #\newline char)))) + (loop)))) + +;;;; Commands + +(define command-table (make-command-table '())) + +(define-command "help" 'tokens + (lambda (state tokens) + "Type \"help\" followed by a command name for full documentation." + (let loop ((name (if (null? tokens) '("help") tokens))) + (let ((value (lookup-command name))) + (cond ((not value) + (write-command-name name) + (display " is not a known command name.") + (newline)) + ((command? value) + (display (command-documentation value)) + (newline) + (if (equal? '("help") (command-name value)) + (begin + (display "Available commands are:") + (newline) + (for-each (lambda (entry) + (if (not (list? (caddr entry))) + (begin + (display " ") + (display (car entry)) + (newline)))) + (command-table-entries command-table))))) + ((command-table? value) + (display "The \"") + (write-command-name name) + (display "\" command requires a subcommand.") + (newline) + (display "Available subcommands are:") + (newline) + (for-each (lambda (entry) + (if (not (list? (caddr entry))) + (begin + (display " ") + (write-command-name name) + (write-char #\space) + (display (car entry)) + (newline)))) + (command-table-entries value))) + ((list? value) + (loop value)) + (else + (error "Unknown value from lookup-command:" value))))) + state)) + +(define-command "frame" '('optional exact-nonnegative-integer) debugger:frame) + +(define-command "position" '() debugger:position) + +(define-command "up" '('optional exact-integer) debugger:up) + +(define-command "down" '('optional exact-integer) debugger:down) + +(define-command "backtrace" '('optional exact-integer) debugger:backtrace) + +(define-command "evaluate" '(object) debugger:evaluate) + +(define-command '("info" "args") '() debugger:info-args) + +(define-command '("info" "frame") '() debugger:info-frame) + +(define-command "quit" '() + (lambda (state) + "Exit the debugger." + (debugger-command-loop-quit))) + +(define-command-alias "f" "frame") +(define-command-alias '("info" "f") '("info" "frame")) +(define-command-alias "bt" "backtrace") +(define-command-alias "where" "backtrace") +(define-command-alias "p" "evaluate") +(define-command-alias '("info" "stack") "backtrace") diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/commands.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/commands.scm new file mode 100755 index 0000000000000000000000000000000000000000..ef6f79026eb8ece2fd69e6e28bd6e0f804ccfaf6 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/commands.scm @@ -0,0 +1,154 @@ +;;;; (ice-9 debugger commands) -- debugger commands + +;;; Copyright (C) 2002, 2006 Free Software Foundation, Inc. +;;; +;; This library is free software; you can redistribute it and/or +;; modify it under the terms of the GNU Lesser General Public +;; License as published by the Free Software Foundation; either +;; version 2.1 of the License, or (at your option) any later version. +;; +;; This library is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; Lesser General Public License for more details. +;; +;; You should have received a copy of the GNU Lesser General Public +;; License along with this library; if not, write to the Free Software +;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +(define-module (ice-9 debugger commands) + #:use-module (ice-9 debug) + #:use-module (ice-9 debugger) + #:use-module (ice-9 debugger state) + #:use-module (ice-9 debugger utils) + #:export (backtrace + evaluate + info-args + info-frame + position + up + down + frame)) + +(define (backtrace state n-frames) + "Print backtrace of all stack frames, or innermost COUNT frames. +With a negative argument, print outermost -COUNT frames. +If the number of frames isn't explicitly given, the debug option +`depth' determines the maximum number of frames printed." + (let ((stack (state-stack state))) + ;; Kludge around lack of call-with-values. + (let ((values + (lambda (start end) + (display-backtrace stack + (current-output-port) + (if (memq 'backwards (debug-options)) + start + (- end 1)) + (- end start)) + ))) + (let ((end (stack-length stack))) + (cond ((not n-frames) ;(>= (abs n-frames) end)) + (values 0 (min end (cadr (memq 'depth (debug-options)))))) + ((>= n-frames 0) + (values 0 n-frames)) + (else + (values (+ end n-frames) end))))))) + +(define (eval-handler key . args) + (let ((stack (make-stack #t eval-handler))) + (if (= (length args) 4) + (apply display-error stack (current-error-port) args) + ;; We want display-error to be the "final common pathway" + (catch #t + (lambda () + (apply bad-throw key args)) + (lambda (key . args) + (apply display-error stack (current-error-port) args))))) + (throw 'continue)) + +(define (evaluate state expression) + "Evaluate an expression in the environment of the selected stack frame. +The expression must appear on the same line as the command, however it +may be continued over multiple lines." + (let ((source (frame-source (stack-ref (state-stack state) + (state-index state))))) + (if (not source) + (display "No environment for this frame.\n") + (catch 'continue + (lambda () + (lazy-catch #t + (lambda () + (let* ((expr + ;; We assume that no one will + ;; really want to evaluate a + ;; string (since it is + ;; self-evaluating); so if we + ;; have a string here, read the + ;; expression to evaluate from + ;; it. + (if (string? expression) + (with-input-from-string expression + read) + expression)) + (env (memoized-environment source)) + (value (local-eval expr env))) + (write expr) + (display " => ") + (write value) + (newline))) + eval-handler)) + (lambda args args))))) + +(define (info-args state) + "Display the argument variables of the current stack frame. +Arguments can also be seen in the backtrace, but are presented more +clearly by this command." + (let ((index (state-index state))) + (let ((frame (stack-ref (state-stack state) index))) + (write-frame-index-long frame) + (write-frame-args-long frame)))) + +(define (info-frame state) + "Display a verbose description of the selected frame. The +information that this command provides is equivalent to what can be +deduced from the one line summary for the frame that appears in a +backtrace, but is presented and explained more clearly." + (write-state-long state)) + +(define (position state) + "Display the name of the source file that the current expression +comes from, and the line and column number of the expression's opening +parenthesis within that file. This information is only available when +the 'positions read option is enabled." + (let* ((frame (stack-ref (state-stack state) (state-index state))) + (source (frame-source frame))) + (if (not source) + (display "No source available for this frame.") + (let ((position (source-position source))) + (if (not position) + (display "No position information available for this frame.") + (display-position position))))) + (newline)) + +(define (up state n) + "Move @var{n} frames up the stack. For positive @var{n}, this +advances toward the outermost frame, to lower frame numbers, to +frames that have existed longer. @var{n} defaults to one." + (set-stack-index! state (+ (state-index state) (or n 1))) + (write-state-short state)) + +(define (down state n) + "Move @var{n} frames down the stack. For positive @var{n}, this +advances toward the innermost frame, to higher frame numbers, to frames +that were created more recently. @var{n} defaults to one." + (set-stack-index! state (- (state-index state) (or n 1))) + (write-state-short state)) + +(define (frame state n) + "Select and print a stack frame. +With no argument, print the selected stack frame. (See also \"info frame\"). +An argument specifies the frame to select; it must be a stack-frame number." + (if n (set-stack-index! state (frame-number->index n (state-stack state)))) + (write-state-short state)) + +;;; (ice-9 debugger commands) ends here. diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/state.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/state.scm new file mode 100755 index 0000000000000000000000000000000000000000..11b8ebbf079d45f523075e83d5e6f2461cd26b8b --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/state.scm @@ -0,0 +1,47 @@ +;;;; (ice-9 debugger state) -- debugger state representation + +;;; Copyright (C) 2002, 2006 Free Software Foundation, Inc. +;;; +;; This library is free software; you can redistribute it and/or +;; modify it under the terms of the GNU Lesser General Public +;; License as published by the Free Software Foundation; either +;; version 2.1 of the License, or (at your option) any later version. +;; +;; This library is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; Lesser General Public License for more details. +;; +;; You should have received a copy of the GNU Lesser General Public +;; License along with this library; if not, write to the Free Software +;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +(define-module (ice-9 debugger state) + #:export (make-state + state-stack + state-index + state-flags + set-stack-index!)) + +(define state-rtd (make-record-type "debugger-state" '(stack index flags))) +(define state? (record-predicate state-rtd)) +(define make-state + (let ((make-state-internal (record-constructor state-rtd + '(stack index flags)))) + (lambda (stack index . flags) + (make-state-internal stack index flags)))) +(define state-stack (record-accessor state-rtd 'stack)) +(define state-index (record-accessor state-rtd 'index)) +(define state-flags (record-accessor state-rtd 'flags)) + +(define set-state-index! (record-modifier state-rtd 'index)) + +(define (set-stack-index! state index) + (let* ((stack (state-stack state)) + (ssize (stack-length stack))) + (set-state-index! state + (cond ((< index 0) 0) + ((>= index ssize) (- ssize 1)) + (else index))))) + +;;; (ice-9 debugger state) ends here. diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/trc.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/trc.scm new file mode 100755 index 0000000000000000000000000000000000000000..49af2747d9160f44ef818f87d39fe306c0a2a550 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/trc.scm @@ -0,0 +1,63 @@ +;;;; (ice-9 debugger trc) -- tracing for Guile debugger code + +;;; Copyright (C) 2002, 2006 Free Software Foundation, Inc. +;;; +;; This library is free software; you can redistribute it and/or +;; modify it under the terms of the GNU Lesser General Public +;; License as published by the Free Software Foundation; either +;; version 2.1 of the License, or (at your option) any later version. +;; +;; This library is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; Lesser General Public License for more details. +;; +;; You should have received a copy of the GNU Lesser General Public +;; License along with this library; if not, write to the Free Software +;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +(define-module (ice-9 debugger trc) + #:export (trc trc-syms trc-all trc-none trc-add trc-remove trc-port)) + +(define *syms* #f) + +(define (trc-set! syms) + (set! *syms* syms)) + +(define (trc-syms . syms) + (trc-set! syms)) + +(define (trc-all) + (trc-set! #f)) + +(define (trc-none) + (trc-set! '())) + +(define (trc-add sym) + (trc-set! (cons sym *syms*))) + +(define (trc-remove sym) + (trc-set! (delq1! sym *syms*))) + +(define (trc sym . args) + (if (or (not *syms*) + (memq sym *syms*)) + (let ((port (trc-port))) + (write sym port) + (display ":" port) + (for-each (lambda (arg) + (display " " port) + (write arg port)) + args) + (newline port)))) + +(define trc-port + (let ((port (current-error-port))) + (make-procedure-with-setter + (lambda () port) + (lambda (p) (set! port p))))) + +;; Default to no tracing. +(trc-none) + +;;; (ice-9 debugger trc) ends here. diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/utils.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/utils.scm new file mode 100755 index 0000000000000000000000000000000000000000..dfef25b1f57c359682d8ec6fc57fd68f8aa8274b --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/utils.scm @@ -0,0 +1,203 @@ + +(define-module (ice-9 debugger utils) + #:use-module (ice-9 debugger state) + #:export (display-position + source-position + write-frame-args-long + write-frame-index-long + write-frame-short/expression + write-frame-short/application + write-frame-long + write-state-long + write-state-short)) + +;;; Procedures in this module print information about a stack frame. +;;; The available information is as follows. +;;; +;;; * Source code location. +;;; +;;; For an evaluation frame, this is the location recorded at the time +;;; that the expression being evaluated was read, if the 'positions +;;; read option was enabled at that time. +;;; +;;; For an application frame, I'm not yet sure. Some applications +;;; seem to have associated source expressions. +;;; +;;; * Whether frame is still evaluating its arguments. +;;; +;;; Only applies to an application frame. For example, an expression +;;; like `(+ (* 2 3) 4)' goes through the following stages of +;;; evaluation. +;;; +;;; (+ (* 2 3) 4) -- evaluation +;;; [+ ... -- application; the car of the evaluation +;;; has been evaluated and found to be a +;;; procedure; before this procedure can +;;; be applied, its arguments must be evaluated +;;; [+ 6 ... -- same application after evaluating the +;;; first argument +;;; [+ 6 4] -- same application after evaluating all +;;; arguments +;;; 10 -- result +;;; +;;; * Whether frame is real or tail-recursive. +;;; +;;; If a frame is tail-recursive, its containing frame as shown by the +;;; debugger backtrace doesn't really exist as far as the Guile +;;; evaluator is concerned. The effect of this is that when a +;;; tail-recursive frame returns, it looks as though its containing +;;; frame returns at the same time. (And if the containing frame is +;;; also tail-recursive, _its_ containing frame returns at that time +;;; also, and so on ...) +;;; +;;; A `real' frame is one that is not tail-recursive. + + +(define (write-state-short state) + (let* ((frame (stack-ref (state-stack state) (state-index state))) + (source (frame-source frame)) + (position (and source (source-position source)))) + (format #t "Frame ~A at " (frame-number frame)) + (if position + (display-position position) + (display "unknown source location")) + (newline) + (write-char #\tab) + (write-frame-short frame) + (newline))) + +(define (write-state-short* stack index) + (write-frame-index-short stack index) + (write-char #\space) + (write-frame-short (stack-ref stack index)) + (newline)) + +(define (write-frame-index-short stack index) + (let ((s (number->string (frame-number (stack-ref stack index))))) + (display s) + (write-char #\:) + (write-chars #\space (- 4 (string-length s))))) + +(define (write-frame-short frame) + (if (frame-procedure? frame) + (write-frame-short/application frame) + (write-frame-short/expression frame))) + +(define (write-frame-short/application frame) + (write-char #\[) + (write (let ((procedure (frame-procedure frame))) + (or (and (procedure? procedure) + (procedure-name procedure)) + procedure))) + (if (frame-evaluating-args? frame) + (display " ...") + (begin + (for-each (lambda (argument) + (write-char #\space) + (write argument)) + (frame-arguments frame)) + (write-char #\])))) + +;;; Use builtin function instead: +(set! write-frame-short/application + (lambda (frame) + (display-application frame (current-output-port) 12))) + +(define (write-frame-short/expression frame) + (write (let* ((source (frame-source frame)) + (copy (source-property source 'copy))) + (if (pair? copy) + copy + (unmemoize-expr source))))) + +(define (write-state-long state) + (let ((index (state-index state))) + (let ((frame (stack-ref (state-stack state) index))) + (write-frame-index-long frame) + (write-frame-long frame)))) + +(define (write-frame-index-long frame) + (display "Stack frame: ") + (write (frame-number frame)) + (if (frame-real? frame) + (display " (real)")) + (newline)) + +(define (write-frame-long frame) + (if (frame-procedure? frame) + (write-frame-long/application frame) + (write-frame-long/expression frame))) + +(define (write-frame-long/application frame) + (display "This frame is an application.") + (newline) + (if (frame-source frame) + (begin + (display "The corresponding expression is:") + (newline) + (display-source frame) + (newline))) + (display "The procedure being applied is: ") + (write (let ((procedure (frame-procedure frame))) + (or (and (procedure? procedure) + (procedure-name procedure)) + procedure))) + (newline) + (display "The procedure's arguments are") + (if (frame-evaluating-args? frame) + (display " being evaluated.") + (begin + (display ": ") + (write (frame-arguments frame)))) + (newline)) + +(define (display-source frame) + (let* ((source (frame-source frame)) + (copy (source-property source 'copy))) + (cond ((source-position source) + => (lambda (p) (display-position p) (display ":\n")))) + (display " ") + (write (or copy (unmemoize-expr source))))) + +(define (source-position source) + (let ((fname (source-property source 'filename)) + (line (source-property source 'line)) + (column (source-property source 'column))) + (and fname + (list fname line column)))) + +(define (display-position pos) + (format #t "~A:~D:~D" (car pos) (+ 1 (cadr pos)) (+ 1 (caddr pos)))) + +(define (write-frame-long/expression frame) + (display "This frame is an evaluation.") + (newline) + (display "The expression being evaluated is:") + (newline) + (display-source frame) + (newline)) + +(define (write-frame-args-long frame) + (if (frame-procedure? frame) + (let ((arguments (frame-arguments frame))) + (let ((n (length arguments))) + (display "This frame has ") + (write n) + (display " argument") + (if (not (= n 1)) + (display "s")) + (write-char (if (null? arguments) #\. #\:)) + (newline)) + (for-each (lambda (argument) + (display " ") + (write argument) + (newline)) + arguments)) + (begin + (display "This frame is an evaluation frame; it has no arguments.") + (newline)))) + +(define (write-chars char n) + (do ((i 0 (+ i 1))) + ((>= i n)) + (write-char char))) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/example-fns.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/example-fns.scm new file mode 100755 index 0000000000000000000000000000000000000000..30d412f00773047a1396d725821078be22e65548 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/example-fns.scm @@ -0,0 +1,17 @@ +(define-module (ice-9 debugging example-fns) + #:export (fact1 fact2 facti)) + +(define (fact1 n) + (if (= n 0) + 1 + (* n (fact1 (- n 1))))) + +(define (facti n a) + (if (= n 0) + a + (facti (- n 1) (* a n)))) + +(define (fact2 n) + (facti n 1)) + +; Test: (fact2 3) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/ice-9-debugger-extensions.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/ice-9-debugger-extensions.scm new file mode 100755 index 0000000000000000000000000000000000000000..fe04fc0118ccde1f431eecd776d6a305f5e128ca --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/ice-9-debugger-extensions.scm @@ -0,0 +1,173 @@ + +(define-module (ice-9 debugging ice-9-debugger-extensions) + #:use-module (ice-9 debugger)) + +;;; Upgrade the debugger state object so that it can carry a flag +;;; indicating whether the debugging session is continuable. + +(cond ((string>=? (version) "1.7") + (use-modules (ice-9 debugger state)) + (define-module (ice-9 debugger state))) + (else + (define-module (ice-9 debugger)))) + +(set! state-rtd (make-record-type "debugger-state" '(stack index flags))) +(set! state? (record-predicate state-rtd)) +(set! make-state + (let ((make-state-internal (record-constructor state-rtd + '(stack index flags)))) + (lambda (stack index . flags) + (make-state-internal stack index flags)))) +(set! state-stack (record-accessor state-rtd 'stack)) +(set! state-index (record-accessor state-rtd 'index)) + +(define state-flags (record-accessor state-rtd 'flags)) + +;;; Add commands that (ice-9 debugger) doesn't currently have, for +;;; continuing or single stepping program execution. + +(cond ((string>=? (version) "1.7") + (use-modules (ice-9 debugger command-loop)) + (define-module (ice-9 debugger command-loop) + #:use-module (ice-9 debugger) + #:use-module (ice-9 debugger state) + #:use-module (ice-9 debugging traps)) + (define new-define-command define-command) + (set! define-command + (lambda (name argument-template documentation procedure) + (new-define-command name argument-template procedure)))) + (else + (define-module (ice-9 debugger)))) + +(use-modules (ice-9 debugging steps) + (ice-9 debugging trace)) + +(define (assert-continuable state) + ;; Check that debugger is in a state where `continuing' makes sense. + ;; If not, signal an error. + (or (memq #:continuable (state-flags state)) + (user-error "This debug session is not continuable."))) + +(define (debugger:continue state) + "Tell the program being debugged to continue running. (In fact this is +the same as the @code{quit} command, because it exits the debugger +command loop and so allows whatever code it was that invoked the +debugger to continue.)" + (assert-continuable state) + (throw 'exit-debugger)) + +(define (debugger:finish state) + "Continue until evaluation of the current frame is complete, and +print the result obtained." + (assert-continuable state) + (at-exit (- (stack-length (state-stack state)) + (state-index state)) + (list trace-trap debug-trap)) + (debugger:continue state)) + +(define (debugger:step state n) + "Tell the debugged program to do @var{n} more steps from its current +position. One @dfn{step} means executing until the next frame entry +or exit of any kind. @var{n} defaults to 1." + (assert-continuable state) + (at-step debug-trap (or n 1)) + (debugger:continue state)) + +(define (debugger:next state n) + "Tell the debugged program to do @var{n} more steps from its current +position, but only counting frame entries and exits where the +corresponding source code comes from the same file as the current +stack frame. (See @ref{Step Traps} for the details of how this +works.) If the current stack frame has no source code, the effect of +this command is the same as of @code{step}. @var{n} defaults to 1." + (assert-continuable state) + (at-step debug-trap + (or n 1) + (frame-file-name (stack-ref (state-stack state) + (state-index state))) + (if (memq #:return (state-flags state)) + #f + (- (stack-length (state-stack state)) (state-index state)))) + (debugger:continue state)) + +(define-command "continue" '() + "Continue program execution." + debugger:continue) + +(define-command "finish" '() + "Continue until evaluation of the current frame is complete, and +print the result obtained." + debugger:finish) + +(define-command "step" '('optional exact-integer) + "Continue until entry to @var{n}th next frame." + debugger:step) + +(define-command "next" '('optional exact-integer) + "Continue until entry to @var{n}th next frame in same file." + debugger:next) + +;;; Export a couple of procedures for use by (ice-9 debugging trace). + +(cond ((string>=? (version) "1.7")) + (else + (define-module (ice-9 debugger)) + (export write-frame-short/expression + write-frame-short/application))) + +;;; Provide a `debug-trap' entry point in (ice-9 debugger). This is +;;; designed so that it can be called to explore the stack at a +;;; breakpoint, and to single step from the breakpoint. + +(define-module (ice-9 debugger)) + +(use-modules (ice-9 debugging traps)) + +(define *not-yet-introduced* #t) + +(cond ((string>=? (version) "1.7")) + (else + (define (debugger-command-loop state) + (read-and-dispatch-commands state (current-input-port))))) + +(define-public (debug-trap trap-context) + "Invoke the Guile debugger to explore the stack at the specified @var{trap}." + (start-stack 'debugger + (let* ((stack (tc:stack trap-context)) + (flags1 (let ((trap-type (tc:type trap-context))) + (case trap-type + ((#:return #:error) + (list trap-type + (tc:return-value trap-context))) + (else + (list trap-type))))) + (flags (if (tc:continuation trap-context) + (cons #:continuable flags1) + flags1)) + (state (apply make-state stack 0 flags))) + (if *not-yet-introduced* + (let ((ssize (stack-length stack))) + (display "This is the Guile debugger -- for help, type `help'.\n") + (set! *not-yet-introduced* #f) + (if (= ssize 1) + (display "There is 1 frame on the stack.\n\n") + (format #t "There are ~A frames on the stack.\n\n" ssize)))) + (write-state-short-with-source-location state) + (debugger-command-loop state)))) + +(define write-state-short-with-source-location + (cond ((string>=? (version) "1.7") + write-state-short) + (else + (lambda (state) + (let* ((frame (stack-ref (state-stack state) (state-index state))) + (source (frame-source frame)) + (position (and source (source-position source)))) + (format #t "Frame ~A at " (frame-number frame)) + (if position + (display-position position) + (display "unknown source location")) + (newline) + (write-char #\tab) + (write-frame-short frame) + (newline)))))) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/steps.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/steps.scm new file mode 100755 index 0000000000000000000000000000000000000000..fedbc6a326c0cb9b0a3bf39fb3bd83b81add951c --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/steps.scm @@ -0,0 +1,106 @@ +;;;; (ice-9 debugging steps) -- stepping through code from the debugger + +;;; Copyright (C) 2002, 2004 Free Software Foundation, Inc. +;;; +;; This library is free software; you can redistribute it and/or +;; modify it under the terms of the GNU Lesser General Public +;; License as published by the Free Software Foundation; either +;; version 2.1 of the License, or (at your option) any later version. +;; +;; This library is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; Lesser General Public License for more details. +;; +;; You should have received a copy of the GNU Lesser General Public +;; License along with this library; if not, write to the Free Software +;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +(define-module (ice-9 debugging steps) + #:use-module (ice-9 debugging traps) + #:use-module (ice-9 and-let-star) + #:use-module (ice-9 debugger) + #:use-module (ice-9 optargs) + #:export (at-exit + at-entry + at-apply + at-step + at-next)) + +;;; at-exit DEPTH BEHAVIOUR +;;; +;;; Install a behaviour to run when we exit the current frame. + +(define (at-exit depth behaviour) + (install-trap (make + #:depth depth + #:single-shot #t + #:behaviour behaviour))) + +;;; at-entry BEHAVIOUR [COUNT] +;;; +;;; Install a behaviour to run when we get to the COUNT'th next frame +;;; entry. COUNT defaults to 1. + +(define* (at-entry behaviour #:optional (count 1)) + (install-trap (make + #:skip-count (- count 1) + #:single-shot #t + #:behaviour behaviour))) + +;;; at-apply BEHAVIOUR [COUNT] +;;; +;;; Install a behaviour to run when we get to the COUNT'th next +;;; application. COUNT defaults to 1. + +(define* (at-apply behaviour #:optional (count 1)) + (install-trap (make + #:skip-count (- count 1) + #:single-shot #t + #:behaviour behaviour))) + +;;; at-step BEHAVIOUR [COUNT [FILENAME [DEPTH]] +;;; +;;; Install BEHAVIOUR to run on the COUNT'th next application, frame +;;; entry or frame exit. COUNT defaults to 1. If FILENAME is +;;; specified and not #f, only frames that begin in the named file are +;;; counted. + +(define* (at-step behaviour #:optional (count 1) filename (depth 1000)) + (install-trap (make + #:file-name filename + #:exit-depth depth + #:skip-count (- count 1) + #:single-shot #t + #:behaviour behaviour))) + +;; (or count (set! count 1)) +;; (letrec ((proc (lambda (trap-context) +;; ;; Behaviour whenever we enter or exit a frame. +;; (set! count (- count 1)) +;; (if (= count 0) +;; (begin +;; (remove-enter-frame-hook! step) +;; (remove-apply-frame-hook! step) +;; (behaviour trap-context))))) +;; (step (lambda (trap-context) +;; ;; Behaviour on frame entry: both execute the above +;; ;; and install it as an exit hook. +;; (if (or (not filename) +;; (equal? (frame-file-name (tc:frame trap-context)) +;; filename)) +;; (begin +;; (proc trap-context) +;; (at-exit (tc:depth trap-context) proc)))))) +;; (at-exit depth proc) +;; (add-enter-frame-hook! step) +;; (add-apply-frame-hook! step))) + +;;; at-next BEHAVIOUR [COUNT] +;;; +;;; Install a behaviour to run when we get to the COUNT'th next frame +;;; entry in the same source file as the current location. COUNT +;;; defaults to 1. If the current location has no filename, fall back +;;; silently to `at-entry' behaviour. + +;;; (ice-9 debugging steps) ends here. diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/trace.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/trace.scm new file mode 100755 index 0000000000000000000000000000000000000000..ad3015ddfe6dab56e3a411de6822a1552895b699 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/trace.scm @@ -0,0 +1,157 @@ +;;;; (ice-9 debugging trace) -- breakpoint trace behaviour + +;;; Copyright (C) 2002 Free Software Foundation, Inc. +;;; +;; This library is free software; you can redistribute it and/or +;; modify it under the terms of the GNU Lesser General Public +;; License as published by the Free Software Foundation; either +;; version 2.1 of the License, or (at your option) any later version. +;; +;; This library is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; Lesser General Public License for more details. +;; +;; You should have received a copy of the GNU Lesser General Public +;; License along with this library; if not, write to the Free Software +;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +(define-module (ice-9 debugging trace) + #:use-module (ice-9 debug) + #:use-module (ice-9 debugger) + #:use-module (ice-9 debugging ice-9-debugger-extensions) + #:use-module (ice-9 debugging steps) + #:use-module (ice-9 debugging traps) + #:export (trace-trap + trace-port + set-trace-layout + trace/pid + trace/stack-id + trace/stack-depth + trace/stack-real-depth + trace/stack + trace/source-file-name + trace/source-line + trace/source-column + trace/source + trace/type + trace/real? + trace/info + trace-at-exit + trace-until-exit)) + +(cond ((string>=? (version) "1.7") + (use-modules (ice-9 debugger utils)))) + +(define trace-format-string #f) +(define trace-arg-procs #f) + +(define (set-trace-layout format-string . arg-procs) + (set! trace-format-string format-string) + (set! trace-arg-procs arg-procs)) + +(define (trace/pid trap-context) + (getpid)) + +(define (trace/stack-id trap-context) + (stack-id (tc:stack trap-context))) + +(define (trace/stack-depth trap-context) + (tc:depth trap-context)) + +(define (trace/stack-real-depth trap-context) + (tc:real-depth trap-context)) + +(define (trace/stack trap-context) + (format #f "~a:~a+~a" + (stack-id (tc:stack trap-context)) + (tc:real-depth trap-context) + (- (tc:depth trap-context) (tc:real-depth trap-context)))) + +(define (trace/source-file-name trap-context) + (cond ((frame->source-position (tc:frame trap-context)) => car) + (else ""))) + +(define (trace/source-line trap-context) + (cond ((frame->source-position (tc:frame trap-context)) => cadr) + (else 0))) + +(define (trace/source-column trap-context) + (cond ((frame->source-position (tc:frame trap-context)) => caddr) + (else 0))) + +(define (trace/source trap-context) + (cond ((frame->source-position (tc:frame trap-context)) + => + (lambda (pos) + (format #f "~a:~a:~a" (car pos) (cadr pos) (caddr pos)))) + (else ""))) + +(define (trace/type trap-context) + (case (tc:type trap-context) + ((#:application) "APP") + ((#:evaluation) "EVA") + ((#:return) "RET") + ((#:error) "ERR") + (else "???"))) + +(define (trace/real? trap-context) + (if (frame-real? (tc:frame trap-context)) " " "t")) + +(define (trace/info trap-context) + (with-output-to-string + (lambda () + (if (memq (tc:type trap-context) '(#:application #:evaluation)) + ((if (tc:expression trap-context) + write-frame-short/expression + write-frame-short/application) (tc:frame trap-context)) + (begin + (display "=>") + (write (tc:return-value trap-context))))))) + +(set-trace-layout "|~3@a: ~a\n" trace/stack-real-depth trace/info) + +;;; trace-trap +;;; +;;; Trace the current location, and install a hook to trace the return +;;; value when we exit the current frame. + +(define (trace-trap trap-context) + (apply format + (trace-port) + trace-format-string + (map (lambda (arg-proc) + (arg-proc trap-context)) + trace-arg-procs))) + +(set! (behaviour-ordering trace-trap) 50) + +;;; trace-port +;;; +;;; The port to which trace information is printed. + +(define trace-port + (let ((port (current-output-port))) + (make-procedure-with-setter + (lambda () port) + (lambda (new) (set! port new))))) + +;;; trace-at-exit +;;; +;;; Trace return value on exit from the current frame. + +(define (trace-at-exit trap-context) + (at-exit (tc:depth trap-context) trace-trap)) + +;;; trace-until-exit +;;; +;;; Trace absolutely everything until exit from the current frame. + +(define (trace-until-exit trap-context) + (let ((step-trap (make #:behaviour trace-trap))) + (install-trap step-trap) + (at-exit (tc:depth trap-context) + (lambda (trap-context) + (uninstall-trap step-trap))))) + +;;; (ice-9 debugging trace) ends here. diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/traps.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/traps.scm new file mode 100755 index 0000000000000000000000000000000000000000..080d7bc31dd84c07fabb3f3d505d961c626c9e22 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/traps.scm @@ -0,0 +1,1037 @@ +;;;; (ice-9 debugging traps) -- abstraction of libguile's traps interface + +;;; Copyright (C) 2002, 2004 Free Software Foundation, Inc. +;;; Copyright (C) 2005 Neil Jerram +;;; +;; This library is free software; you can redistribute it and/or +;; modify it under the terms of the GNU Lesser General Public +;; License as published by the Free Software Foundation; either +;; version 2.1 of the License, or (at your option) any later version. +;; +;; This library is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; Lesser General Public License for more details. +;; +;; You should have received a copy of the GNU Lesser General Public +;; License along with this library; if not, write to the Free Software +;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +;;; This module provides an abstraction around Guile's low level trap +;;; handler interface; its aim is to make the low level trap mechanism +;;; shareable between the debugger and other applications, and to +;;; insulate the rest of the debugger code a bit from changes that may +;;; occur in the low level trap interface in future. + +(define-module (ice-9 debugging traps) + #:use-module (ice-9 regex) + #:use-module (oop goops) + #:use-module (oop goops describe) + #:use-module (ice-9 debugging trc) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-2) + #:export (tc:type + tc:continuation + tc:expression + tc:return-value + tc:stack + tc:frame + tc:depth + tc:real-depth + tc:exit-depth + tc:fired-traps + ;; Interface for users of subclasses defined in + ;; this module. + add-trapped-stack-id! + remove-trapped-stack-id! + + + + + + + + install-trap + uninstall-trap + all-traps + get-trap + list-traps + trap-ordering + behaviour-ordering + throw->trap-context + on-lazy-handler-dispatch + ;; Interface for authors of new subclasses. + + + trap->behaviour + trap-runnable? + install-apply-frame-trap + install-breakpoint-trap + install-enter-frame-trap + install-exit-frame-trap + install-trace-trap + uninstall-apply-frame-trap + uninstall-breakpoint-trap + uninstall-enter-frame-trap + uninstall-exit-frame-trap + uninstall-trace-trap + frame->source-position + frame-file-name + without-traps + guile-trap-features) + #:re-export (make) + #:export-syntax (trap-here)) + +;; How to debug the debugging infrastructure, when needed. Grep for +;; "(trc " to find other symbols that can be passed to trc-add. +;; (trc-add 'after-gc-hook) + +;; In Guile 1.7 onwards, weak-vector and friends are provided by the +;; (ice-9 weak-vector) module. +(cond ((string>=? (version) "1.7") + (use-modules (ice-9 weak-vector)))) + +;;; The current low level traps interface is as follows. +;;; +;;; All trap handlers are subject to SCM_TRAPS_P, which is controlled +;;; by the `traps' setting of `(evaluator-traps-interface)' but also +;;; (and more relevant in most cases) by the `with-traps' procedure. +;;; Basically, `with-traps' sets SCM_TRAPS_P to 1 during execution of +;;; its thunk parameter. +;;; +;;; Note that all trap handlers are called with SCM_TRAPS_P set to 0 +;;; for the duration of the call, to avoid nasty recursive trapping +;;; loops. If a trap handler knows what it is doing, it can override +;;; this by `(trap-enable traps)'. +;;; +;;; The apply-frame handler is called when Guile is about to perform +;;; an application if EITHER the `apply-frame' evaluator trap option +;;; is set, OR the `trace' debug option is set and the procedure to +;;; apply has its `trace' procedure property set. The arguments +;;; passed are: +;;; +;;; - the symbol 'apply-frame +;;; +;;; - a continuation or debug object describing the current stack +;;; +;;; - a boolean indicating whether the application is tail-recursive. +;;; +;;; The enter-frame handler is called when the evaluator begins a new +;;; evaluation frame if EITHER the `enter-frame' evaluator trap option +;;; is set, OR the `breakpoints' debug option is set and the code to +;;; be evaluated has its `breakpoint' source property set. The +;;; arguments passed are: +;;; +;;; - the symbol 'enter-frame +;;; +;;; - a continuation or debug object describing the current stack +;;; +;;; - a boolean indicating whether the application is tail-recursive. +;;; +;;; - an unmemoized copy of the expression to be evaluated. +;;; +;;; If the `enter-frame' evaluator trap option is set, the enter-frame +;;; handler is also called when about to perform an application in +;;; SCM_APPLY, immediately before possibly calling the apply-frame +;;; handler. (I don't totally understand this.) In this case, the +;;; arguments passed are: +;;; +;;; - the symbol 'enter-frame +;;; +;;; - a continuation or debug object describing the current stack. +;;; +;;; The exit-frame handler is called when Guile exits an evaluation +;;; frame (in SCM_CEVAL) or an application frame (in SCM_APPLY), if +;;; EITHER the `exit-frame' evaluator trap option is set, OR the +;;; `trace' debug option is set and the frame is marked as having been +;;; traced. The frame will be marked as having been traced if the +;;; apply-frame handler was called for this frame. (This is trickier +;;; than it sounds because of tail recursion: the same debug frame +;;; could have been used for multiple applications, only some of which +;;; were traced - I think.) The arguments passed are: +;;; +;;; - the symbol 'exit-frame +;;; +;;; - a continuation or debug object describing the current stack +;;; +;;; - the result of the evaluation or application. + +;;; {Trap Context} +;;; +;;; A trap context is a GOOPS object that encapsulates all the useful +;;; information about a particular trap. Encapsulating this +;;; information in a single object also allows us: +;;; +;;; - to defer the calculation of information that is time-consuming +;;; to calculate, such as the stack, and to cache such information so +;;; that it is only ever calculated once per trap +;;; +;;; - to pass all interesting information to trap behaviour procedures +;;; in a single parameter, which (i) is convenient and (ii) makes for +;;; a more future-proof interface. +;;; +;;; It also allows us - where very carefully documented! - to pass +;;; information from one behaviour procedure to another. + +(define-class () + ;; Information provided directly by the trap calls from the + ;; evaluator. The "type" slot holds a keyword indicating the type + ;; of the trap: one of #:evaluation, #:application, #:return, + ;; #:error. + (type #:getter tc:type + #:init-keyword #:type) + ;; The "continuation" slot holds the continuation (or debug object, + ;; if "cheap" traps are enabled, which is the default) at the point + ;; of the trap. For an error trap it is #f. + (continuation #:getter tc:continuation + #:init-keyword #:continuation) + ;; The "expression" slot holds the source code expression, for an + ;; evaluation trap. + (expression #:getter tc:expression + #:init-keyword #:expression + #:init-value #f) + ;; The "return-value" slot holds the return value, for a return + ;; trap, or the error args, for an error trap. + (return-value #:getter tc:return-value + #:init-keyword #:return-value + #:init-value #f) + ;; The list of trap objects which fired in this trap context. + (fired-traps #:getter tc:fired-traps + #:init-value '()) + ;; The set of symbols which, if one of them is set in the CAR of the + ;; handler-return-value slot, will cause the CDR of that slot to + ;; have an effect. + (handler-return-syms #:init-value '()) + ;; The value which the trap handler should return to the evaluator. + (handler-return-value #:init-value #f) + ;; Calculated and cached information. "stack" is the stack + ;; (computed from the continuation (or debug object) by make-stack, + ;; or else (in the case of an error trap) by (make-stack #t ...). + (stack #:init-value #f) + (frame #:init-value #f) + (depth #:init-value #f) + (real-depth #:init-value #f) + (exit-depth #:init-value #f)) + +(define-method (tc:stack (ctx )) + (or (slot-ref ctx 'stack) + (let ((stack (make-stack (tc:continuation ctx)))) + (slot-set! ctx 'stack stack) + stack))) + +(define-method (tc:frame (ctx )) + (or (slot-ref ctx 'frame) + (let ((frame (cond ((tc:continuation ctx) => last-stack-frame) + (else (stack-ref (tc:stack ctx) 0))))) + (slot-set! ctx 'frame frame) + frame))) + +(define-method (tc:depth (ctx )) + (or (slot-ref ctx 'depth) + (let ((depth (stack-length (tc:stack ctx)))) + (slot-set! ctx 'depth depth) + depth))) + +(define-method (tc:real-depth (ctx )) + (or (slot-ref ctx 'real-depth) + (let* ((stack (tc:stack ctx)) + (real-depth (apply + + (map (lambda (i) + (if (frame-real? (stack-ref stack i)) + 1 + 0)) + (iota (tc:depth ctx)))))) + (slot-set! ctx 'real-depth real-depth) + real-depth))) + +(define-method (tc:exit-depth (ctx )) + (or (slot-ref ctx 'exit-depth) + (let* ((stack (tc:stack ctx)) + (depth (tc:depth ctx)) + (exit-depth (let loop ((exit-depth depth)) + (if (or (zero? exit-depth) + (frame-real? (stack-ref stack + (- depth + exit-depth)))) + exit-depth + (loop (- exit-depth 1)))))) + (slot-set! ctx 'exit-depth exit-depth) + exit-depth))) + +;;; {Stack IDs} +;;; +;;; Mechanism for limiting trapping to contexts whose stack ID matches +;;; one of a registered set. The default is for traps to fire +;;; regardless of stack ID. + +(define trapped-stack-ids (list #t)) +(define all-stack-ids-trapped? #t) + +(define (add-trapped-stack-id! id) + "Add ID to the set of stack ids for which traps are active. +If `#t' is in this set, traps are active regardless of stack context. +To remove ID again, use `remove-trapped-stack-id!'. If you add the +same ID twice using `add-trapped-stack-id!', you will need to remove +it twice." + (set! trapped-stack-ids (cons id trapped-stack-ids)) + (set! all-stack-ids-trapped? (memq #t trapped-stack-ids))) + +(define (remove-trapped-stack-id! id) + "Remove ID from the set of stack ids for which traps are active." + (set! trapped-stack-ids (delq1! id trapped-stack-ids)) + (set! all-stack-ids-trapped? (memq #t trapped-stack-ids))) + +(define (trap-here? cont) + ;; Return true if the stack id of the specified continuation (or + ;; debug object) is in the set that we should trap for; otherwise + ;; false. + (or all-stack-ids-trapped? + (memq (stack-id cont) trapped-stack-ids))) + +;;; {Global State} +;;; +;;; Variables tracking registered handlers, relevant procedures, and +;;; what's turned on as regards the evaluator's debugging options. + +(define enter-frame-traps '()) +(define apply-frame-traps '()) +(define exit-frame-traps '()) +(define breakpoint-traps '()) +(define trace-traps '()) + +(define (non-null? hook) + (not (null? hook))) + +;; The low level frame handlers must all be initialized to something +;; harmless. Otherwise we hit a problem immediately when trying to +;; enable one of these handlers. +(trap-set! enter-frame-handler noop) +(trap-set! apply-frame-handler noop) +(trap-set! exit-frame-handler noop) + +(define set-debug-and-trap-options + (let ((dopts (debug-options)) + (topts (evaluator-traps-interface)) + (setting (lambda (key opts) + (let ((l (memq key opts))) + (and l + (not (null? (cdr l))) + (cadr l))))) + (debug-set-boolean! (lambda (key value) + ((if value debug-enable debug-disable) key))) + (trap-set-boolean! (lambda (key value) + ((if value trap-enable trap-disable) key)))) + (let ((save-debug (memq 'debug dopts)) + (save-trace (memq 'trace dopts)) + (save-breakpoints (memq 'breakpoints dopts)) + (save-enter-frame (memq 'enter-frame topts)) + (save-apply-frame (memq 'apply-frame topts)) + (save-exit-frame (memq 'exit-frame topts)) + (save-enter-frame-handler (setting 'enter-frame-handler topts)) + (save-apply-frame-handler (setting 'apply-frame-handler topts)) + (save-exit-frame-handler (setting 'exit-frame-handler topts))) + (lambda () + (let ((need-trace (non-null? trace-traps)) + (need-breakpoints (non-null? breakpoint-traps)) + (need-enter-frame (non-null? enter-frame-traps)) + (need-apply-frame (non-null? apply-frame-traps)) + (need-exit-frame (non-null? exit-frame-traps))) + (debug-set-boolean! 'debug + (or need-trace + need-breakpoints + need-enter-frame + need-apply-frame + need-exit-frame + save-debug)) + (debug-set-boolean! 'trace + (or need-trace + save-trace)) + (debug-set-boolean! 'breakpoints + (or need-breakpoints + save-breakpoints)) + (trap-set-boolean! 'enter-frame + (or need-enter-frame + save-enter-frame)) + (trap-set-boolean! 'apply-frame + (or need-apply-frame + save-apply-frame)) + (trap-set-boolean! 'exit-frame + (or need-exit-frame + save-exit-frame)) + (trap-set! enter-frame-handler + (cond ((or need-breakpoints + need-enter-frame) + enter-frame-handler) + (else save-enter-frame-handler))) + (trap-set! apply-frame-handler + (cond ((or need-trace + need-apply-frame) + apply-frame-handler) + (else save-apply-frame-handler))) + (trap-set! exit-frame-handler + (cond ((or need-exit-frame) + exit-frame-handler) + (else save-exit-frame-handler)))) + ;;(write (evaluator-traps-interface)) + *unspecified*)))) + +(define (enter-frame-handler key cont . args) + ;; For a non-application entry, ARGS is (TAIL? EXP), where EXP is an + ;; unmemoized copy of the source expression. For an application + ;; entry, ARGS is empty. + (if (trap-here? cont) + (let* ((application-entry? (null? args)) + (trap-context (make + #:type #:evaluation + #:continuation cont + #:expression (if application-entry? + #f + (cadr args))))) + (trc 'enter-frame-handler) + (if (and (not application-entry?) + (memq 'tweaking guile-trap-features)) + (slot-set! trap-context 'handler-return-syms '(instead))) + (run-traps (if application-entry? + enter-frame-traps + (append enter-frame-traps breakpoint-traps)) + trap-context) + (slot-ref trap-context 'handler-return-value)))) + +(define (apply-frame-handler key cont tail?) + (if (trap-here? cont) + (let ((trap-context (make + #:type #:application + #:continuation cont))) + (trc 'apply-frame-handler tail?) + (run-traps (append apply-frame-traps trace-traps) trap-context) + (slot-ref trap-context 'handler-return-value)))) + +(define (exit-frame-handler key cont retval) + (if (trap-here? cont) + (let ((trap-context (make + #:type #:return + #:continuation cont + #:return-value retval))) + (trc 'exit-frame-handler retval (tc:depth trap-context)) + (if (memq 'tweaking guile-trap-features) + (slot-set! trap-context 'handler-return-syms '(instead))) + (run-traps exit-frame-traps trap-context) + (slot-ref trap-context 'handler-return-value)))) + +(define-macro (trap-installer trap-list) + `(lambda (trap) + (set! ,trap-list (cons trap ,trap-list)) + (set-debug-and-trap-options))) + +(define install-enter-frame-trap (trap-installer enter-frame-traps)) +(define install-apply-frame-trap (trap-installer apply-frame-traps)) +(define install-exit-frame-trap (trap-installer exit-frame-traps)) +(define install-breakpoint-trap (trap-installer breakpoint-traps)) +(define install-trace-trap (trap-installer trace-traps)) + +(define-macro (trap-uninstaller trap-list) + `(lambda (trap) + (or (memq trap ,trap-list) + (error "Trap list does not include the specified trap")) + (set! ,trap-list (delq1! trap ,trap-list)) + (set-debug-and-trap-options))) + +(define uninstall-enter-frame-trap (trap-uninstaller enter-frame-traps)) +(define uninstall-apply-frame-trap (trap-uninstaller apply-frame-traps)) +(define uninstall-exit-frame-trap (trap-uninstaller exit-frame-traps)) +(define uninstall-breakpoint-trap (trap-uninstaller breakpoint-traps)) +(define uninstall-trace-trap (trap-uninstaller trace-traps)) + +(define trap-ordering (make-object-property)) +(define behaviour-ordering (make-object-property)) + +(define (run-traps traps trap-context) + (let ((behaviours (apply append + (map (lambda (trap) + (trap->behaviour trap trap-context)) + (sort traps + (lambda (t1 t2) + (< (or (trap-ordering t1) 0) + (or (trap-ordering t2) 0)))))))) + (for-each (lambda (proc) + (proc trap-context)) + (sort (delete-duplicates behaviours) + (lambda (b1 b2) + (< (or (behaviour-ordering b1) 0) + (or (behaviour-ordering b2) 0))))))) + +;;; {Pseudo-Traps for Non-Trap Events} + +;;; Once there is a body of code to do with responding to (debugging, +;;; tracing, etc.) traps, it makes sense to be able to leverage that +;;; same code for certain events that are trap-like, but not actually +;;; traps in the sense of the calls made by libguile's evaluator. + +;;; The main example of this is when an error is signalled. Guile +;;; doesn't yet have a 100% reliable way of hooking into errors, but +;;; in practice most errors go through a lazy-catch whose handler is +;;; lazy-handler-dispatch (defined in ice-9/boot-9.scm), which in turn +;;; calls default-lazy-handler. So we can present most errors as +;;; pseudo-traps by modifying default-lazy-handler. + +(define default-default-lazy-handler default-lazy-handler) + +(define (throw->trap-context key args . stack-args) + (let ((ctx (make + #:type #:error + #:continuation #f + #:return-value (cons key args)))) + (slot-set! ctx 'stack + (let ((caller-stack (and (= (length stack-args) 1) + (car stack-args)))) + (if (stack? caller-stack) + caller-stack + (apply make-stack #t stack-args)))) + ctx)) + +(define (on-lazy-handler-dispatch behaviour . ignored-keys) + (set! default-lazy-handler + (if behaviour + (lambda (key . args) + (or (memq key ignored-keys) + (behaviour (throw->trap-context key + args + lazy-handler-dispatch))) + (apply default-default-lazy-handler key args)) + default-default-lazy-handler))) + +;;; {Trap Classes} + +;;; Class: +;;; +;;; is the base class for traps. Any actual trap should be an +;;; instance of a class derived from , not of itself, +;;; because there is no base class method for the install-trap, +;;; trap-runnable? and uninstall-trap GFs. +(define-class () + ;; "number" slot: the number of this trap (assigned automatically). + (number) + ;; "installed" slot: whether this trap is installed. + (installed #:init-value #f) + ;; "condition" slot: if non-#f, this is a thunk which is called when + ;; the trap fires, to determine whether trap processing should + ;; proceed any further. + (condition #:init-value #f #:init-keyword #:condition) + ;; "skip-count" slot: a count of valid (after "condition" + ;; processing) firings of this trap to skip. + (skip-count #:init-value 0 #:init-keyword #:skip-count) + ;; "single-shot" slot: if non-#f, this trap is removed after it has + ;; successfully fired (after "condition" and "skip-count" + ;; processing) for the first time. + (single-shot #:init-value #f #:init-keyword #:single-shot) + ;; "behaviour" slot: procedure or list of procedures to call + ;; (passing the trap context as parameter) if we finally decide + ;; (after "condition" and "skip-count" processing) to run this + ;; trap's behaviour. + (behaviour #:init-value '() #:init-keyword #:behaviour) + ;; "repeat-identical-behaviour" slot: normally, if multiple + ;; objects are triggered by the same low level trap, and they + ;; request the same behaviour, it's only useful to do that behaviour + ;; once (per low level trap); so by default multiple requests for + ;; the same behaviour are coalesced. If this slot is non-#f, the + ;; contents of the "behaviour" slot are uniquified so that they + ;; avoid being coalesced in this way. + (repeat-identical-behaviour #:init-value #f + #:init-keyword #:repeat-identical-behaviour) + ;; "observer" slot: this is a procedure that is called with one + ;; EVENT argument when the trap status changes in certain + ;; interesting ways, currently the following. (1) When the trap is + ;; uninstalled because of the target becoming inaccessible; EVENT in + ;; this case is 'target-gone. + (observer #:init-value #f #:init-keyword #:observer)) + +(define last-assigned-trap-number 0) +(define all-traps (make-weak-value-hash-table 7)) + +(define-method (initialize (trap ) initargs) + (next-method) + ;; Assign a trap number, and store in the hash of all traps. + (set! last-assigned-trap-number (+ last-assigned-trap-number 1)) + (slot-set! trap 'number last-assigned-trap-number) + (hash-set! all-traps last-assigned-trap-number trap) + ;; Listify the behaviour slot, if not a list already. + (let ((behaviour (slot-ref trap 'behaviour))) + (if (procedure? behaviour) + (slot-set! trap 'behaviour (list behaviour))))) + +(define-generic install-trap) ; provided mostly by subclasses +(define-generic uninstall-trap) ; provided mostly by subclasses +(define-generic trap->behaviour) ; provided by +(define-generic trap-runnable?) ; provided by subclasses + +(define-method (install-trap (trap )) + (if (slot-ref trap 'installed) + (error "Trap is already installed")) + (slot-set! trap 'installed #t)) + +(define-method (uninstall-trap (trap )) + (or (slot-ref trap 'installed) + (error "Trap is not installed")) + (slot-set! trap 'installed #f)) + +;;; uniquify-behaviour +;;; +;;; Uniquify BEHAVIOUR by wrapping it in a new lambda. +(define (uniquify-behaviour behaviour) + (lambda (trap-context) + (behaviour trap-context))) + +;;; trap->behaviour +;;; +;;; If TRAP is runnable, given TRAP-CONTEXT, return a list of +;;; behaviour procs to call with TRAP-CONTEXT as a parameter. +;;; Otherwise return the empty list. +(define-method (trap->behaviour (trap ) (trap-context )) + (if (and + ;; Check that the trap is runnable. Runnability is implemented + ;; by the subclass and allows us to check, for example, that + ;; the procedure being applied in an apply-frame trap matches + ;; this trap's procedure. + (trap-runnable? trap trap-context) + ;; Check the additional condition, if specified. + (let ((condition (slot-ref trap 'condition))) + (or (not condition) + ((condition)))) + ;; Check for a skip count. + (let ((skip-count (slot-ref trap 'skip-count))) + (if (zero? skip-count) + #t + (begin + (slot-set! trap 'skip-count (- skip-count 1)) + #f)))) + ;; All checks passed, so we will return the contents of this + ;; trap's behaviour slot. + (begin + ;; First, though, remove this trap if its single-shot slot + ;; indicates that it should fire only once. + (if (slot-ref trap 'single-shot) + (uninstall-trap trap)) + ;; Add this trap object to the context's list of traps which + ;; fired here. + (slot-set! trap-context 'fired-traps + (cons trap (tc:fired-traps trap-context))) + ;; Return trap behaviour, uniquified if necessary. + (if (slot-ref trap 'repeat-identical-behaviour) + (map uniquify-behaviour (slot-ref trap 'behaviour)) + (slot-ref trap 'behaviour))) + '())) + +;;; Class: +;;; +;;; An installed instance of triggers on invocation +;;; of a specific procedure. +(define-class () + ;; "procedure" slot: the procedure to trap on. This is implemented + ;; virtually, using the following weak vector slot, so as to avoid + ;; this trap preventing the GC of the target procedure. + (procedure #:init-keyword #:procedure + #:allocation #:virtual + #:slot-ref + (lambda (trap) + (vector-ref (slot-ref trap 'procedure-wv) 0)) + #:slot-set! + (lambda (trap proc) + (if (slot-bound? trap 'procedure-wv) + (vector-set! (slot-ref trap 'procedure-wv) 0 proc) + (slot-set! trap 'procedure-wv (weak-vector proc))))) + (procedure-wv)) + +;; Customization of the initialize method: set up to handle what +;; should happen when the procedure is GC'd. +(define-method (initialize (trap ) initargs) + (next-method) + (let* ((proc (slot-ref trap 'procedure)) + (existing-traps (volatile-target-traps proc))) + ;; If this is the target's first trap, give the target procedure + ;; to the volatile-target-guardian, so we can find out if it + ;; becomes inaccessible. + (or existing-traps (volatile-target-guardian proc)) + ;; Add this trap to the target procedure's list of traps. + (set! (volatile-target-traps proc) + (cons trap (or existing-traps '()))))) + +(define procedure-trace-count (make-object-property)) + +(define-method (install-trap (trap )) + (next-method) + (let* ((proc (slot-ref trap 'procedure)) + (trace-count (or (procedure-trace-count proc) 0))) + (set-procedure-property! proc 'trace #t) + (set! (procedure-trace-count proc) (+ trace-count 1))) + (install-trace-trap trap)) + +(define-method (uninstall-trap (trap )) + (next-method) + (let* ((proc (slot-ref trap 'procedure)) + (trace-count (or (procedure-trace-count proc) 0))) + (if (= trace-count 1) + (set-procedure-property! proc 'trace #f)) + (set! (procedure-trace-count proc) (- trace-count 1))) + (uninstall-trace-trap trap)) + +(define-method (trap-runnable? (trap ) + (trap-context )) + (eq? (slot-ref trap 'procedure) + (frame-procedure (tc:frame trap-context)))) + +;;; Class: +;;; +;;; An installed instance of triggers on stack frame exit +;;; past a specified stack depth. +(define-class () + ;; "depth" slot: the reference depth for the trap. + (depth #:init-keyword #:depth)) + +(define-method (install-trap (trap )) + (next-method) + (install-exit-frame-trap trap)) + +(define-method (uninstall-trap (trap )) + (next-method) + (uninstall-exit-frame-trap trap)) + +(define-method (trap-runnable? (trap ) + (trap-context )) + (<= (tc:exit-depth trap-context) + (slot-ref trap 'depth))) + +;;; Class: +;;; +;;; An installed instance of triggers on any frame entry. +(define-class ()) + +(define-method (install-trap (trap )) + (next-method) + (install-enter-frame-trap trap)) + +(define-method (uninstall-trap (trap )) + (next-method) + (uninstall-enter-frame-trap trap)) + +(define-method (trap-runnable? (trap ) + (trap-context )) + #t) + +;;; Class: +;;; +;;; An installed instance of triggers on any procedure +;;; application. +(define-class ()) + +(define-method (install-trap (trap )) + (next-method) + (install-apply-frame-trap trap)) + +(define-method (uninstall-trap (trap )) + (next-method) + (uninstall-apply-frame-trap trap)) + +(define-method (trap-runnable? (trap ) + (trap-context )) + #t) + +;;; Class: +;;; +;;; An installed instance of triggers on the next frame +;;; entry, exit or application, optionally with source location inside +;;; a specified file. +(define-class () + ;; "file-name" slot: if non-#f, indicates that this trap should + ;; trigger only for steps in source code from the specified file. + (file-name #:init-value #f #:init-keyword #:file-name) + ;; "exit-depth" slot: when non-#f, indicates that the next step may + ;; be a frame exit past this depth; otherwise, indicates that the + ;; next step must be an application or a frame entry. + (exit-depth #:init-value #f #:init-keyword #:exit-depth)) + +(define-method (initialize (trap ) initargs) + (next-method) + (slot-set! trap 'depth (slot-ref trap 'exit-depth))) + +(define-method (install-trap (trap )) + (next-method) + (install-enter-frame-trap trap) + (install-apply-frame-trap trap)) + +(define-method (uninstall-trap (trap )) + (next-method) + (uninstall-enter-frame-trap trap) + (uninstall-apply-frame-trap trap)) + +(define-method (trap-runnable? (trap ) + (trap-context )) + (if (eq? (tc:type trap-context) #:return) + ;; We're in the context of an exit-frame trap. Trap should only + ;; be run if exit-depth is set and this exit-frame has returned + ;; past the set depth. + (and (slot-ref trap 'exit-depth) + (next-method) + ;; OK to run the trap here, but we should first reset the + ;; exit-depth slot to indicate that the step after this one + ;; must be an application or frame entry. + (begin + (slot-set! trap 'exit-depth #f) + #t)) + ;; We're in the context of an application or frame entry trap. + ;; Check whether trap is limited to a specified file. + (let ((file-name (slot-ref trap 'file-name))) + (and (or (not file-name) + (equal? (frame-file-name (tc:frame trap-context)) file-name)) + ;; Trap should run here, but we should also set exit-depth to + ;; the current stack length, so that - if we don't stop at any + ;; other steps first - the next step shows the return value of + ;; the current application or evaluation. + (begin + (slot-set! trap 'exit-depth (tc:depth trap-context)) + (slot-set! trap 'depth (tc:depth trap-context)) + #t))))) + +(define (frame->source-position frame) + (let ((source (if (frame-procedure? frame) + (or (frame-source frame) + (let ((proc (frame-procedure frame))) + (and proc + (procedure? proc) + (procedure-source proc)))) + (frame-source frame)))) + (and source + (string? (source-property source 'filename)) + (list (source-property source 'filename) + (source-property source 'line) + (source-property source 'column))))) + +(define (frame-file-name frame) + (cond ((frame->source-position frame) => car) + (else #f))) + +;;; Class: +;;; +;;; An installed instance of triggers upon evaluation of +;;; a specified source expression. +(define-class () + ;; "expression" slot: the expression to trap on. This is + ;; implemented virtually, using the following weak vector slot, so + ;; as to avoid this trap preventing the GC of the target source + ;; code. + (expression #:init-keyword #:expression + #:allocation #:virtual + #:slot-ref + (lambda (trap) + (vector-ref (slot-ref trap 'expression-wv) 0)) + #:slot-set! + (lambda (trap expr) + (if (slot-bound? trap 'expression-wv) + (vector-set! (slot-ref trap 'expression-wv) 0 expr) + (slot-set! trap 'expression-wv (weak-vector expr))))) + (expression-wv) + ;; source property slots - for internal use only + (filename) + (line) + (column)) + +;; Customization of the initialize method: get and save the +;; expression's source properties, or signal an error if it doesn't +;; have the necessary properties. +(define-method (initialize (trap ) initargs) + (next-method) + (let* ((expr (slot-ref trap 'expression)) + (filename (source-property expr 'filename)) + (line (source-property expr 'line)) + (column (source-property expr 'column)) + (existing-traps (volatile-target-traps expr))) + (or (and filename line column) + (error "Specified source does not have the necessary properties" + filename line column)) + (slot-set! trap 'filename filename) + (slot-set! trap 'line line) + (slot-set! trap 'column column) + ;; If this is the target's first trap, give the target expression + ;; to the volatile-target-guardian, so we can find out if it + ;; becomes inaccessible. + (or existing-traps (volatile-target-guardian expr)) + ;; Add this trap to the target expression's list of traps. + (set! (volatile-target-traps expr) + (cons trap (or existing-traps '()))))) + +;; Just in case more than one trap is installed on the same source +;; expression ... so that we can still get the setting and resetting +;; of the 'breakpoint source property correct. +(define source-breakpoint-count (make-object-property)) + +(define-method (install-trap (trap )) + (next-method) + (let* ((expr (slot-ref trap 'expression)) + (breakpoint-count (or (source-breakpoint-count expr) 0))) + (set-source-property! expr 'breakpoint #t) + (set! (source-breakpoint-count expr) (+ breakpoint-count 1))) + (install-breakpoint-trap trap)) + +(define-method (uninstall-trap (trap )) + (next-method) + (let* ((expr (slot-ref trap 'expression)) + (breakpoint-count (or (source-breakpoint-count expr) 0))) + (if (= breakpoint-count 1) + (set-source-property! expr 'breakpoint #f)) + (set! (source-breakpoint-count expr) (- breakpoint-count 1))) + (uninstall-breakpoint-trap trap)) + +(define-method (trap-runnable? (trap ) + (trap-context )) + (or (eq? (slot-ref trap 'expression) + (tc:expression trap-context)) + (let ((trap-location (frame->source-position (tc:frame trap-context)))) + (and trap-location + (string=? (car trap-location) (slot-ref trap 'filename)) + (= (cadr trap-location) (slot-ref trap 'line)) + (= (caddr trap-location) (slot-ref trap 'column)))))) + +;; (trap-here EXPRESSION . OPTIONS) +(define trap-here + (procedure->memoizing-macro + (lambda (expr env) + (let ((trap (apply make + + #:expression expr + (local-eval `(list ,@(cddr expr)) + env)))) + (install-trap trap) + (set-car! expr 'begin) + (set-cdr! (cdr expr) '()) + expr)))) + +;;; Class: +;;; +;;; An installed instance of triggers on entry to a +;;; frame with a more-or-less precisely specified source location. +(define-class () + ;; "file-regexp" slot: regexp matching the name(s) of the file(s) to + ;; trap in. + (file-regexp #:init-keyword #:file-regexp) + ;; "line" and "column" slots: position to trap at (0-based). + (line #:init-value #f #:init-keyword #:line) + (column #:init-value #f #:init-keyword #:column) + ;; "compiled-regexp" slot - self explanatory, internal use only + (compiled-regexp)) + +(define-method (initialize (trap ) initargs) + (next-method) + (slot-set! trap 'compiled-regexp + (make-regexp (slot-ref trap 'file-regexp)))) + +(define-method (install-trap (trap )) + (next-method) + (install-enter-frame-trap trap)) + +(define-method (uninstall-trap (trap )) + (next-method) + (uninstall-enter-frame-trap trap)) + +(define-method (trap-runnable? (trap ) + (trap-context )) + (and-let* ((trap-location (frame->source-position (tc:frame trap-context))) + (tcline (cadr trap-location)) + (tccolumn (caddr trap-location))) + (and (= tcline (slot-ref trap 'line)) + (= tccolumn (slot-ref trap 'column)) + (regexp-exec (slot-ref trap 'compiled-regexp) + (car trap-location) 0)))) + +;;; {Misc Trap Utilities} + +(define (get-trap number) + (hash-ref all-traps number)) + +(define (list-traps) + (for-each describe + (map cdr (sort (hash-fold acons '() all-traps) + (lambda (x y) (< (car x) (car y))))))) + +;;; {Volatile Traps} +;;; +;;; Some traps are associated with Scheme objects that are likely to +;;; be GC'd, such as procedures and read expressions. When those +;;; objects are GC'd, we want to allow their traps to evaporate as +;;; well, or at least not to prevent them from doing so because they +;;; are (now pointlessly) included on the various installed trap +;;; lists. + +;; An object property that maps each volatile target to the list of +;; traps that are installed on it. +(define volatile-target-traps (make-object-property)) + +;; A guardian that tells us when a volatile target is no longer +;; accessible. +(define volatile-target-guardian (make-guardian)) + +;; An after GC hook that checks for newly inaccessible targets. +(add-hook! after-gc-hook + (lambda () + (trc 'after-gc-hook) + (let loop ((target (volatile-target-guardian))) + (if target + ;; We have a target which is now inaccessible. Get + ;; the list of traps installed on it. + (begin + (trc 'after-gc-hook "got target") + ;; Uninstall all the traps that are installed on + ;; this target. + (for-each (lambda (trap) + (trc 'after-gc-hook "got trap") + ;; If the trap is still installed, + ;; uninstall it. + (if (slot-ref trap 'installed) + (uninstall-trap trap)) + ;; If the trap has an observer, tell + ;; it that the target has gone. + (cond ((slot-ref trap 'observer) + => + (lambda (proc) + (trc 'after-gc-hook "call obs") + (proc 'target-gone))))) + (or (volatile-target-traps target) '())) + ;; Check for any more inaccessible targets. + (loop (volatile-target-guardian))))))) + +(define (without-traps thunk) + (with-traps (lambda () + (trap-disable 'traps) + (thunk)))) + +(define guile-trap-features + ;; Helper procedure, to test whether a specific possible Guile + ;; feature is supported. + (let ((supported? + (lambda (test-feature) + (case test-feature + ((tweaking) + ;; Tweaking is supported if the description of the cheap + ;; traps option includes the word "obsolete", or if the + ;; option isn't there any more. + (and (string>=? (version) "1.7") + (let ((cheap-opt-desc + (assq 'cheap (debug-options-interface 'help)))) + (or (not cheap-opt-desc) + (string-match "obsolete" (caddr cheap-opt-desc)))))) + (else + (error "Unexpected feature name:" test-feature)))))) + ;; Compile the list of actually supported features from all + ;; possible features. + (let loop ((possible-features '(tweaking)) + (actual-features '())) + (if (null? possible-features) + (reverse! actual-features) + (let ((test-feature (car possible-features))) + (loop (cdr possible-features) + (if (supported? test-feature) + (cons test-feature actual-features) + actual-features))))))) + +;; Make sure that traps are enabled. +(trap-enable 'traps) + +;;; (ice-9 debugging traps) ends here. diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/trc.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/trc.scm new file mode 100755 index 0000000000000000000000000000000000000000..9e95d7e5c39117ae68cb20a0a7e506f2c34c087a --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/trc.scm @@ -0,0 +1,63 @@ +;;;; (ice-9 debugging trc) -- tracing for Guile debugger code + +;;; Copyright (C) 2002, 2004 Free Software Foundation, Inc. +;;; +;; This library is free software; you can redistribute it and/or +;; modify it under the terms of the GNU Lesser General Public +;; License as published by the Free Software Foundation; either +;; version 2.1 of the License, or (at your option) any later version. +;; +;; This library is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; Lesser General Public License for more details. +;; +;; You should have received a copy of the GNU Lesser General Public +;; License along with this library; if not, write to the Free Software +;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +(define-module (ice-9 debugging trc) + #:export (trc trc-syms trc-all trc-none trc-add trc-remove trc-port)) + +(define *syms* #f) + +(define (trc-set! syms) + (set! *syms* syms)) + +(define (trc-syms . syms) + (trc-set! syms)) + +(define (trc-all) + (trc-set! #f)) + +(define (trc-none) + (trc-set! '())) + +(define (trc-add sym) + (trc-set! (cons sym *syms*))) + +(define (trc-remove sym) + (trc-set! (delq1! sym *syms*))) + +(define (trc sym . args) + (if (or (not *syms*) + (memq sym *syms*)) + (let ((port (trc-port))) + (write sym port) + (display ":" port) + (for-each (lambda (arg) + (display " " port) + (write arg port)) + args) + (newline port)))) + +(define trc-port + (let ((port (current-error-port))) + (make-procedure-with-setter + (lambda () port) + (lambda (p) (set! port p))))) + +;; Default to no tracing. +(trc-none) + +;;; (ice-9 debugging trc) ends here. diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/deprecated.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/deprecated.scm new file mode 100755 index 0000000000000000000000000000000000000000..27332ba79c8a6abc863a817887b3b197bbd11c86 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/deprecated.scm @@ -0,0 +1,180 @@ +;;;; Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; + +;;;; Deprecated definitions. + +(define substring-move-left! substring-move!) +(define substring-move-right! substring-move!) + +;; This method of dynamically linking Guile Extensions is deprecated. +;; Use `load-extension' explicitly from Scheme code instead. + +(define (split-c-module-name str) + (let loop ((rev '()) + (start 0) + (pos 0) + (end (string-length str))) + (cond + ((= pos end) + (reverse (cons (string->symbol (substring str start pos)) rev))) + ((eq? (string-ref str pos) #\space) + (loop (cons (string->symbol (substring str start pos)) rev) + (+ pos 1) + (+ pos 1) + end)) + (else + (loop rev start (+ pos 1) end))))) + +(define (convert-c-registered-modules dynobj) + (let ((res (map (lambda (c) + (list (split-c-module-name (car c)) (cdr c) dynobj)) + (c-registered-modules)))) + (c-clear-registered-modules) + res)) + +(define registered-modules '()) + +(define (register-modules dynobj) + (set! registered-modules + (append! (convert-c-registered-modules dynobj) + registered-modules))) + +(define (warn-autoload-deprecation modname) + (issue-deprecation-warning + "Autoloading of compiled code modules is deprecated." + "Write a Scheme file instead that uses `load-extension'.") + (issue-deprecation-warning + (simple-format #f "(You just autoloaded module ~S.)" modname))) + +(define (init-dynamic-module modname) + ;; Register any linked modules which have been registered on the C level + (register-modules #f) + (or-map (lambda (modinfo) + (if (equal? (car modinfo) modname) + (begin + (warn-autoload-deprecation modname) + (set! registered-modules (delq! modinfo registered-modules)) + (let ((mod (resolve-module modname #f))) + (save-module-excursion + (lambda () + (set-current-module mod) + (set-module-public-interface! mod mod) + (dynamic-call (cadr modinfo) (caddr modinfo)) + )) + #t)) + #f)) + registered-modules)) + +(define (dynamic-maybe-call name dynobj) + (catch #t ; could use false-if-exception here + (lambda () + (dynamic-call name dynobj)) + (lambda args + #f))) + +(define (dynamic-maybe-link filename) + (catch #t ; could use false-if-exception here + (lambda () + (dynamic-link filename)) + (lambda args + #f))) + +(define (find-and-link-dynamic-module module-name) + (define (make-init-name mod-name) + (string-append "scm_init" + (list->string (map (lambda (c) + (if (or (char-alphabetic? c) + (char-numeric? c)) + c + #\_)) + (string->list mod-name))) + "_module")) + + ;; Put the subdirectory for this module in the car of SUBDIR-AND-LIBNAME, + ;; and the `libname' (the name of the module prepended by `lib') in the cdr + ;; field. For example, if MODULE-NAME is the list (inet tcp-ip udp), then + ;; SUBDIR-AND-LIBNAME will be the pair ("inet/tcp-ip" . "libudp"). + (let ((subdir-and-libname + (let loop ((dirs "") + (syms module-name)) + (if (null? (cdr syms)) + (cons dirs (string-append "lib" (symbol->string (car syms)))) + (loop (string-append dirs (symbol->string (car syms)) "/") + (cdr syms))))) + (init (make-init-name (apply string-append + (map (lambda (s) + (string-append "_" + (symbol->string s))) + module-name))))) + (let ((subdir (car subdir-and-libname)) + (libname (cdr subdir-and-libname))) + + ;; Now look in each dir in %LOAD-PATH for `subdir/libfoo.la'. If that + ;; file exists, fetch the dlname from that file and attempt to link + ;; against it. If `subdir/libfoo.la' does not exist, or does not seem + ;; to name any shared library, look for `subdir/libfoo.so' instead and + ;; link against that. + (let check-dirs ((dir-list %load-path)) + (if (null? dir-list) + #f + (let* ((dir (in-vicinity (car dir-list) subdir)) + (sharlib-full + (or (try-using-libtool-name dir libname) + (try-using-sharlib-name dir libname)))) + (if (and sharlib-full (file-exists? sharlib-full)) + (link-dynamic-module sharlib-full init) + (check-dirs (cdr dir-list))))))))) + +(define (try-using-libtool-name libdir libname) + (let ((libtool-filename (in-vicinity libdir + (string-append libname ".la")))) + (and (file-exists? libtool-filename) + libtool-filename))) + +(define (try-using-sharlib-name libdir libname) + (in-vicinity libdir (string-append libname ".so"))) + +(define (link-dynamic-module filename initname) + ;; Register any linked modules which have been registered on the C level + (register-modules #f) + (let ((dynobj (dynamic-link filename))) + (dynamic-call initname dynobj) + (register-modules dynobj))) + +(define (try-module-linked module-name) + (init-dynamic-module module-name)) + +(define (try-module-dynamic-link module-name) + (and (find-and-link-dynamic-module module-name) + (init-dynamic-module module-name))) + +(define (list* . args) + (issue-deprecation-warning "'list*' is deprecated. Use 'cons*' instead.") + (apply cons* args)) + +;; The strange prototype system for uniform arrays has been +;; deprecated. + +(define uniform-vector-fill! array-fill!) + +(define make-uniform-vector dimensions->uniform-array) + +(define (make-uniform-array prot . bounds) + (dimensions->uniform-array bounds prot)) + +(define (list->uniform-vector prot lst) + (list->uniform-array 1 prot lst)) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/documentation.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/documentation.scm new file mode 100755 index 0000000000000000000000000000000000000000..6e74799e6b624894268bbaaf347f4c79d3404e07 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/documentation.scm @@ -0,0 +1,213 @@ +;;;; Copyright (C) 2000,2001, 2002, 2003, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; + +;;; Commentary: + +;; * This module exports: +;; +;; file-commentary -- a procedure that returns a file's "commentary" +;; +;; documentation-files -- a search-list of files using the Guile +;; Documentation Format Version 2. +;; +;; search-documentation-files -- a procedure that takes NAME (a symbol) +;; and searches `documentation-files' for +;; associated documentation. optional +;; arg FILES is a list of filenames to use +;; instead of `documentation-files'. +;; +;; object-documentation -- a procedure that returns its arg's docstring +;; +;; * Guile Documentation Format +;; +;; Here is the complete and authoritative documentation for the Guile +;; Documentation Format Version 2: +;; +;; HEADER +;; ^LPROC1 +;; DOCUMENTATION1 +;; +;; ^LPROC2 +;; DOCUMENTATION2 +;; +;; ^L... +;; +;; The HEADER is completely ignored. The "^L" are formfeeds. PROC1, PROC2 +;; and so on are symbols that name the element documented. DOCUMENTATION1, +;; DOCUMENTATION2 and so on are the related documentation, w/o any further +;; formatting. Note that there are two newlines before the next formfeed; +;; these are discarded when the documentation is read in. +;; +;; (Version 1, corresponding to guile-1.4 and prior, is documented as being +;; not documented anywhere except by this embarrassingly circular comment.) +;; +;; * File Commentary +;; +;; A file's commentary is the body of text found between comments +;; ;;; Commentary: +;; and +;; ;;; Code: +;; both of which must be at the beginning of the line. In the result string, +;; semicolons at the beginning of each line are discarded. +;; +;; You can specify to `file-commentary' alternate begin and end strings, and +;; scrub procedure. Use #t to get default values. For example: +;; +;; (file-commentary "documentation.scm") +;; You should see this text! +;; +;; (file-commentary "documentation.scm" "^;;; Code:" "ends here$") +;; You should see the rest of this file. +;; +;; (file-commentary "documentation.scm" #t #t string-upcase) +;; You should see this text very loudly (note semicolons untouched). + +;;; Code: + +(define-module (ice-9 documentation) + :use-module (ice-9 rdelim) + :export (file-commentary + documentation-files search-documentation-files + object-documentation) + :autoload (ice-9 regex) (match:suffix) + :no-backtrace) + + +;; +;; commentary extraction +;; + +(define (file-commentary filename . cust) ; (IN-LINE-RE AFTER-LINE-RE SCRUB) + + ;; These are constants but are not at the top level because the repl in + ;; boot-9.scm loads session.scm which in turn loads this file, and we want + ;; that to work even even when regexps are not available (ie. make-regexp + ;; doesn't exist), as for instance is the case on mingw. + ;; + (define default-in-line-re (make-regexp "^;;; Commentary:")) + (define default-after-line-re (make-regexp "^;;; Code:")) + (define default-scrub (let ((dirt (make-regexp "^;+"))) + (lambda (line) + (let ((m (regexp-exec dirt line))) + (if m (match:suffix m) line))))) + + ;; fixme: might be cleaner to use optargs here... + (let ((in-line-re (if (> 1 (length cust)) + default-in-line-re + (let ((v (car cust))) + (cond ((regexp? v) v) + ((string? v) (make-regexp v)) + (else default-in-line-re))))) + (after-line-re (if (> 2 (length cust)) + default-after-line-re + (let ((v (cadr cust))) + (cond ((regexp? v) v) + ((string? v) (make-regexp v)) + (else default-after-line-re))))) + (scrub (if (> 3 (length cust)) + default-scrub + (let ((v (caddr cust))) + (cond ((procedure? v) v) + (else default-scrub)))))) + (call-with-input-file filename + (lambda (port) + (let loop ((line (read-delimited "\n" port)) + (doc "") + (parse-state 'before)) + (if (or (eof-object? line) (eq? 'after parse-state)) + doc + (let ((new-state + (cond ((regexp-exec in-line-re line) 'in) + ((regexp-exec after-line-re line) 'after) + (else parse-state)))) + (if (eq? 'after new-state) + doc + (loop (read-delimited "\n" port) + (if (and (eq? 'in new-state) (eq? 'in parse-state)) + (string-append doc (scrub line) "\n") + doc) + new-state))))))))) + + + +;; +;; documentation-files is the list of places to look for documentation +;; +(define documentation-files + (map (lambda (vicinity) + (in-vicinity (vicinity) "guile-procedures.txt")) + (list %library-dir + %package-data-dir + %site-dir + (lambda () ".")))) + +(define entry-delimiter "\f") + +(define (find-documentation-in-file name file) + (and (file-exists? file) + (call-with-input-file file + (lambda (port) + (let ((name (symbol->string name))) + (let ((len (string-length name))) + (read-delimited entry-delimiter port) ;skip to first entry + (let loop ((entry (read-delimited entry-delimiter port))) + (cond ((eof-object? entry) #f) + ;; match? + ((and ;; large enough? + (>= (string-length entry) len) + ;; matching name? + (string=? (substring entry 0 len) name) + ;; terminated? + (memq (string-ref entry len) '(#\newline))) + ;; cut away name tag and extra surrounding newlines + (substring entry (+ len 2) (- (string-length entry) 2))) + (else (loop (read-delimited entry-delimiter port))))))))))) + +(define (search-documentation-files name . files) + (or-map (lambda (file) + (find-documentation-in-file name file)) + (cond ((null? files) documentation-files) + (else files)))) + +;; helper until the procedure documentation property is cleaned up +(define (proc-doc proc) + (or (procedure-documentation proc) + (procedure-property proc 'documentation))) + +(define (object-documentation object) + "Return the docstring for OBJECT. +OBJECT can be a procedure, macro or any object that has its +`documentation' property set." + (or (and (procedure? object) + (proc-doc object)) + (and (defmacro? object) + (proc-doc (defmacro-transformer object))) + (and (macro? object) + (let ((transformer (macro-transformer object))) + (and transformer + (proc-doc transformer)))) + (object-property object 'documentation) + (and (procedure? object) + (not (closure? object)) + (procedure-name object) + (let ((docstring (search-documentation-files + (procedure-name object)))) + (if docstring + (set-procedure-property! object 'documentation docstring)) + docstring)))) + +;;; documentation.scm ends here diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/emacs.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/emacs.scm new file mode 100755 index 0000000000000000000000000000000000000000..12d8228ee388ef368ed50d03a0c0177554256367 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/emacs.scm @@ -0,0 +1,276 @@ +;;;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; +;;;; The author can be reached at djurfeldt@nada.kth.se +;;;; Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN +;;;; (I didn't write this!) +;;;; + + +;;; ********************************************************************* +;;; * This is the Guile side of the Emacs interface * +;;; * Experimental hACK---the real version will be coming soon (almost) * +;;; ********************************************************************* + +;;; {Session support for Emacs} +;;; + +(define-module (ice-9 emacs) + :use-module (ice-9 debug) + :use-module (ice-9 threads) + :use-module (ice-9 session) + :no-backtrace) + +(define emacs-escape-character #\sub) + +(define emacs-output-port (current-output-port)) + +(define (make-emacs-command char) + (let ((cmd (list->string (list emacs-escape-character char)))) + (lambda () + (display cmd emacs-output-port)))) + +(define enter-input-wait (make-emacs-command #\s)) +(define exit-input-wait (make-emacs-command #\f)) +(define enter-read-character #\r) +(define sending-error (make-emacs-command #\F)) +(define sending-backtrace (make-emacs-command #\B)) +(define sending-result (make-emacs-command #\x)) +(define end-of-text (make-emacs-command #\.)) +(define no-stack (make-emacs-command #\S)) +(define no-source (make-emacs-command #\R)) + +;; {Error handling} +;; + +(add-hook! before-backtrace-hook sending-backtrace) +(add-hook! after-backtrace-hook end-of-text) +(add-hook! before-error-hook sending-error) +(add-hook! after-error-hook end-of-text) + +;; {Repl} +;; + +(set-current-error-port emacs-output-port) + +(add-hook! before-read-hook + (lambda () + (enter-input-wait) + (force-output emacs-output-port))) + +(add-hook! after-read-hook + (lambda () + (exit-input-wait) + (force-output emacs-output-port))) + +;;; {Misc.} + +(define (make-emacs-load-port orig-port) + (letrec ((read-char-fn (lambda args + (let ((c (read-char orig-port))) + (if (eq? c #\soh) + (throw 'end-of-chunk) + c))))) + + (make-soft-port + (vector #f #f #f + read-char-fn + (lambda () (close-port orig-port))) + "r"))) + +(set-current-input-port (make-emacs-load-port (current-input-port))) + +(define (result-to-emacs exp) + (sending-result) + (write exp emacs-output-port) + (end-of-text) + (force-output emacs-output-port)) + +(define load-acknowledge (make-emacs-command #\l)) + +(define load-port (current-input-port)) + +(define (flush-line port) + (let loop ((c (read-char port))) + (if (not (eq? c #\nl)) + (loop (read-char port))))) + +(define whitespace-chars (list #\space #\tab #\nl #\np)) + +(define (flush-whitespace port) + (catch 'end-of-chunk + (lambda () + (let loop ((c (read-char port))) + (cond ((eq? c the-eof-object) + (error "End of file while receiving Emacs data")) + ((memq c whitespace-chars) (loop (read-char port))) + ((eq? c #\;) (flush-line port) (loop (read-char port))) + (else (unread-char c port)))) + #f) + (lambda args + (read-char port) ; Read final newline + #t))) + +(define (emacs-load filename linum colnum module interactivep) + (define (read-and-eval! port) + (let ((x (read port))) + (if (eof-object? x) + (throw 'end-of-file) + (primitive-eval x)))) + (set-port-filename! %%load-port filename) + (set-port-line! %%load-port linum) + (set-port-column! %%load-port colnum) + (lazy-catch #t + (lambda () + (let loop ((endp (flush-whitespace %%load-port))) + (if (not endp) + (begin + (save-module-excursion + (lambda () + (if module + (set-current-module (resolve-module module #f))) + (let ((result + (start-stack read-and-eval! + (read-and-eval! %%load-port)))) + (if interactivep + (result-to-emacs result))))) + (loop (flush-whitespace %%load-port))) + (begin + (load-acknowledge))) + (set-port-filename! %%load-port #f))) ;reset port filename + (lambda (key . args) + (set-port-filename! %%load-port #f) + (cond ((eq? key 'end-of-chunk) + (fluid-set! the-last-stack #f) + (set! stack-saved? #t) + (scm-error 'misc-error + #f + "Incomplete expression" + '() + '())) + ((eq? key 'exit)) + (else + (save-stack 2) + (catch 'end-of-chunk + (lambda () + (let loop () + (read-char %%load-port) + (loop))) + (lambda args + #f)) + (apply throw key args)))))) + +(define (emacs-eval-request form) + (result-to-emacs (eval form (interaction-environment)))) + +;;*fixme* Not necessary to use flags no-stack and no-source +(define (get-frame-source frame) + (if (or (not (fluid-ref the-last-stack)) + (>= frame (stack-length (fluid-ref the-last-stack)))) + (begin + (no-stack) + #f) + (let* ((frame (stack-ref (fluid-ref the-last-stack) + (frame-number->index frame))) + (source (frame-source frame))) + (or source + (begin (no-source) + #f))))) + +(define (emacs-select-frame frame) + (let ((source (get-frame-source frame))) + (if source + (let ((fname (source-property source 'filename)) + (line (source-property source 'line)) + (column (source-property source 'column))) + (if (and fname line column) + (list fname line column) + (begin (no-source) + '()))) + '()))) + +(define (object->string x . method) + (with-output-to-string + (lambda () + ((if (null? method) + write + (car method)) + x)))) + +(define (format template . rest) + (let loop ((chars (string->list template)) + (result '()) + (rest rest)) + (cond ((null? chars) (list->string (reverse result))) + ((char=? (car chars) #\%) + (loop (cddr chars) + (append (reverse + (string->list + (case (cadr chars) + ((#\S) (object->string (car rest))) + ((#\s) (object->string (car rest) display))))) + result) + (cdr rest))) + (else (loop (cdr chars) (cons (car chars) result) rest))))) + +(define (error-args->string args) + (let ((msg (apply format (caddr args) (cadddr args)))) + (if (symbol? (cadr args)) + (string-append (symbol->string (cadr args)) + ": " + msg) + msg))) + +(define (emacs-frame-eval frame form) + (let ((source (get-frame-source frame))) + (if source + (catch #t + (lambda () + (list 'result + (object->string + (local-eval (with-input-from-string form read) + (memoized-environment source))))) + (lambda args + (list (car args) + (error-args->string args)))) + (begin + (no-source) + '())))) + +(define (emacs-symdoc symbol) + (if (or (not (module-bound? (current-module) symbol)) + (not (procedure? (eval symbol (interaction-environment))))) + 'nil + (procedure-documentation (eval symbol (interaction-environment))))) + +;;; A fix to get the emacs interface to work together with the module system. +;;; +(for-each (lambda (name value) + (module-define! the-root-module name value)) + '(%%load-port + %%emacs-load + %%emacs-eval-request + %%emacs-select-frame + %%emacs-frame-eval + %%emacs-symdoc + %%apropos-internal) + (list load-port + emacs-load + emacs-eval-request + emacs-select-frame + emacs-frame-eval + emacs-symdoc + apropos-internal)) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/expect.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/expect.scm new file mode 100755 index 0000000000000000000000000000000000000000..a024e91e87cd14aca861dfe38b1141da30793d7d --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/expect.scm @@ -0,0 +1,171 @@ +;;;; Copyright (C) 1996, 1998, 1999, 2001, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; + +;;; Commentary: + +;; This module is documented in the Guile Reference Manual. +;; Briefly, these are exported: +;; procedures: expect-select, expect-regexec +;; variables: expect-port, expect-timeout, expect-timeout-proc, +;; expect-eof-proc, expect-char-proc, +;; expect-strings-compile-flags, expect-strings-exec-flags, +;; macros: expect, expect-strings + +;;; Code: + +(define-module (ice-9 expect) + :use-module (ice-9 regex) + :export-syntax (expect expect-strings) + :export (expect-port expect-timeout expect-timeout-proc + expect-eof-proc expect-char-proc expect-strings-compile-flags + expect-strings-exec-flags expect-select expect-regexec)) + +;;; Expect: a macro for selecting actions based on what it reads from a port. +;;; The idea is from Don Libes' expect based on Tcl. +;;; This version by Gary Houston incorporating ideas from Aubrey Jaffer. + + +(define expect-port #f) +(define expect-timeout #f) +(define expect-timeout-proc #f) +(define expect-eof-proc #f) +(define expect-char-proc #f) + +;;; expect: each test is a procedure which is applied to the accumulating +;;; string. +(defmacro expect clauses + (let ((s (gensym)) + (c (gensym)) + (port (gensym)) + (timeout (gensym))) + `(let ((,s "") + (,port (or expect-port (current-input-port))) + ;; when timeout occurs, in floating point seconds. + (,timeout (if expect-timeout + (let* ((secs-usecs (gettimeofday))) + (+ (car secs-usecs) + expect-timeout + (/ (cdr secs-usecs) + 1000000))) ; one million. + #f))) + (let next-char () + (if (and expect-timeout + (not (expect-select ,port ,timeout))) + (if expect-timeout-proc + (expect-timeout-proc ,s) + #f) + (let ((,c (read-char ,port))) + (if expect-char-proc + (expect-char-proc ,c)) + (if (not (eof-object? ,c)) + (set! ,s (string-append ,s (string ,c)))) + (cond + ;; this expands to clauses where the car invokes the + ;; match proc and the cdr is the return value from expect + ;; if the proc matched. + ,@(let next-expr ((tests (map car clauses)) + (exprs (map cdr clauses)) + (body '())) + (cond + ((null? tests) + (reverse body)) + (else + (next-expr + (cdr tests) + (cdr exprs) + (cons + `((,(car tests) ,s (eof-object? ,c)) + ,@(cond ((null? (car exprs)) + '()) + ((eq? (caar exprs) '=>) + (if (not (= (length (car exprs)) + 2)) + (scm-error 'misc-error + "expect" + "bad recipient: ~S" + (list (car exprs)) + #f) + `((apply ,(cadar exprs) + (,(car tests) ,s ,port))))) + (else + (car exprs)))) + body))))) + ;; if none of the clauses matched the current string. + (else (cond ((eof-object? ,c) + (if expect-eof-proc + (expect-eof-proc ,s) + #f)) + (else + (next-char))))))))))) + + +(define expect-strings-compile-flags regexp/newline) +(define expect-strings-exec-flags regexp/noteol) + +;;; the regexec front-end to expect: +;;; each test must evaluate to a regular expression. +(defmacro expect-strings clauses + `(let ,@(let next-test ((tests (map car clauses)) + (exprs (map cdr clauses)) + (defs '()) + (body '())) + (cond ((null? tests) + (list (reverse defs) `(expect ,@(reverse body)))) + (else + (let ((rxname (gensym))) + (next-test (cdr tests) + (cdr exprs) + (cons `(,rxname (make-regexp + ,(car tests) + expect-strings-compile-flags)) + defs) + (cons `((lambda (s eof?) + (expect-regexec ,rxname s eof?)) + ,@(car exprs)) + body)))))))) + +;;; simplified select: returns #t if input is waiting or #f if timed out or +;;; select was interrupted by a signal. +;;; timeout is an absolute time in floating point seconds. +(define (expect-select port timeout) + (let* ((secs-usecs (gettimeofday)) + (relative (- timeout + (car secs-usecs) + (/ (cdr secs-usecs) + 1000000)))) ; one million. + (and (> relative 0) + (pair? (car (select (list port) '() '() + relative)))))) + +;;; match a string against a regexp, returning a list of strings (required +;;; by the => syntax) or #f. called once each time a character is added +;;; to s (eof? will be #f), and once when eof is reached (with eof? #t). +(define (expect-regexec rx s eof?) + ;; if expect-strings-exec-flags contains regexp/noteol, + ;; remove it for the eof test. + (let* ((flags (if (and eof? + (logand expect-strings-exec-flags regexp/noteol)) + (logxor expect-strings-exec-flags regexp/noteol) + expect-strings-exec-flags)) + (match (regexp-exec rx s 0 flags))) + (if match + (do ((i (- (match:count match) 1) (- i 1)) + (result '() (cons (match:substring match i) result))) + ((< i 0) result)) + #f))) + +;;; expect.scm ends here diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/format.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/format.scm new file mode 100755 index 0000000000000000000000000000000000000000..4bf623757cf19ec60b419bd0cf639840301a5943 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/format.scm @@ -0,0 +1,1690 @@ +;;;; "format.scm" Common LISP text output formatter for SLIB +;;; Written 1992-1994 by Dirk Lutzebaeck (lutzeb@cs.tu-berlin.de) +;;; Assimilated into Guile May 1999 +;; +;; This code is in the public domain. + +;; Authors of the original version (< 1.4) were Ken Dickey and Aubrey Jaffer. +;; Please send error reports to bug-guile@gnu.org. +;; For documentation see slib.texi and format.doc. +;; For testing load formatst.scm. +;; +;; Version 3.0 + +(define-module (ice-9 format) + :use-module (ice-9 and-let-star) + :autoload (ice-9 pretty-print) (pretty-print) + :replace (format) + :export (format:symbol-case-conv + format:iobj-case-conv + format:expch)) + +;;; Configuration ------------------------------------------------------------ + +(define format:symbol-case-conv #f) +;; Symbols are converted by symbol->string so the case of the printed +;; symbols is implementation dependent. format:symbol-case-conv is a +;; one arg closure which is either #f (no conversion), string-upcase!, +;; string-downcase! or string-capitalize!. + +(define format:iobj-case-conv #f) +;; As format:symbol-case-conv but applies for the representation of +;; implementation internal objects. + +(define format:expch #\E) +;; The character prefixing the exponent value in ~e printing. + +(define format:floats (provided? 'inexact)) +;; Detects if the scheme system implements flonums (see at eof). + +(define format:complex-numbers (provided? 'complex)) +;; Detects if the scheme system implements complex numbers. + +(define format:radix-pref (char=? #\# (string-ref (number->string 8 8) 0))) +;; Detects if number->string adds a radix prefix. + +(define format:ascii-non-printable-charnames + '#("nul" "soh" "stx" "etx" "eot" "enq" "ack" "bel" + "bs" "ht" "nl" "vt" "np" "cr" "so" "si" + "dle" "dc1" "dc2" "dc3" "dc4" "nak" "syn" "etb" + "can" "em" "sub" "esc" "fs" "gs" "rs" "us" "space")) + +;;; End of configuration ---------------------------------------------------- + +(define (format . args) + (letrec + ((format:version "3.0") + (format:port #f) ; curr. format output port + (format:output-col 0) ; curr. format output tty column + (format:flush-output #f) ; flush output at end of formatting + (format:case-conversion #f) + (format:args #f) + (format:pos 0) ; curr. format string parsing position + (format:arg-pos 0) ; curr. format argument position + ; this is global for error presentation + + ;; format string and char output routines on format:port + + (format:out-str + (lambda (str) + (if format:case-conversion + (display (format:case-conversion str) format:port) + (display str format:port)) + (set! format:output-col + (+ format:output-col (string-length str))))) + + (format:out-char + (lambda (ch) + (if format:case-conversion + (display (format:case-conversion (string ch)) + format:port) + (write-char ch format:port)) + (set! format:output-col + (if (char=? ch #\newline) + 0 + (+ format:output-col 1))))) + + ;;(define (format:out-substr str i n) ; this allocates a new string + ;; (display (substring str i n) format:port) + ;; (set! format:output-col (+ format:output-col n))) + + (format:out-substr + (lambda (str i n) + (do ((k i (+ k 1))) + ((= k n)) + (write-char (string-ref str k) format:port)) + (set! format:output-col (+ format:output-col (- n i))))) + + ;;(define (format:out-fill n ch) ; this allocates a new string + ;; (format:out-str (make-string n ch))) + + (format:out-fill + (lambda (n ch) + (do ((i 0 (+ i 1))) + ((= i n)) + (write-char ch format:port)) + (set! format:output-col (+ format:output-col n)))) + + ;; format's user error handler + + (format:error + (lambda args ; never returns! + (let ((format-args format:args) + (port (current-error-port))) + (set! format:error format:intern-error) + (if (and (>= (length format:args) 2) + (string? (cadr format:args))) + (let ((format-string (cadr format-args))) + (if (not (zero? format:arg-pos)) + (set! format:arg-pos (- format:arg-pos 1))) + (format port + "~%FORMAT: error with call: (format ~a \"~a<===~a\" ~ + ~{~a ~}===>~{~a ~})~% " + (car format:args) + (substring format-string 0 format:pos) + (substring format-string format:pos + (string-length format-string)) + (list-head (cddr format:args) format:arg-pos) + (list-tail (cddr format:args) format:arg-pos))) + (format port + "~%FORMAT: error with call: (format~{ ~a~})~% " + format:args)) + (apply format port args) + (newline port) + (set! format:error format:error-save) + (format:abort)))) + + (format:intern-error + (lambda args + ;;if something goes wrong in format:error + (display "FORMAT: INTERNAL ERROR IN FORMAT:ERROR!") (newline) + (display " format args: ") (write format:args) (newline) + (display " error args: ") (write args) (newline) + (set! format:error format:error-save) + (format:abort))) + + (format:error-save #f) + + (format:format + (lambda args ; the formatter entry + (set! format:args args) + (set! format:arg-pos 0) + (set! format:pos 0) + (if (< (length args) 1) + (format:error "not enough arguments")) + + ;; If the first argument is a string, then that's the format string. + ;; (Scheme->C) + ;; In this case, put the argument list in canonical form. + (let ((args (if (string? (car args)) + (cons #f args) + args))) + ;; Use this canonicalized version when reporting errors. + (set! format:args args) + + (let ((destination (car args)) + (arglist (cdr args))) + (cond + ((or (and (boolean? destination) ; port output + destination) + (output-port? destination) + (number? destination)) + (format:out (cond + ((boolean? destination) (current-output-port)) + ((output-port? destination) destination) + ((number? destination) (current-error-port))) + (car arglist) (cdr arglist))) + ((and (boolean? destination) ; string output + (not destination)) + (call-with-output-string + (lambda (port) (format:out port (car arglist) (cdr arglist))))) + (else + (format:error "illegal destination `~a'" destination))))))) + + (format:out ; the output handler for a port + (lambda (port fmt args) + (set! format:port port) ; global port for + ; output routines + (set! format:case-conversion #f) ; modifier case + ; conversion procedure + (set! format:flush-output #f) ; ~! reset + (and-let* ((col (port-column port))) ; get current column from port + (set! format:output-col col)) + (let ((arg-pos (format:format-work fmt args)) + (arg-len (length args))) + (cond + ((> arg-pos arg-len) + (set! format:arg-pos (+ arg-len 1)) + (display format:arg-pos) + (format:error "~a missing argument~:p" (- arg-pos arg-len))) + (else + (if format:flush-output (force-output port)) + #t))))) + + (format:parameter-characters + '(#\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9 #\- #\+ #\v #\# #\')) + + (format:format-work ; does the formatting work + (lambda (format-string arglist) + (letrec + ((format-string-len (string-length format-string)) + (arg-pos 0) ; argument position in arglist + (arg-len (length arglist)) ; number of arguments + (modifier #f) ; 'colon | 'at | 'colon-at | #f + (params '()) ; directive parameter list + (param-value-found #f) ; a directive + ; parameter value + ; found + (conditional-nest 0) ; conditional nesting level + (clause-pos 0) ; last cond. clause + ; beginning char pos + (clause-default #f) ; conditional default + ; clause string + (clauses '()) ; conditional clause + ; string list + (conditional-type #f) ; reflects the + ; contional modifiers + (conditional-arg #f) ; argument to apply the conditional + (iteration-nest 0) ; iteration nesting level + (iteration-pos 0) ; iteration string + ; beginning char pos + (iteration-type #f) ; reflects the + ; iteration modifiers + (max-iterations #f) ; maximum number of + ; iterations + (recursive-pos-save format:pos) + + (next-char ; gets the next char + ; from format-string + (lambda () + (let ((ch (peek-next-char))) + (set! format:pos (+ 1 format:pos)) + ch))) + + (peek-next-char + (lambda () + (if (>= format:pos format-string-len) + (format:error "illegal format string") + (string-ref format-string format:pos)))) + + (one-positive-integer? + (lambda (params) + (cond + ((null? params) #f) + ((and (integer? (car params)) + (>= (car params) 0) + (= (length params) 1)) #t) + (else + (format:error + "one positive integer parameter expected"))))) + + (next-arg + (lambda () + (if (>= arg-pos arg-len) + (begin + (set! format:arg-pos (+ arg-len 1)) + (format:error "missing argument(s)"))) + (add-arg-pos 1) + (list-ref arglist (- arg-pos 1)))) + + (prev-arg + (lambda () + (add-arg-pos -1) + (if (negative? arg-pos) + (format:error "missing backward argument(s)")) + (list-ref arglist arg-pos))) + + (rest-args + (lambda () + (let loop ((l arglist) (k arg-pos)) ; list-tail definition + (if (= k 0) l (loop (cdr l) (- k 1)))))) + + (add-arg-pos + (lambda (n) + (set! arg-pos (+ n arg-pos)) + (set! format:arg-pos arg-pos))) + + (anychar-dispatch ; dispatches the format-string + (lambda () + (if (>= format:pos format-string-len) + arg-pos ; used for ~? continuance + (let ((char (next-char))) + (cond + ((char=? char #\~) + (set! modifier #f) + (set! params '()) + (set! param-value-found #f) + (tilde-dispatch)) + (else + (if (and (zero? conditional-nest) + (zero? iteration-nest)) + (format:out-char char)) + (anychar-dispatch))))))) + + (tilde-dispatch + (lambda () + (cond + ((>= format:pos format-string-len) + (format:out-str "~") ; tilde at end of + ; string is just + ; output + arg-pos) ; used for ~? + ; continuance + ((and (or (zero? conditional-nest) + (memv (peek-next-char) ; find conditional + ; directives + (append '(#\[ #\] #\; #\: #\@ #\^) + format:parameter-characters))) + (or (zero? iteration-nest) + (memv (peek-next-char) ; find iteration + ; directives + (append '(#\{ #\} #\: #\@ #\^) + format:parameter-characters)))) + (case (char-upcase (next-char)) + + ;; format directives + + ((#\A) ; Any -- for humans + (set! format:read-proof + (memq modifier '(colon colon-at))) + (format:out-obj-padded (memq modifier '(at colon-at)) + (next-arg) #f params) + (anychar-dispatch)) + ((#\S) ; Slashified -- for parsers + (set! format:read-proof + (memq modifier '(colon colon-at))) + (format:out-obj-padded (memq modifier '(at colon-at)) + (next-arg) #t params) + (anychar-dispatch)) + ((#\D) ; Decimal + (format:out-num-padded modifier (next-arg) params 10) + (anychar-dispatch)) + ((#\X) ; Hexadecimal + (format:out-num-padded modifier (next-arg) params 16) + (anychar-dispatch)) + ((#\O) ; Octal + (format:out-num-padded modifier (next-arg) params 8) + (anychar-dispatch)) + ((#\B) ; Binary + (format:out-num-padded modifier (next-arg) params 2) + (anychar-dispatch)) + ((#\R) + (if (null? params) + (format:out-obj-padded ; Roman, cardinal, + ; ordinal numerals + #f + ((case modifier + ((at) format:num->roman) + ((colon-at) format:num->old-roman) + ((colon) format:num->ordinal) + (else format:num->cardinal)) + (next-arg)) + #f params) + (format:out-num-padded ; any Radix + modifier (next-arg) (cdr params) (car params))) + (anychar-dispatch)) + ((#\F) ; Fixed-format floating-point + (if format:floats + (format:out-fixed modifier (next-arg) params) + (format:out-str (number->string (next-arg)))) + (anychar-dispatch)) + ((#\E) ; Exponential floating-point + (if format:floats + (format:out-expon modifier (next-arg) params) + (format:out-str (number->string (next-arg)))) + (anychar-dispatch)) + ((#\G) ; General floating-point + (if format:floats + (format:out-general modifier (next-arg) params) + (format:out-str (number->string (next-arg)))) + (anychar-dispatch)) + ((#\$) ; Dollars floating-point + (if format:floats + (format:out-dollar modifier (next-arg) params) + (format:out-str (number->string (next-arg)))) + (anychar-dispatch)) + ((#\I) ; Complex numbers + (if (not format:complex-numbers) + (format:error + "complex numbers not supported by this scheme system")) + (let ((z (next-arg))) + (if (not (complex? z)) + (format:error "argument not a complex number")) + (format:out-fixed modifier (real-part z) params) + (format:out-fixed 'at (imag-part z) params) + (format:out-char #\i)) + (anychar-dispatch)) + ((#\C) ; Character + (let ((ch (if (one-positive-integer? params) + (integer->char (car params)) + (next-arg)))) + (if (not (char? ch)) + (format:error "~~c expects a character")) + (case modifier + ((at) + (format:out-str (format:char->str ch))) + ((colon) + (let ((c (char->integer ch))) + (if (< c 0) + (set! c (+ c 256))) ; compensate + ; complement + ; impl. + (cond + ((< c #x20) ; assumes that control + ; chars are < #x20 + (format:out-char #\^) + (format:out-char + (integer->char (+ c #x40)))) + ((>= c #x7f) + (format:out-str "#\\") + (format:out-str + (if format:radix-pref + (let ((s (number->string c 8))) + (substring s 2 (string-length s))) + (number->string c 8)))) + (else + (format:out-char ch))))) + (else (format:out-char ch)))) + (anychar-dispatch)) + ((#\P) ; Plural + (if (memq modifier '(colon colon-at)) + (prev-arg)) + (let ((arg (next-arg))) + (if (not (number? arg)) + (format:error "~~p expects a number argument")) + (if (= arg 1) + (if (memq modifier '(at colon-at)) + (format:out-char #\y)) + (if (memq modifier '(at colon-at)) + (format:out-str "ies") + (format:out-char #\s)))) + (anychar-dispatch)) + ((#\~) ; Tilde + (if (one-positive-integer? params) + (format:out-fill (car params) #\~) + (format:out-char #\~)) + (anychar-dispatch)) + ((#\%) ; Newline + (if (one-positive-integer? params) + (format:out-fill (car params) #\newline) + (format:out-char #\newline)) + (set! format:output-col 0) + (anychar-dispatch)) + ((#\&) ; Fresh line + (if (one-positive-integer? params) + (begin + (if (> (car params) 0) + (format:out-fill (- (car params) + (if (> + format:output-col + 0) 0 1)) + #\newline)) + (set! format:output-col 0)) + (if (> format:output-col 0) + (format:out-char #\newline))) + (anychar-dispatch)) + ((#\_) ; Space character + (if (one-positive-integer? params) + (format:out-fill (car params) #\space) + (format:out-char #\space)) + (anychar-dispatch)) + ((#\/) ; Tabulator character + (if (one-positive-integer? params) + (format:out-fill (car params) #\tab) + (format:out-char #\tab)) + (anychar-dispatch)) + ((#\|) ; Page seperator + (if (one-positive-integer? params) + (format:out-fill (car params) #\page) + (format:out-char #\page)) + (set! format:output-col 0) + (anychar-dispatch)) + ((#\T) ; Tabulate + (format:tabulate modifier params) + (anychar-dispatch)) + ((#\Y) ; Pretty-print + (pretty-print (next-arg) format:port) + (set! format:output-col 0) + (anychar-dispatch)) + ((#\? #\K) ; Indirection (is "~K" in T-Scheme) + (cond + ((memq modifier '(colon colon-at)) + (format:error "illegal modifier in ~~?")) + ((eq? modifier 'at) + (let* ((frmt (next-arg)) + (args (rest-args))) + (add-arg-pos (format:format-work frmt args)))) + (else + (let* ((frmt (next-arg)) + (args (next-arg))) + (format:format-work frmt args)))) + (anychar-dispatch)) + ((#\!) ; Flush output + (set! format:flush-output #t) + (anychar-dispatch)) + ((#\newline) ; Continuation lines + (if (eq? modifier 'at) + (format:out-char #\newline)) + (if (< format:pos format-string-len) + (do ((ch (peek-next-char) (peek-next-char))) + ((or (not (char-whitespace? ch)) + (= format:pos (- format-string-len 1)))) + (if (eq? modifier 'colon) + (format:out-char (next-char)) + (next-char)))) + (anychar-dispatch)) + ((#\*) ; Argument jumping + (case modifier + ((colon) ; jump backwards + (if (one-positive-integer? params) + (do ((i 0 (+ i 1))) + ((= i (car params))) + (prev-arg)) + (prev-arg))) + ((at) ; jump absolute + (set! arg-pos (if (one-positive-integer? params) + (car params) 0))) + ((colon-at) + (format:error "illegal modifier `:@' in ~~* directive")) + (else ; jump forward + (if (one-positive-integer? params) + (do ((i 0 (+ i 1))) + ((= i (car params))) + (next-arg)) + (next-arg)))) + (anychar-dispatch)) + ((#\() ; Case conversion begin + (set! format:case-conversion + (case modifier + ((at) string-capitalize-first) + ((colon) string-capitalize) + ((colon-at) string-upcase) + (else string-downcase))) + (anychar-dispatch)) + ((#\)) ; Case conversion end + (if (not format:case-conversion) + (format:error "missing ~~(")) + (set! format:case-conversion #f) + (anychar-dispatch)) + ((#\[) ; Conditional begin + (set! conditional-nest (+ conditional-nest 1)) + (cond + ((= conditional-nest 1) + (set! clause-pos format:pos) + (set! clause-default #f) + (set! clauses '()) + (set! conditional-type + (case modifier + ((at) 'if-then) + ((colon) 'if-else-then) + ((colon-at) (format:error "illegal modifier in ~~[")) + (else 'num-case))) + (set! conditional-arg + (if (one-positive-integer? params) + (car params) + (next-arg))))) + (anychar-dispatch)) + ((#\;) ; Conditional separator + (if (zero? conditional-nest) + (format:error "~~; not in ~~[~~] conditional")) + (if (not (null? params)) + (format:error "no parameter allowed in ~~;")) + (if (= conditional-nest 1) + (let ((clause-str + (cond + ((eq? modifier 'colon) + (set! clause-default #t) + (substring format-string clause-pos + (- format:pos 3))) + ((memq modifier '(at colon-at)) + (format:error "illegal modifier in ~~;")) + (else + (substring format-string clause-pos + (- format:pos 2)))))) + (set! clauses (append clauses (list clause-str))) + (set! clause-pos format:pos))) + (anychar-dispatch)) + ((#\]) ; Conditional end + (if (zero? conditional-nest) (format:error "missing ~~[")) + (set! conditional-nest (- conditional-nest 1)) + (if modifier + (format:error "no modifier allowed in ~~]")) + (if (not (null? params)) + (format:error "no parameter allowed in ~~]")) + (cond + ((zero? conditional-nest) + (let ((clause-str (substring format-string clause-pos + (- format:pos 2)))) + (if clause-default + (set! clause-default clause-str) + (set! clauses (append clauses (list clause-str))))) + (case conditional-type + ((if-then) + (if conditional-arg + (format:format-work (car clauses) + (list conditional-arg)))) + ((if-else-then) + (add-arg-pos + (format:format-work (if conditional-arg + (cadr clauses) + (car clauses)) + (rest-args)))) + ((num-case) + (if (or (not (integer? conditional-arg)) + (< conditional-arg 0)) + (format:error "argument not a positive integer")) + (if (not (and (>= conditional-arg (length clauses)) + (not clause-default))) + (add-arg-pos + (format:format-work + (if (>= conditional-arg (length clauses)) + clause-default + (list-ref clauses conditional-arg)) + (rest-args)))))))) + (anychar-dispatch)) + ((#\{) ; Iteration begin + (set! iteration-nest (+ iteration-nest 1)) + (cond + ((= iteration-nest 1) + (set! iteration-pos format:pos) + (set! iteration-type + (case modifier + ((at) 'rest-args) + ((colon) 'sublists) + ((colon-at) 'rest-sublists) + (else 'list))) + (set! max-iterations (if (one-positive-integer? params) + (car params) #f)))) + (anychar-dispatch)) + ((#\}) ; Iteration end + (if (zero? iteration-nest) (format:error "missing ~~{")) + (set! iteration-nest (- iteration-nest 1)) + (case modifier + ((colon) + (if (not max-iterations) (set! max-iterations 1))) + ((colon-at at) (format:error "illegal modifier"))) + (if (not (null? params)) + (format:error "no parameters allowed in ~~}")) + (if (zero? iteration-nest) + (let ((iteration-str + (substring format-string iteration-pos + (- format:pos (if modifier 3 2))))) + (if (string=? iteration-str "") + (set! iteration-str (next-arg))) + (case iteration-type + ((list) + (let ((args (next-arg)) + (args-len 0)) + (if (not (list? args)) + (format:error "expected a list argument")) + (set! args-len (length args)) + (do ((arg-pos 0 (+ arg-pos + (format:format-work + iteration-str + (list-tail args arg-pos)))) + (i 0 (+ i 1))) + ((or (>= arg-pos args-len) + (and max-iterations + (>= i max-iterations))))))) + ((sublists) + (let ((args (next-arg)) + (args-len 0)) + (if (not (list? args)) + (format:error "expected a list argument")) + (set! args-len (length args)) + (do ((arg-pos 0 (+ arg-pos 1))) + ((or (>= arg-pos args-len) + (and max-iterations + (>= arg-pos max-iterations)))) + (let ((sublist (list-ref args arg-pos))) + (if (not (list? sublist)) + (format:error + "expected a list of lists argument")) + (format:format-work iteration-str sublist))))) + ((rest-args) + (let* ((args (rest-args)) + (args-len (length args)) + (usedup-args + (do ((arg-pos 0 (+ arg-pos + (format:format-work + iteration-str + (list-tail + args arg-pos)))) + (i 0 (+ i 1))) + ((or (>= arg-pos args-len) + (and max-iterations + (>= i max-iterations))) + arg-pos)))) + (add-arg-pos usedup-args))) + ((rest-sublists) + (let* ((args (rest-args)) + (args-len (length args)) + (usedup-args + (do ((arg-pos 0 (+ arg-pos 1))) + ((or (>= arg-pos args-len) + (and max-iterations + (>= arg-pos max-iterations))) + arg-pos) + (let ((sublist (list-ref args arg-pos))) + (if (not (list? sublist)) + (format:error "expected list arguments")) + (format:format-work iteration-str sublist))))) + (add-arg-pos usedup-args))) + (else (format:error "internal error in ~~}"))))) + (anychar-dispatch)) + ((#\^) ; Up and out + (let* ((continue + (cond + ((not (null? params)) + (not + (case (length params) + ((1) (zero? (car params))) + ((2) (= (list-ref params 0) (list-ref params 1))) + ((3) (<= (list-ref params 0) + (list-ref params 1) + (list-ref params 2))) + (else (format:error "too much parameters"))))) + (format:case-conversion ; if conversion stop conversion + (set! format:case-conversion string-copy) #t) + ((= iteration-nest 1) #t) + ((= conditional-nest 1) #t) + ((>= arg-pos arg-len) + (set! format:pos format-string-len) #f) + (else #t)))) + (if continue + (anychar-dispatch)))) + + ;; format directive modifiers and parameters + + ((#\@) ; `@' modifier + (if (memq modifier '(at colon-at)) + (format:error "double `@' modifier")) + (set! modifier (if (eq? modifier 'colon) 'colon-at 'at)) + (tilde-dispatch)) + ((#\:) ; `:' modifier + (if (memq modifier '(colon colon-at)) + (format:error "double `:' modifier")) + (set! modifier (if (eq? modifier 'at) 'colon-at 'colon)) + (tilde-dispatch)) + ((#\') ; Character parameter + (if modifier (format:error "misplaced modifier")) + (set! params (append params (list (char->integer (next-char))))) + (set! param-value-found #t) + (tilde-dispatch)) + ((#\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9 #\- #\+) ; num. paramtr + (if modifier (format:error "misplaced modifier")) + (let ((num-str-beg (- format:pos 1)) + (num-str-end format:pos)) + (do ((ch (peek-next-char) (peek-next-char))) + ((not (char-numeric? ch))) + (next-char) + (set! num-str-end (+ 1 num-str-end))) + (set! params + (append params + (list (string->number + (substring format-string + num-str-beg + num-str-end)))))) + (set! param-value-found #t) + (tilde-dispatch)) + ((#\V) ; Variable parameter from next argum. + (if modifier (format:error "misplaced modifier")) + (set! params (append params (list (next-arg)))) + (set! param-value-found #t) + (tilde-dispatch)) + ((#\#) ; Parameter is number of remaining args + (if param-value-found (format:error "misplaced '#'")) + (if modifier (format:error "misplaced modifier")) + (set! params (append params (list (length (rest-args))))) + (set! param-value-found #t) + (tilde-dispatch)) + ((#\,) ; Parameter separators + (if modifier (format:error "misplaced modifier")) + (if (not param-value-found) + (set! params (append params '(#f)))) ; append empty paramtr + (set! param-value-found #f) + (tilde-dispatch)) + ((#\Q) ; Inquiry messages + (if (eq? modifier 'colon) + (format:out-str format:version) + (let ((nl (string #\newline))) + (format:out-str + (string-append + "SLIB Common LISP format version " format:version nl + " (C) copyright 1992-1994 by Dirk Lutzebaeck" nl + " please send bug reports to `lutzeb@cs.tu-berlin.de'" + nl)))) + (anychar-dispatch)) + (else ; Unknown tilde directive + (format:error "unknown control character `~c'" + (string-ref format-string (- format:pos 1)))))) + (else (anychar-dispatch)))))) ; in case of conditional + + (set! format:pos 0) + (set! format:arg-pos 0) + (anychar-dispatch) ; start the formatting + (set! format:pos recursive-pos-save) + arg-pos))) ; return the position in the arg. list + + ;; when format:read-proof is true, format:obj->str will wrap + ;; result strings starting with "#<" in an extra pair of double + ;; quotes. + + (format:read-proof #f) + + ;; format:obj->str returns a R4RS representation as a string of + ;; an arbitrary scheme object. + + (format:obj->str + (lambda (obj slashify) + (let ((res (if slashify + (object->string obj) + (with-output-to-string (lambda () (display obj)))))) + (if (and format:read-proof (string-prefix? "#<" res)) + (object->string res) + res)))) + + ;; format:char->str converts a character into a slashified string as + ;; done by `write'. The procedure is dependent on the integer + ;; representation of characters and assumes a character number according to + ;; the ASCII character set. + + (format:char->str + (lambda (ch) + (let ((int-rep (char->integer ch))) + (if (< int-rep 0) ; if chars are [-128...+127] + (set! int-rep (+ int-rep 256))) + (string-append + "#\\" + (cond + ((char=? ch #\newline) "newline") + ((and (>= int-rep 0) (<= int-rep 32)) + (vector-ref format:ascii-non-printable-charnames int-rep)) + ((= int-rep 127) "del") + ((>= int-rep 128) ; octal representation + (if format:radix-pref + (let ((s (number->string int-rep 8))) + (substring s 2 (string-length s))) + (number->string int-rep 8))) + (else (string ch))))))) + + (format:space-ch (char->integer #\space)) + (format:zero-ch (char->integer #\0)) + + (format:par + (lambda (pars length index default name) + (if (> length index) + (let ((par (list-ref pars index))) + (if par + (if name + (if (< par 0) + (format:error + "~s parameter must be a positive integer" name) + par) + par) + default)) + default))) + + (format:out-obj-padded + (lambda (pad-left obj slashify pars) + (if (null? pars) + (format:out-str (format:obj->str obj slashify)) + (let ((l (length pars))) + (let ((mincol (format:par pars l 0 0 "mincol")) + (colinc (format:par pars l 1 1 "colinc")) + (minpad (format:par pars l 2 0 "minpad")) + (padchar (integer->char + (format:par pars l 3 format:space-ch #f))) + (objstr (format:obj->str obj slashify))) + (if (not pad-left) + (format:out-str objstr)) + (do ((objstr-len (string-length objstr)) + (i minpad (+ i colinc))) + ((>= (+ objstr-len i) mincol) + (format:out-fill i padchar))) + (if pad-left + (format:out-str objstr))))))) + + (format:out-num-padded + (lambda (modifier number pars radix) + (if (not (integer? number)) (format:error "argument not an integer")) + (let ((numstr (number->string number radix))) + (if (and format:radix-pref (not (= radix 10))) + (set! numstr (substring numstr 2 (string-length numstr)))) + (if (and (null? pars) (not modifier)) + (format:out-str numstr) + (let ((l (length pars)) + (numstr-len (string-length numstr))) + (let ((mincol (format:par pars l 0 #f "mincol")) + (padchar (integer->char + (format:par pars l 1 format:space-ch #f))) + (commachar (integer->char + (format:par pars l 2 (char->integer #\,) #f))) + (commawidth (format:par pars l 3 3 "commawidth"))) + (if mincol + (let ((numlen numstr-len)) ; calc. the output len of number + (if (and (memq modifier '(at colon-at)) (>= number 0)) + (set! numlen (+ numlen 1))) + (if (memq modifier '(colon colon-at)) + (set! numlen (+ (quotient (- numstr-len + (if (< number 0) 2 1)) + commawidth) + numlen))) + (if (> mincol numlen) + (format:out-fill (- mincol numlen) padchar)))) + (if (and (memq modifier '(at colon-at)) + (>= number 0)) + (format:out-char #\+)) + (if (memq modifier '(colon colon-at)) ; insert comma character + (let ((start (remainder numstr-len commawidth)) + (ns (if (< number 0) 1 0))) + (format:out-substr numstr 0 start) + (do ((i start (+ i commawidth))) + ((>= i numstr-len)) + (if (> i ns) + (format:out-char commachar)) + (format:out-substr numstr i (+ i commawidth)))) + (format:out-str numstr)))))))) + + (format:tabulate + (lambda (modifier pars) + (let ((l (length pars))) + (let ((colnum (format:par pars l 0 1 "colnum")) + (colinc (format:par pars l 1 1 "colinc")) + (padch (integer->char (format:par pars l 2 format:space-ch #f)))) + (case modifier + ((colon colon-at) + (format:error "unsupported modifier for ~~t")) + ((at) ; relative tabulation + (format:out-fill + (if (= colinc 0) + colnum ; colnum = colrel + (do ((c 0 (+ c colinc)) + (col (+ format:output-col colnum))) + ((>= c col) + (- c format:output-col)))) + padch)) + (else ; absolute tabulation + (format:out-fill + (cond + ((< format:output-col colnum) + (- colnum format:output-col)) + ((= colinc 0) + 0) + (else + (do ((c colnum (+ c colinc))) + ((>= c format:output-col) + (- c format:output-col))))) + padch))))))) + + + ;; roman numerals (from dorai@cs.rice.edu). + + (format:roman-alist + '((1000 #\M) (500 #\D) (100 #\C) (50 #\L) + (10 #\X) (5 #\V) (1 #\I))) + + (format:roman-boundary-values + '(100 100 10 10 1 1 #f)) + + (format:num->old-roman + (lambda (n) + (if (and (integer? n) (>= n 1)) + (let loop ((n n) + (romans format:roman-alist) + (s '())) + (if (null? romans) (list->string (reverse s)) + (let ((roman-val (caar romans)) + (roman-dgt (cadar romans))) + (do ((q (quotient n roman-val) (- q 1)) + (s s (cons roman-dgt s))) + ((= q 0) + (loop (remainder n roman-val) + (cdr romans) s)))))) + (format:error "only positive integers can be romanized")))) + + (format:num->roman + (lambda (n) + (if (and (integer? n) (> n 0)) + (let loop ((n n) + (romans format:roman-alist) + (boundaries format:roman-boundary-values) + (s '())) + (if (null? romans) + (list->string (reverse s)) + (let ((roman-val (caar romans)) + (roman-dgt (cadar romans)) + (bdry (car boundaries))) + (let loop2 ((q (quotient n roman-val)) + (r (remainder n roman-val)) + (s s)) + (if (= q 0) + (if (and bdry (>= r (- roman-val bdry))) + (loop (remainder r bdry) (cdr romans) + (cdr boundaries) + (cons roman-dgt + (append + (cdr (assv bdry romans)) + s))) + (loop r (cdr romans) (cdr boundaries) s)) + (loop2 (- q 1) r (cons roman-dgt s))))))) + (format:error "only positive integers can be romanized")))) + + ;; cardinals & ordinals (from dorai@cs.rice.edu) + + (format:cardinal-ones-list + '(#f "one" "two" "three" "four" "five" + "six" "seven" "eight" "nine" "ten" "eleven" "twelve" "thirteen" + "fourteen" "fifteen" "sixteen" "seventeen" "eighteen" + "nineteen")) + + (format:cardinal-tens-list + '(#f #f "twenty" "thirty" "forty" "fifty" "sixty" "seventy" "eighty" + "ninety")) + + (format:num->cardinal999 + (lambda (n) + ;this procedure is inspired by the Bruno Haible's CLisp + ;function format-small-cardinal, which converts numbers + ;in the range 1 to 999, and is used for converting each + ;thousand-block in a larger number + (let* ((hundreds (quotient n 100)) + (tens+ones (remainder n 100)) + (tens (quotient tens+ones 10)) + (ones (remainder tens+ones 10))) + (append + (if (> hundreds 0) + (append + (string->list + (list-ref format:cardinal-ones-list hundreds)) + (string->list" hundred") + (if (> tens+ones 0) '(#\space) '())) + '()) + (if (< tens+ones 20) + (if (> tens+ones 0) + (string->list + (list-ref format:cardinal-ones-list tens+ones)) + '()) + (append + (string->list + (list-ref format:cardinal-tens-list tens)) + (if (> ones 0) + (cons #\- + (string->list + (list-ref format:cardinal-ones-list ones))) + '()))))))) + + (format:cardinal-thousand-block-list + '("" " thousand" " million" " billion" " trillion" " quadrillion" + " quintillion" " sextillion" " septillion" " octillion" " nonillion" + " decillion" " undecillion" " duodecillion" " tredecillion" + " quattuordecillion" " quindecillion" " sexdecillion" " septendecillion" + " octodecillion" " novemdecillion" " vigintillion")) + + (format:num->cardinal + (lambda (n) + (cond ((not (integer? n)) + (format:error + "only integers can be converted to English cardinals")) + ((= n 0) "zero") + ((< n 0) (string-append "minus " (format:num->cardinal (- n)))) + (else + (let ((power3-word-limit + (length format:cardinal-thousand-block-list))) + (let loop ((n n) + (power3 0) + (s '())) + (if (= n 0) + (list->string s) + (let ((n-before-block (quotient n 1000)) + (n-after-block (remainder n 1000))) + (loop n-before-block + (+ power3 1) + (if (> n-after-block 0) + (append + (if (> n-before-block 0) + (string->list ", ") '()) + (format:num->cardinal999 n-after-block) + (if (< power3 power3-word-limit) + (string->list + (list-ref + format:cardinal-thousand-block-list + power3)) + (append + (string->list " times ten to the ") + (string->list + (format:num->ordinal + (* power3 3))) + (string->list " power"))) + s) + s)))))))))) + + (format:ordinal-ones-list + '(#f "first" "second" "third" "fourth" "fifth" + "sixth" "seventh" "eighth" "ninth" "tenth" "eleventh" "twelfth" + "thirteenth" "fourteenth" "fifteenth" "sixteenth" "seventeenth" + "eighteenth" "nineteenth")) + + (format:ordinal-tens-list + '(#f #f "twentieth" "thirtieth" "fortieth" "fiftieth" "sixtieth" + "seventieth" "eightieth" "ninetieth")) + + (format:num->ordinal + (lambda (n) + (cond ((not (integer? n)) + (format:error + "only integers can be converted to English ordinals")) + ((= n 0) "zeroth") + ((< n 0) (string-append "minus " (format:num->ordinal (- n)))) + (else + (let ((hundreds (quotient n 100)) + (tens+ones (remainder n 100))) + (string-append + (if (> hundreds 0) + (string-append + (format:num->cardinal (* hundreds 100)) + (if (= tens+ones 0) "th" " ")) + "") + (if (= tens+ones 0) "" + (if (< tens+ones 20) + (list-ref format:ordinal-ones-list tens+ones) + (let ((tens (quotient tens+ones 10)) + (ones (remainder tens+ones 10))) + (if (= ones 0) + (list-ref format:ordinal-tens-list tens) + (string-append + (list-ref format:cardinal-tens-list tens) + "-" + (list-ref format:ordinal-ones-list ones)))) + )))))))) + + ;; format inf and nan. + + (format:out-inf-nan + (lambda (number width digits edigits overch padch) + ;; inf and nan are always printed exactly as "+inf.0", "-inf.0" or + ;; "+nan.0", suitably justified in their field. We insist on + ;; printing this exact form so that the numbers can be read back in. + + (let* ((str (number->string number)) + (len (string-length str)) + (dot (string-index str #\.)) + (digits (+ (or digits 0) + (if edigits (+ edigits 2) 0)))) + (if (and width overch (< width len)) + (format:out-fill width (integer->char overch)) + (let* ((leftpad (if width + (max (- width (max len (+ dot 1 digits))) 0) + 0)) + (rightpad (if width + (max (- width leftpad len) 0) + 0)) + (padch (integer->char (or padch format:space-ch)))) + (format:out-fill leftpad padch) + (format:out-str str) + (format:out-fill rightpad padch)))))) + + ;; format fixed flonums (~F) + + (format:out-fixed + (lambda (modifier number pars) + (if (not (or (number? number) (string? number))) + (format:error "argument is not a number or a number string")) + + (let ((l (length pars))) + (let ((width (format:par pars l 0 #f "width")) + (digits (format:par pars l 1 #f "digits")) + (scale (format:par pars l 2 0 #f)) + (overch (format:par pars l 3 #f #f)) + (padch (format:par pars l 4 format:space-ch #f))) + + (cond + ((or (inf? number) (nan? number)) + (format:out-inf-nan number width digits #f overch padch)) + + (digits + (format:parse-float + (if (string? number) number (number->string number)) #t scale) + (if (<= (- format:fn-len format:fn-dot) digits) + (format:fn-zfill #f (- digits (- format:fn-len format:fn-dot))) + (format:fn-round digits)) + (if width + (let ((numlen (+ format:fn-len 1))) + (if (or (not format:fn-pos?) (eq? modifier 'at)) + (set! numlen (+ numlen 1))) + (if (and (= format:fn-dot 0) (> width (+ digits 1))) + (set! numlen (+ numlen 1))) + (if (< numlen width) + (format:out-fill (- width numlen) (integer->char padch))) + (if (and overch (> numlen width)) + (format:out-fill width (integer->char overch)) + (format:fn-out modifier (> width (+ digits 1))))) + (format:fn-out modifier #t))) + + (else + (format:parse-float + (if (string? number) number (number->string number)) #t scale) + (format:fn-strip) + (if width + (let ((numlen (+ format:fn-len 1))) + (if (or (not format:fn-pos?) (eq? modifier 'at)) + (set! numlen (+ numlen 1))) + (if (= format:fn-dot 0) + (set! numlen (+ numlen 1))) + (if (< numlen width) + (format:out-fill (- width numlen) (integer->char padch))) + (if (> numlen width) ; adjust precision if possible + (let ((dot-index (- numlen + (- format:fn-len format:fn-dot)))) + (if (> dot-index width) + (if overch ; numstr too big for required width + (format:out-fill width (integer->char overch)) + (format:fn-out modifier #t)) + (begin + (format:fn-round (- width dot-index)) + (format:fn-out modifier #t)))) + (format:fn-out modifier #t))) + (format:fn-out modifier #t)))))))) + + ;; format exponential flonums (~E) + + (format:out-expon + (lambda (modifier number pars) + (if (not (or (number? number) (string? number))) + (format:error "argument is not a number")) + + (let ((l (length pars))) + (let ((width (format:par pars l 0 #f "width")) + (digits (format:par pars l 1 #f "digits")) + (edigits (format:par pars l 2 #f "exponent digits")) + (scale (format:par pars l 3 1 #f)) + (overch (format:par pars l 4 #f #f)) + (padch (format:par pars l 5 format:space-ch #f)) + (expch (format:par pars l 6 #f #f))) + + (cond + ((or (inf? number) (nan? number)) + (format:out-inf-nan number width digits edigits overch padch)) + + (digits ; fixed precision + + (let ((digits (if (> scale 0) + (if (< scale (+ digits 2)) + (+ (- digits scale) 1) + 0) + digits))) + (format:parse-float + (if (string? number) number (number->string number)) #f scale) + (if (<= (- format:fn-len format:fn-dot) digits) + (format:fn-zfill #f (- digits (- format:fn-len format:fn-dot))) + (format:fn-round digits)) + (if width + (if (and edigits overch (> format:en-len edigits)) + (format:out-fill width (integer->char overch)) + (let ((numlen (+ format:fn-len 3))) ; .E+ + (if (or (not format:fn-pos?) (eq? modifier 'at)) + (set! numlen (+ numlen 1))) + (if (and (= format:fn-dot 0) (> width (+ digits 1))) + (set! numlen (+ numlen 1))) + (set! numlen + (+ numlen + (if (and edigits (>= edigits format:en-len)) + edigits + format:en-len))) + (if (< numlen width) + (format:out-fill (- width numlen) + (integer->char padch))) + (if (and overch (> numlen width)) + (format:out-fill width (integer->char overch)) + (begin + (format:fn-out modifier (> width (- numlen 1))) + (format:en-out edigits expch))))) + (begin + (format:fn-out modifier #t) + (format:en-out edigits expch))))) + + (else + (format:parse-float + (if (string? number) number (number->string number)) #f scale) + (format:fn-strip) + (if width + (if (and edigits overch (> format:en-len edigits)) + (format:out-fill width (integer->char overch)) + (let ((numlen (+ format:fn-len 3))) ; .E+ + (if (or (not format:fn-pos?) (eq? modifier 'at)) + (set! numlen (+ numlen 1))) + (if (= format:fn-dot 0) + (set! numlen (+ numlen 1))) + (set! numlen + (+ numlen + (if (and edigits (>= edigits format:en-len)) + edigits + format:en-len))) + (if (< numlen width) + (format:out-fill (- width numlen) + (integer->char padch))) + (if (> numlen width) ; adjust precision if possible + (let ((f (- format:fn-len format:fn-dot))) ; fract len + (if (> (- numlen f) width) + (if overch ; numstr too big for required width + (format:out-fill width + (integer->char overch)) + (begin + (format:fn-out modifier #t) + (format:en-out edigits expch))) + (begin + (format:fn-round (+ (- f numlen) width)) + (format:fn-out modifier #t) + (format:en-out edigits expch)))) + (begin + (format:fn-out modifier #t) + (format:en-out edigits expch))))) + (begin + (format:fn-out modifier #t) + (format:en-out edigits expch))))))))) + + ;; format general flonums (~G) + + (format:out-general + (lambda (modifier number pars) + (if (not (or (number? number) (string? number))) + (format:error "argument is not a number or a number string")) + + (let ((l (length pars))) + (let ((width (if (> l 0) (list-ref pars 0) #f)) + (digits (if (> l 1) (list-ref pars 1) #f)) + (edigits (if (> l 2) (list-ref pars 2) #f)) + (overch (if (> l 4) (list-ref pars 4) #f)) + (padch (if (> l 5) (list-ref pars 5) #f))) + (cond + ((or (inf? number) (nan? number)) + ;; FIXME: this isn't right. + (format:out-inf-nan number width digits edigits overch padch)) + (else + (format:parse-float + (if (string? number) number (number->string number)) #t 0) + (format:fn-strip) + (let* ((ee (if edigits (+ edigits 2) 4)) ; for the following algorithm + (ww (if width (- width ee) #f)) ; see Steele's CL book p.395 + (n (if (= format:fn-dot 0) ; number less than (abs 1.0) ? + (- (format:fn-zlead)) + format:fn-dot)) + (d (if digits + digits + (max format:fn-len (min n 7)))) ; q = format:fn-len + (dd (- d n))) + (if (<= 0 dd d) + (begin + (format:out-fixed modifier number (list ww dd #f overch padch)) + (format:out-fill ee #\space)) ;~@T not implemented yet + (format:out-expon modifier number pars))))))))) + + ;; format dollar flonums (~$) + + (format:out-dollar + (lambda (modifier number pars) + (if (not (or (number? number) (string? number))) + (format:error "argument is not a number or a number string")) + + (let ((l (length pars))) + (let ((digits (format:par pars l 0 2 "digits")) + (mindig (format:par pars l 1 1 "mindig")) + (width (format:par pars l 2 0 "width")) + (padch (format:par pars l 3 format:space-ch #f))) + + (cond + ((or (inf? number) (nan? number)) + (format:out-inf-nan number width digits #f #f padch)) + + (else + (format:parse-float + (if (string? number) number (number->string number)) #t 0) + (if (<= (- format:fn-len format:fn-dot) digits) + (format:fn-zfill #f (- digits (- format:fn-len format:fn-dot))) + (format:fn-round digits)) + (let ((numlen (+ format:fn-len 1))) + (if (or (not format:fn-pos?) (memq modifier '(at colon-at))) + (set! numlen (+ numlen 1))) + (if (and mindig (> mindig format:fn-dot)) + (set! numlen (+ numlen (- mindig format:fn-dot)))) + (if (and (= format:fn-dot 0) (not mindig)) + (set! numlen (+ numlen 1))) + (if (< numlen width) + (case modifier + ((colon) + (if (not format:fn-pos?) + (format:out-char #\-)) + (format:out-fill (- width numlen) (integer->char padch))) + ((at) + (format:out-fill (- width numlen) (integer->char padch)) + (format:out-char (if format:fn-pos? #\+ #\-))) + ((colon-at) + (format:out-char (if format:fn-pos? #\+ #\-)) + (format:out-fill (- width numlen) (integer->char padch))) + (else + (format:out-fill (- width numlen) (integer->char padch)) + (if (not format:fn-pos?) + (format:out-char #\-)))) + (if format:fn-pos? + (if (memq modifier '(at colon-at)) (format:out-char #\+)) + (format:out-char #\-)))) + (if (and mindig (> mindig format:fn-dot)) + (format:out-fill (- mindig format:fn-dot) #\0)) + (if (and (= format:fn-dot 0) (not mindig)) + (format:out-char #\0)) + (format:out-substr format:fn-str 0 format:fn-dot) + (format:out-char #\.) + (format:out-substr format:fn-str format:fn-dot format:fn-len))))))) + + ; the flonum buffers + + (format:fn-max 400) ; max. number of number digits + (format:fn-str #f) ; number buffer + (format:fn-len 0) ; digit length of number + (format:fn-dot #f) ; dot position of number + (format:fn-pos? #t) ; number positive? + (format:en-max 10) ; max. number of exponent digits + (format:en-str #f) ; exponent buffer + (format:en-len 0) ; digit length of exponent + (format:en-pos? #t) ; exponent positive? + + (format:parse-float + (lambda (num-str fixed? scale) + (set! format:fn-pos? #t) + (set! format:fn-len 0) + (set! format:fn-dot #f) + (set! format:en-pos? #t) + (set! format:en-len 0) + (do ((i 0 (+ i 1)) + (left-zeros 0) + (mantissa? #t) + (all-zeros? #t) + (num-len (string-length num-str)) + (c #f)) ; current exam. character in num-str + ((= i num-len) + (if (not format:fn-dot) + (set! format:fn-dot format:fn-len)) + + (if all-zeros? + (begin + (set! left-zeros 0) + (set! format:fn-dot 0) + (set! format:fn-len 1))) + + ;; now format the parsed values according to format's need + + (if fixed? + + (begin ; fixed format m.nnn or .nnn + (if (and (> left-zeros 0) (> format:fn-dot 0)) + (if (> format:fn-dot left-zeros) + (begin ; norm 0{0}nn.mm to nn.mm + (format:fn-shiftleft left-zeros) + (set! format:fn-dot (- format:fn-dot left-zeros)) + (set! left-zeros 0)) + (begin ; normalize 0{0}.nnn to .nnn + (format:fn-shiftleft format:fn-dot) + (set! left-zeros (- left-zeros format:fn-dot)) + (set! format:fn-dot 0)))) + (if (or (not (= scale 0)) (> format:en-len 0)) + (let ((shift (+ scale (format:en-int)))) + (cond + (all-zeros? #t) + ((> (+ format:fn-dot shift) format:fn-len) + (format:fn-zfill + #f (- shift (- format:fn-len format:fn-dot))) + (set! format:fn-dot format:fn-len)) + ((< (+ format:fn-dot shift) 0) + (format:fn-zfill #t (- (- shift) format:fn-dot)) + (set! format:fn-dot 0)) + (else + (if (> left-zeros 0) + (if (<= left-zeros shift) ; shift always > 0 here + (format:fn-shiftleft shift) ; shift out 0s + (begin + (format:fn-shiftleft left-zeros) + (set! format:fn-dot (- shift left-zeros)))) + (set! format:fn-dot (+ format:fn-dot shift)))))))) + + (let ((negexp ; expon format m.nnnEee + (if (> left-zeros 0) + (- left-zeros format:fn-dot -1) + (if (= format:fn-dot 0) 1 0)))) + (if (> left-zeros 0) + (begin ; normalize 0{0}.nnn to n.nn + (format:fn-shiftleft left-zeros) + (set! format:fn-dot 1)) + (if (= format:fn-dot 0) + (set! format:fn-dot 1))) + (format:en-set (- (+ (- format:fn-dot scale) (format:en-int)) + negexp)) + (cond + (all-zeros? + (format:en-set 0) + (set! format:fn-dot 1)) + ((< scale 0) ; leading zero + (format:fn-zfill #t (- scale)) + (set! format:fn-dot 0)) + ((> scale format:fn-dot) + (format:fn-zfill #f (- scale format:fn-dot)) + (set! format:fn-dot scale)) + (else + (set! format:fn-dot scale))))) + #t) + + ;; do body + (set! c (string-ref num-str i)) ; parse the output of number->string + (cond ; which can be any valid number + ((char-numeric? c) ; representation of R4RS except + (if mantissa? ; complex numbers + (begin + (if (char=? c #\0) + (if all-zeros? + (set! left-zeros (+ left-zeros 1))) + (begin + (set! all-zeros? #f))) + (string-set! format:fn-str format:fn-len c) + (set! format:fn-len (+ format:fn-len 1))) + (begin + (string-set! format:en-str format:en-len c) + (set! format:en-len (+ format:en-len 1))))) + ((or (char=? c #\-) (char=? c #\+)) + (if mantissa? + (set! format:fn-pos? (char=? c #\+)) + (set! format:en-pos? (char=? c #\+)))) + ((char=? c #\.) + (set! format:fn-dot format:fn-len)) + ((char=? c #\e) + (set! mantissa? #f)) + ((char=? c #\E) + (set! mantissa? #f)) + ((char-whitespace? c) #t) + ((char=? c #\d) #t) ; decimal radix prefix + ((char=? c #\#) #t) + (else + (format:error "illegal character `~c' in number->string" c)))))) + + (format:en-int + (lambda () ; convert exponent string to integer + (if (= format:en-len 0) + 0 + (do ((i 0 (+ i 1)) + (n 0)) + ((= i format:en-len) + (if format:en-pos? + n + (- n))) + (set! n (+ (* n 10) (- (char->integer (string-ref format:en-str i)) + format:zero-ch))))))) + + (format:en-set ; set exponent string number + (lambda (en) + (set! format:en-len 0) + (set! format:en-pos? (>= en 0)) + (let ((en-str (number->string en))) + (do ((i 0 (+ i 1)) + (en-len (string-length en-str)) + (c #f)) + ((= i en-len)) + (set! c (string-ref en-str i)) + (if (char-numeric? c) + (begin + (string-set! format:en-str format:en-len c) + (set! format:en-len (+ format:en-len 1)))))))) + + (format:fn-zfill ; fill current number string with 0s + (lambda (left? n) + (if (> (+ n format:fn-len) format:fn-max) ; from the left or right + (format:error "number is too long to format (enlarge format:fn-max)")) + (set! format:fn-len (+ format:fn-len n)) + (if left? + (do ((i format:fn-len (- i 1))) ; fill n 0s to left + ((< i 0)) + (string-set! format:fn-str i + (if (< i n) + #\0 + (string-ref format:fn-str (- i n))))) + (do ((i (- format:fn-len n) (+ i 1))) ; fill n 0s to the right + ((= i format:fn-len)) + (string-set! format:fn-str i #\0))))) + + (format:fn-shiftleft ; shift left current number n positions + (lambda (n) + (if (> n format:fn-len) + (format:error "internal error in format:fn-shiftleft (~d,~d)" + n format:fn-len)) + (do ((i n (+ i 1))) + ((= i format:fn-len) + (set! format:fn-len (- format:fn-len n))) + (string-set! format:fn-str (- i n) (string-ref format:fn-str i))))) + + (format:fn-round ; round format:fn-str + (lambda (digits) + (set! digits (+ digits format:fn-dot)) + (do ((i digits (- i 1)) ; "099",2 -> "10" + (c 5)) ; "023",2 -> "02" + ((or (= c 0) (< i 0)) ; "999",2 -> "100" + (if (= c 1) ; "005",2 -> "01" + (begin ; carry overflow + (set! format:fn-len digits) + (format:fn-zfill #t 1) ; add a 1 before fn-str + (string-set! format:fn-str 0 #\1) + (set! format:fn-dot (+ format:fn-dot 1))) + (set! format:fn-len digits))) + (set! c (+ (- (char->integer (string-ref format:fn-str i)) + format:zero-ch) c)) + (string-set! format:fn-str i (integer->char + (if (< c 10) + (+ c format:zero-ch) + (+ (- c 10) format:zero-ch)))) + (set! c (if (< c 10) 0 1))))) + + (format:fn-out + (lambda (modifier add-leading-zero?) + (if format:fn-pos? + (if (eq? modifier 'at) + (format:out-char #\+)) + (format:out-char #\-)) + (if (= format:fn-dot 0) + (if add-leading-zero? + (format:out-char #\0)) + (format:out-substr format:fn-str 0 format:fn-dot)) + (format:out-char #\.) + (format:out-substr format:fn-str format:fn-dot format:fn-len))) + + (format:en-out + (lambda (edigits expch) + (format:out-char (if expch (integer->char expch) format:expch)) + (format:out-char (if format:en-pos? #\+ #\-)) + (if edigits + (if (< format:en-len edigits) + (format:out-fill (- edigits format:en-len) #\0))) + (format:out-substr format:en-str 0 format:en-len))) + + (format:fn-strip ; strip trailing zeros but one + (lambda () + (string-set! format:fn-str format:fn-len #\0) + (do ((i format:fn-len (- i 1))) + ((or (not (char=? (string-ref format:fn-str i) #\0)) + (<= i format:fn-dot)) + (set! format:fn-len (+ i 1)))))) + + (format:fn-zlead ; count leading zeros + (lambda () + (do ((i 0 (+ i 1))) + ((or (= i format:fn-len) + (not (char=? (string-ref format:fn-str i) #\0))) + (if (= i format:fn-len) ; found a real zero + 0 + i))))) + + +;;; some global functions not found in SLIB + + (string-capitalize-first ; "hello" -> "Hello" + (lambda (str) + (let ((cap-str (string-copy str)) ; "hELLO" -> "Hello" + (non-first-alpha #f) ; "*hello" -> "*Hello" + (str-len (string-length str))) ; "hello you" -> "Hello you" + (do ((i 0 (+ i 1))) + ((= i str-len) cap-str) + (let ((c (string-ref str i))) + (if (char-alphabetic? c) + (if non-first-alpha + (string-set! cap-str i (char-downcase c)) + (begin + (set! non-first-alpha #t) + (string-set! cap-str i (char-upcase c)))))))))) + + ;; Aborts the program when a formatting error occures. This is a null + ;; argument closure to jump to the interpreters toplevel continuation. + + (format:abort (lambda () (error "error in format")))) + + (set! format:error-save format:error) + (set! format:fn-str (make-string format:fn-max)) ; number buffer + (set! format:en-str (make-string format:en-max)) ; exponent buffer + (apply format:format args))) + +;; Thanks to Shuji Narazaki +(module-set! the-root-module 'format format) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/ftw.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/ftw.scm new file mode 100755 index 0000000000000000000000000000000000000000..23f341521e0965b317a41066d4b85a11b00c8d5d --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/ftw.scm @@ -0,0 +1,380 @@ +;;;; ftw.scm --- filesystem tree walk + +;;;; Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +;;; Author: Thien-Thi Nguyen + +;;; Commentary: + +;; Two procedures are provided: `ftw' and `nftw'. + +;; NOTE: The following description was adapted from the GNU libc info page, w/ +;; significant modifications for a more "Schemey" interface. Most noticible +;; are the inlining of `struct FTW *' parameters `base' and `level' and the +;; omission of `descriptors' parameters. + +;; * Types +;; +;; The X/Open specification defines two procedures to process whole +;; hierarchies of directories and the contained files. Both procedures +;; of this `ftw' family take as one of the arguments a callback procedure +;; which must be of these types. +;; +;; - Data Type: __ftw_proc_t +;; (lambda (filename statinfo flag) ...) => status +;; +;; Type for callback procedures given to the `ftw' procedure. The +;; first parameter is a filename, the second parameter is the +;; vector value as returned by calling `stat' on FILENAME. +;; +;; The last parameter is a symbol giving more information about +;; FILENAM. It can have one of the following values: +;; +;; `regular' +;; The current item is a normal file or files which do not fit +;; into one of the following categories. This means +;; especially special files, sockets etc. +;; +;; `directory' +;; The current item is a directory. +;; +;; `invalid-stat' +;; The `stat' call to fill the object pointed to by the second +;; parameter failed and so the information is invalid. +;; +;; `directory-not-readable' +;; The item is a directory which cannot be read. +;; +;; `symlink' +;; The item is a symbolic link. Since symbolic links are +;; normally followed seeing this value in a `ftw' callback +;; procedure means the referenced file does not exist. The +;; situation for `nftw' is different. +;; +;; - Data Type: __nftw_proc_t +;; (lambda (filename statinfo flag base level) ...) => status +;; +;; The first three arguments have the same as for the +;; `__ftw_proc_t' type. A difference is that for the third +;; argument some additional values are defined to allow finer +;; differentiation: +;; +;; `directory-processed' +;; The current item is a directory and all subdirectories have +;; already been visited and reported. This flag is returned +;; instead of `directory' if the `depth' flag is given to +;; `nftw' (see below). +;; +;; `stale-symlink' +;; The current item is a stale symbolic link. The file it +;; points to does not exist. +;; +;; The last two parameters are described below. They contain +;; information to help interpret FILENAME and give some information +;; about current state of the traversal of the directory hierarchy. +;; +;; `base' +;; The value specifies which part of the filename argument +;; given in the first parameter to the callback procedure is +;; the name of the file. The rest of the string is the path +;; to locate the file. This information is especially +;; important if the `chdir' flag for `nftw' was set since then +;; the current directory is the one the current item is found +;; in. +;; +;; `level' +;; While processing the directory the procedures tracks how +;; many directories have been examined to find the current +;; item. This nesting level is 0 for the item given starting +;; item (file or directory) and is incremented by one for each +;; entered directory. +;; +;; * Procedure: (ftw filename proc . options) +;; Do a filesystem tree walk starting at FILENAME using PROC. +;; +;; The `ftw' procedure calls the callback procedure given in the +;; parameter PROC for every item which is found in the directory +;; specified by FILENAME and all directories below. The procedure +;; follows symbolic links if necessary but does not process an item +;; twice. If FILENAME names no directory this item is the only +;; object reported by calling the callback procedure. +;; +;; The filename given to the callback procedure is constructed by +;; taking the FILENAME parameter and appending the names of all +;; passed directories and then the local file name. So the +;; callback procedure can use this parameter to access the file. +;; Before the callback procedure is called `ftw' calls `stat' for +;; this file and passes the information up to the callback +;; procedure. If this `stat' call was not successful the failure is +;; indicated by setting the flag argument of the callback procedure +;; to `invalid-stat'. Otherwise the flag is set according to the +;; description given in the description of `__ftw_proc_t' above. +;; +;; The callback procedure is expected to return non-#f to indicate +;; that no error occurred and the processing should be continued. +;; If an error occurred in the callback procedure or the call to +;; `ftw' shall return immediately the callback procedure can return +;; #f. This is the only correct way to stop the procedure. The +;; program must not use `throw' or similar techniques to continue +;; the program in another place. [Can we relax this? --ttn] +;; +;; The return value of the `ftw' procedure is #t if all callback +;; procedure calls returned #t and all actions performed by the +;; `ftw' succeeded. If some procedure call failed (other than +;; calling `stat' on an item) the procedure returns #f. If a +;; callback procedure returns a value other than #t this value is +;; returned as the return value of `ftw'. +;; +;; * Procedure: (nftw filename proc . control-flags) +;; Do a new-style filesystem tree walk starting at FILENAME using PROC. +;; Various optional CONTROL-FLAGS alter the default behavior. +;; +;; The `nftw' procedures works like the `ftw' procedures. It calls +;; the callback procedure PROC for all items it finds in the +;; directory FILENAME and below. +;; +;; The differences are that for one the callback procedure is of a +;; different type. It takes also `base' and `level' parameters as +;; described above. +;; +;; The second difference is that `nftw' takes additional optional +;; arguments which are zero or more of the following symbols: +;; +;; physical' +;; While traversing the directory symbolic links are not +;; followed. I.e., if this flag is given symbolic links are +;; reported using the `symlink' value for the type parameter +;; to the callback procedure. Please note that if this flag is +;; used the appearance of `symlink' in a callback procedure +;; does not mean the referenced file does not exist. To +;; indicate this the extra value `stale-symlink' exists. +;; +;; mount' +;; The callback procedure is only called for items which are on +;; the same mounted filesystem as the directory given as the +;; FILENAME parameter to `nftw'. +;; +;; chdir' +;; If this flag is given the current working directory is +;; changed to the directory containing the reported object +;; before the callback procedure is called. +;; +;; depth' +;; If this option is given the procedure visits first all files +;; and subdirectories before the callback procedure is called +;; for the directory itself (depth-first processing). This +;; also means the type flag given to the callback procedure is +;; `directory-processed' and not `directory'. +;; +;; The return value is computed in the same way as for `ftw'. +;; `nftw' returns #t if no failure occurred in `nftw' and all +;; callback procedure call return values are also #t. For internal +;; errors such as memory problems the error `ftw-error' is thrown. +;; If the return value of a callback invocation is not #t this +;; very same value is returned. + +;;; Code: + +(define-module (ice-9 ftw) + :export (ftw nftw)) + +(define (directory-files dir) + (let ((dir-stream (opendir dir))) + (let loop ((new (readdir dir-stream)) + (acc '())) + (if (eof-object? new) + (begin + (closedir dir-stream) + acc) + (loop (readdir dir-stream) + (if (or (string=? "." new) ;;; ignore + (string=? ".." new)) ;;; ignore + acc + (cons new acc))))))) + +(define (pathify . nodes) + (let loop ((nodes nodes) + (result "")) + (if (null? nodes) + (or (and (string=? "" result) "") + (substring result 1 (string-length result))) + (loop (cdr nodes) (string-append result "/" (car nodes)))))) + +(define (abs? filename) + (char=? #\/ (string-ref filename 0))) + +;; `visited?-proc' returns a test procedure VISITED? which when called as +;; (VISITED? stat-obj) returns #f the first time a distinct file is seen, +;; then #t on any subsequent sighting of it. +;; +;; stat:dev and stat:ino together uniquely identify a file (see "Attribute +;; Meanings" in the glibc manual). Often there'll be just one dev, and +;; usually there's just a handful mounted, so the strategy here is a small +;; hash table indexed by dev, containing hash tables indexed by ino. +;; +;; It'd be possible to make a pair (dev . ino) and use that as the key to a +;; single hash table. It'd use an extra pair for every file visited, but +;; might be a little faster if it meant less scheme code. +;; +(define (visited?-proc size) + (let ((dev-hash (make-hash-table 7))) + (lambda (s) + (and s + (let ((ino-hash (hashv-ref dev-hash (stat:dev s))) + (ino (stat:ino s))) + (or ino-hash + (begin + (set! ino-hash (make-hash-table size)) + (hashv-set! dev-hash (stat:dev s) ino-hash))) + (or (hashv-ref ino-hash ino) + (begin + (hashv-set! ino-hash ino #t) + #f))))))) + +(define (stat-dir-readable?-proc uid gid) + (let ((uid (getuid)) + (gid (getgid))) + (lambda (s) + (let* ((perms (stat:perms s)) + (perms-bit-set? (lambda (mask) + (not (= 0 (logand mask perms)))))) + (or (and (= uid (stat:uid s)) + (perms-bit-set? #o400)) + (and (= gid (stat:gid s)) + (perms-bit-set? #o040)) + (perms-bit-set? #o004)))))) + +(define (stat&flag-proc dir-readable? . control-flags) + (let* ((directory-flag (if (memq 'depth control-flags) + 'directory-processed + 'directory)) + (stale-symlink-flag (if (memq 'nftw-style control-flags) + 'stale-symlink + 'symlink)) + (physical? (memq 'physical control-flags)) + (easy-flag (lambda (s) + (let ((type (stat:type s))) + (if (eq? 'directory type) + (if (dir-readable? s) + directory-flag + 'directory-not-readable) + 'regular))))) + (lambda (name) + (let ((s (false-if-exception (lstat name)))) + (cond ((not s) + (values s 'invalid-stat)) + ((eq? 'symlink (stat:type s)) + (let ((s-follow (false-if-exception (stat name)))) + (cond ((not s-follow) + (values s stale-symlink-flag)) + ((and s-follow physical?) + (values s 'symlink)) + ((and s-follow (not physical?)) + (values s-follow (easy-flag s-follow)))))) + (else (values s (easy-flag s)))))))) + +(define (clean name) + (let ((last-char-index (1- (string-length name)))) + (if (char=? #\/ (string-ref name last-char-index)) + (substring name 0 last-char-index) + name))) + +(define (ftw filename proc . options) + (let* ((visited? (visited?-proc (cond ((memq 'hash-size options) => cadr) + (else 211)))) + (stat&flag (stat&flag-proc + (stat-dir-readable?-proc (getuid) (getgid))))) + (letrec ((go (lambda (fullname) + (call-with-values (lambda () (stat&flag fullname)) + (lambda (s flag) + (or (visited? s) + (let ((ret (proc fullname s flag))) ; callback + (or (eq? #t ret) + (throw 'ftw-early-exit ret)) + (and (eq? 'directory flag) + (for-each + (lambda (child) + (go (pathify fullname child))) + (directory-files fullname))) + #t))))))) + (catch 'ftw-early-exit + (lambda () (go (clean filename))) + (lambda (key val) val))))) + +(define (nftw filename proc . control-flags) + (let* ((od (getcwd)) ; orig dir + (odev (let ((s (false-if-exception (lstat filename)))) + (if s (stat:dev s) -1))) + (same-dev? (if (memq 'mount control-flags) + (lambda (s) (= (stat:dev s) odev)) + (lambda (s) #t))) + (base-sub (lambda (name base) (substring name 0 base))) + (maybe-cd (if (memq 'chdir control-flags) + (if (abs? filename) + (lambda (fullname base) + (or (= 0 base) + (chdir (base-sub fullname base)))) + (lambda (fullname base) + (chdir + (pathify od (base-sub fullname base))))) + (lambda (fullname base) #t))) + (maybe-cd-back (if (memq 'chdir control-flags) + (lambda () (chdir od)) + (lambda () #t))) + (depth-first? (memq 'depth control-flags)) + (visited? (visited?-proc + (cond ((memq 'hash-size control-flags) => cadr) + (else 211)))) + (has-kids? (if depth-first? + (lambda (flag) (eq? flag 'directory-processed)) + (lambda (flag) (eq? flag 'directory)))) + (stat&flag (apply stat&flag-proc + (stat-dir-readable?-proc (getuid) (getgid)) + (cons 'nftw-style control-flags)))) + (letrec ((go (lambda (fullname base level) + (call-with-values (lambda () (stat&flag fullname)) + (lambda (s flag) + (letrec ((self (lambda () + (maybe-cd fullname base) + ;; the callback + (let ((ret (proc fullname s flag + base level))) + (maybe-cd-back) + (or (eq? #t ret) + (throw 'nftw-early-exit ret))))) + (kids (lambda () + (and (has-kids? flag) + (for-each + (lambda (child) + (go (pathify fullname child) + (1+ (string-length + fullname)) + (1+ level))) + (directory-files fullname)))))) + (or (visited? s) + (not (same-dev? s)) + (if depth-first? + (begin (kids) (self)) + (begin (self) (kids))))))) + #t))) + (let ((ret (catch 'nftw-early-exit + (lambda () (go (clean filename) 0 0)) + (lambda (key val) val)))) + (chdir od) + ret)))) + +;;; ftw.scm ends here diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/gap-buffer.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/gap-buffer.scm new file mode 100755 index 0000000000000000000000000000000000000000..b6162e802f4cf6279aa4a8150940c4a509aa2b8c --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/gap-buffer.scm @@ -0,0 +1,283 @@ +;;; gap-buffer.scm --- String buffer that supports point + +;;; Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc. +;;; +;; This library is free software; you can redistribute it and/or +;; modify it under the terms of the GNU Lesser General Public +;; License as published by the Free Software Foundation; either +;; version 2.1 of the License, or (at your option) any later version. +;; +;; This library is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; Lesser General Public License for more details. +;; +;; You should have received a copy of the GNU Lesser General Public +;; License along with this library; if not, write to the Free Software +;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;; + +;;; Author: Thien-Thi Nguyen + +;;; Commentary: + +;; A gap buffer is a structure that models a string but allows relatively +;; efficient insertion of text somewhere in the middle. The insertion +;; location is called `point' with minimum value 1, and a maximum value of the +;; length of the string (which is not fixed). +;; +;; Specifically, we allocate a continuous buffer of characters that is +;; composed of the BEFORE, the GAP and the AFTER (reading L->R), like so: +;; +;; +--- POINT +;; v +;; +--------------------+--------------------+--------------------+ +;; | BEFORE | GAP | AFTER | +;; +--------------------+--------------------+--------------------+ +;; +;; <----- bef-sz ----->|<----- gap-sz ----->|<----- aft-sz -----> +;; +;; <-------------------| usr-sz |-------------------> +;; +;; <-------------------------- all-sz --------------------------> +;; +;; This diagram also shows how the different sizes are computed, and the +;; location of POINT. Note that the user-visible buffer size `usr-sz' does +;; NOT include the GAP, while the allocation `all-sz' DOES. +;; +;; The consequence of this arrangement is that "moving point" is simply a +;; matter of kicking characters across the GAP, while insertion can be viewed +;; as filling up the gap, increasing `bef-sz' and decreasing `gap-sz'. When +;; `gap-sz' falls below some threshold, we reallocate with a larger `all-sz'. +;; +;; In the implementation, we actually keep track of the AFTER start offset +;; `aft-ofs' since it is used more often than `gap-sz'. In fact, most of the +;; variables in the diagram are for conceptualization only. +;; +;; A gap buffer port is a soft port (see Guile manual) that wraps a gap +;; buffer. Character and string writes, as well as character reads, are +;; supported. Flushing and closing are not supported. +;; +;; These procedures are exported: +;; (gb? OBJ) +;; (make-gap-buffer . INIT) +;; (gb-point GB) +;; (gb-point-min GB) +;; (gb-point-max GB) +;; (gb-insert-string! GB STRING) +;; (gb-insert-char! GB CHAR) +;; (gb-delete-char! GB COUNT) +;; (gb-goto-char GB LOCATION) +;; (gb->string GB) +;; (gb-filter! GB STRING-PROC) +;; (gb->lines GB) +;; (gb-filter-lines! GB LINES-PROC) +;; (make-gap-buffer-port GB) +;; +;; INIT is an optional port or a string. COUNT and LOCATION are integers. +;; STRING-PROC is a procedure that takes and returns a string. LINES-PROC is +;; a procedure that takes and returns a list of strings, each representing a +;; line of text (newlines are stripped and added back automatically). +;; +;; (The term and concept of "gap buffer" are borrowed from Emacs. We will +;; gladly return them when libemacs.so is available. ;-) +;; +;; Notes: +;; - overrun errors are suppressed silently + +;;; Code: + +(define-module (ice-9 gap-buffer) + :autoload (srfi srfi-13) (string-join) + :export (gb? + make-gap-buffer + gb-point + gb-point-min + gb-point-max + gb-insert-string! + gb-insert-char! + gb-delete-char! + gb-erase! + gb-goto-char + gb->string + gb-filter! + gb->lines + gb-filter-lines! + make-gap-buffer-port)) + +(define gap-buffer + (make-record-type 'gap-buffer + '(s ; the buffer, a string + all-sz ; total allocation + gap-ofs ; GAP starts, aka (1- point) + aft-ofs ; AFTER starts + ))) + +(define gb? (record-predicate gap-buffer)) + +(define s: (record-accessor gap-buffer 's)) +(define all-sz: (record-accessor gap-buffer 'all-sz)) +(define gap-ofs: (record-accessor gap-buffer 'gap-ofs)) +(define aft-ofs: (record-accessor gap-buffer 'aft-ofs)) + +(define s! (record-modifier gap-buffer 's)) +(define all-sz! (record-modifier gap-buffer 'all-sz)) +(define gap-ofs! (record-modifier gap-buffer 'gap-ofs)) +(define aft-ofs! (record-modifier gap-buffer 'aft-ofs)) + +;; todo: expose +(define default-initial-allocation 128) +(define default-chunk-size 128) +(define default-realloc-threshold 32) + +(define (round-up n) + (* default-chunk-size (+ 1 (quotient n default-chunk-size)))) + +(define new (record-constructor gap-buffer '())) + +(define (realloc gb inc) + (let* ((old-s (s: gb)) + (all-sz (all-sz: gb)) + (new-sz (+ all-sz inc)) + (gap-ofs (gap-ofs: gb)) + (aft-ofs (aft-ofs: gb)) + (new-s (make-string new-sz)) + (new-aft-ofs (+ aft-ofs inc))) + (substring-move! old-s 0 gap-ofs new-s 0) + (substring-move! old-s aft-ofs all-sz new-s new-aft-ofs) + (s! gb new-s) + (all-sz! gb new-sz) + (aft-ofs! gb new-aft-ofs))) + +(define (make-gap-buffer . init) ; port/string + (let ((gb (new))) + (cond ((null? init) + (s! gb (make-string default-initial-allocation)) + (all-sz! gb default-initial-allocation) + (gap-ofs! gb 0) + (aft-ofs! gb default-initial-allocation)) + (else (let ((jam! (lambda (string len) + (let ((alloc (round-up len))) + (s! gb (make-string alloc)) + (all-sz! gb alloc) + (substring-move! string 0 len (s: gb) 0) + (gap-ofs! gb len) + (aft-ofs! gb alloc)))) + (v (car init))) + (cond ((port? v) + (let ((next (lambda () (read-char v)))) + (let loop ((c (next)) (acc '()) (len 0)) + (if (eof-object? c) + (jam! (list->string (reverse acc)) len) + (loop (next) (cons c acc) (1+ len)))))) + ((string? v) + (jam! v (string-length v))) + (else (error "bad init type")))))) + gb)) + +(define (gb-point gb) + (1+ (gap-ofs: gb))) + +(define (gb-point-min gb) 1) ; no narrowing (for now) + +(define (gb-point-max gb) + (1+ (- (all-sz: gb) (- (aft-ofs: gb) (gap-ofs: gb))))) + +(define (insert-prep gb len) + (let* ((gap-ofs (gap-ofs: gb)) + (aft-ofs (aft-ofs: gb)) + (slack (- (- aft-ofs gap-ofs) len))) + (and (< slack default-realloc-threshold) + (realloc gb (round-up (- slack)))) + gap-ofs)) + +(define (gb-insert-string! gb string) + (let* ((len (string-length string)) + (gap-ofs (insert-prep gb len))) + (substring-move! string 0 len (s: gb) gap-ofs) + (gap-ofs! gb (+ gap-ofs len)))) + +(define (gb-insert-char! gb char) + (let ((gap-ofs (insert-prep gb 1))) + (string-set! (s: gb) gap-ofs char) + (gap-ofs! gb (+ gap-ofs 1)))) + +(define (gb-delete-char! gb count) + (cond ((< count 0) ; backwards + (gap-ofs! gb (max 0 (+ (gap-ofs: gb) count)))) + ((> count 0) ; forwards + (aft-ofs! gb (min (all-sz: gb) (+ (aft-ofs: gb) count)))) + ((= count 0) ; do nothing + #t))) + +(define (gb-erase! gb) + (gap-ofs! gb 0) + (aft-ofs! gb (all-sz: gb))) + +(define (point++n! gb n s gap-ofs aft-ofs) ; n>0; warning: reckless + (substring-move! s aft-ofs (+ aft-ofs n) s gap-ofs) + (gap-ofs! gb (+ gap-ofs n)) + (aft-ofs! gb (+ aft-ofs n))) + +(define (point+-n! gb n s gap-ofs aft-ofs) ; n<0; warning: reckless + (substring-move! s (+ gap-ofs n) gap-ofs s (+ aft-ofs n)) + (gap-ofs! gb (+ gap-ofs n)) + (aft-ofs! gb (+ aft-ofs n))) + +(define (gb-goto-char gb new-point) + (let ((pmax (gb-point-max gb))) + (or (and (< new-point 1) (gb-goto-char gb 1)) + (and (> new-point pmax) (gb-goto-char gb pmax)) + (let ((delta (- new-point (gb-point gb)))) + (or (= delta 0) + ((if (< delta 0) + point+-n! + point++n!) + gb delta (s: gb) (gap-ofs: gb) (aft-ofs: gb)))))) + new-point) + +(define (gb->string gb) + (let ((s (s: gb))) + (string-append (substring s 0 (gap-ofs: gb)) + (substring s (aft-ofs: gb))))) + +(define (gb-filter! gb string-proc) + (let ((new (string-proc (gb->string gb)))) + (gb-erase! gb) + (gb-insert-string! gb new))) + +(define (gb->lines gb) + (let ((str (gb->string gb))) + (let loop ((start 0) (acc '())) + (cond ((string-index str #\newline start) + => (lambda (w) + (loop (1+ w) (cons (substring str start w) acc)))) + (else (reverse (cons (substring str start) acc))))))) + +(define (gb-filter-lines! gb lines-proc) + (let ((new-lines (lines-proc (gb->lines gb)))) + (gb-erase! gb) + (gb-insert-string! gb (string-join new-lines #\newline)))) + +(define (make-gap-buffer-port gb) + (or (gb? gb) + (error "not a gap-buffer:" gb)) + (make-soft-port + (vector + (lambda (c) (gb-insert-char! gb c)) + (lambda (s) (gb-insert-string! gb s)) + #f + (lambda () (let ((gap-ofs (gap-ofs: gb)) + (aft-ofs (aft-ofs: gb))) + (if (= aft-ofs (all-sz: gb)) + #f + (let* ((s (s: gb)) + (c (string-ref s aft-ofs))) + (string-set! s gap-ofs c) + (gap-ofs! gb (1+ gap-ofs)) + (aft-ofs! gb (1+ aft-ofs)) + c)))) + #f) + "rw")) + +;;; gap-buffer.scm ends here diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/gds-client.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/gds-client.scm new file mode 100755 index 0000000000000000000000000000000000000000..960015abd7792f4c1b3b83d900763d9e75028724 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/gds-client.scm @@ -0,0 +1,592 @@ +(define-module (ice-9 gds-client) + #:use-module (oop goops) + #:use-module (oop goops describe) + #:use-module (ice-9 debugging trace) + #:use-module (ice-9 debugging traps) + #:use-module (ice-9 debugging trc) + #:use-module (ice-9 debugging steps) + #:use-module (ice-9 pretty-print) + #:use-module (ice-9 regex) + #:use-module (ice-9 session) + #:use-module (ice-9 string-fun) + #:export (gds-debug-trap + run-utility + gds-accept-input)) + +(cond ((string>=? (version) "1.7") + (use-modules (ice-9 debugger utils))) + (else + (define the-ice-9-debugger-module (resolve-module '(ice-9 debugger))) + (module-export! the-ice-9-debugger-module + '(source-position + write-frame-short/application + write-frame-short/expression + write-frame-args-long + write-frame-long)))) + +(use-modules (ice-9 debugger)) + +(define gds-port #f) + +;; Return an integer that somehow identifies the current thread. +(define (get-thread-id) + (let ((root (dynamic-root))) + (cond ((integer? root) + root) + ((pair? root) + (object-address root)) + (else + (error "Unexpected dynamic root:" root))))) + +;; gds-debug-read is a high-priority read. The (debug-thread-id ID) +;; form causes the frontend to dismiss any reads from threads whose id +;; is not ID, until it receives the (thread-id ...) form with the same +;; id as ID. Dismissing the reads of any other threads (by sending a +;; form that is otherwise ignored) causes those threads to release the +;; read mutex, which allows the (gds-read) here to proceed. +(define (gds-debug-read) + (write-form `(debug-thread-id ,(get-thread-id))) + (gds-read)) + +(define (gds-debug-trap trap-context) + "Invoke the GDS debugger to explore the stack at the specified trap." + (connect-to-gds) + (start-stack 'debugger + (let* ((stack (tc:stack trap-context)) + (flags1 (let ((trap-type (tc:type trap-context))) + (case trap-type + ((#:return #:error) + (list trap-type + (tc:return-value trap-context))) + (else + (list trap-type))))) + (flags (if (tc:continuation trap-context) + (cons #:continuable flags1) + flags1)) + (fired-traps (tc:fired-traps trap-context)) + (special-index (and (= (length fired-traps) 1) + (is-a? (car fired-traps) ) + (eq? (tc:type trap-context) #:return) + (- (tc:depth trap-context) + (slot-ref (car fired-traps) 'depth))))) + ;; Write current stack to the frontend. + (write-form (list 'stack + (if (and special-index (> special-index 0)) + special-index + 0) + (stack->emacs-readable stack) + (append (flags->emacs-readable flags) + (slot-ref trap-context + 'handler-return-syms)))) + ;; Now wait for instruction. + (let loop ((protocol (gds-debug-read))) + ;; Act on it. + (case (car protocol) + ((tweak) + ;; Request to tweak the handler return value. + (let ((tweaking (catch #t + (lambda () + (list (with-input-from-string + (cadr protocol) + read))) + (lambda ignored #f)))) + (if tweaking + (slot-set! trap-context + 'handler-return-value + (cons 'instead (car tweaking))))) + (loop (gds-debug-read))) + ((continue) + ;; Continue (by exiting the debugger). + *unspecified*) + ((evaluate) + ;; Evaluate expression in specified frame. + (eval-in-frame stack (cadr protocol) (caddr protocol)) + (loop (gds-debug-read))) + ((info-frame) + ;; Return frame info. + (let ((frame (stack-ref stack (cadr protocol)))) + (write-form (list 'info-result + (with-output-to-string + (lambda () + (write-frame-long frame)))))) + (loop (gds-debug-read))) + ((info-args) + ;; Return frame args. + (let ((frame (stack-ref stack (cadr protocol)))) + (write-form (list 'info-result + (with-output-to-string + (lambda () + (write-frame-args-long frame)))))) + (loop (gds-debug-read))) + ((proc-source) + ;; Show source of application procedure. + (let* ((frame (stack-ref stack (cadr protocol))) + (proc (frame-procedure frame)) + (source (and proc (procedure-source proc)))) + (write-form (list 'info-result + (if source + (sans-surrounding-whitespace + (with-output-to-string + (lambda () + (pretty-print source)))) + (if proc + "This procedure is coded in C" + "This frame has no procedure"))))) + (loop (gds-debug-read))) + ((traps-here) + ;; Show the traps that fired here. + (write-form (list 'info-result + (with-output-to-string + (lambda () + (for-each describe + (tc:fired-traps trap-context)))))) + (loop (gds-debug-read))) + ((step-into) + ;; Set temporary breakpoint on next trap. + (at-step gds-debug-trap + 1 + #f + (if (memq #:return flags) + #f + (- (stack-length stack) + (cadr protocol))))) + ((step-over) + ;; Set temporary breakpoint on exit from + ;; specified frame. + (at-exit (- (stack-length stack) (cadr protocol)) + gds-debug-trap)) + ((step-file) + ;; Set temporary breakpoint on next trap in same + ;; source file. + (at-step gds-debug-trap + 1 + (frame-file-name (stack-ref stack + (cadr protocol))) + (if (memq #:return flags) + #f + (- (stack-length stack) + (cadr protocol))))) + (else + (safely-handle-nondebug-protocol protocol) + (loop (gds-debug-read)))))))) + +(define (connect-to-gds . application-name) + (or gds-port + (begin + (set! gds-port + (or (let ((s (socket PF_INET SOCK_STREAM 0)) + (SOL_TCP 6) + (TCP_NODELAY 1)) + (setsockopt s SOL_TCP TCP_NODELAY 1) + (catch #t + (lambda () + (connect s AF_INET (inet-aton "127.0.0.1") 8333) + s) + (lambda _ #f))) + (let ((s (socket PF_UNIX SOCK_STREAM 0))) + (catch #t + (lambda () + (connect s AF_UNIX "/tmp/.gds_socket") + s) + (lambda _ #f))) + (error "Couldn't connect to GDS by TCP or Unix domain socket"))) + (write-form (list 'name (getpid) (apply client-name application-name)))))) + +(define (client-name . application-name) + (let loop ((args (append application-name (program-arguments)))) + (if (null? args) + (format #f "PID ~A" (getpid)) + (let ((arg (car args))) + (cond ((string-match "^(.*[/\\])?guile(\\..*)?$" arg) + (loop (cdr args))) + ((string-match "^-" arg) + (loop (cdr args))) + (else + (format #f "~A (PID ~A)" arg (getpid)))))))) + +(if (not (defined? 'make-mutex)) + (begin + (define (make-mutex) #f) + (define lock-mutex noop) + (define unlock-mutex noop))) + +(define write-mutex (make-mutex)) + +(define (write-form form) + ;; Write any form FORM to GDS. + (lock-mutex write-mutex) + (write form gds-port) + (newline gds-port) + (force-output gds-port) + (unlock-mutex write-mutex)) + +(define (stack->emacs-readable stack) + ;; Return Emacs-readable representation of STACK. + (map (lambda (index) + (frame->emacs-readable (stack-ref stack index))) + (iota (min (stack-length stack) + (cadr (memq 'depth (debug-options))))))) + +(define (frame->emacs-readable frame) + ;; Return Emacs-readable representation of FRAME. + (if (frame-procedure? frame) + (list 'application + (with-output-to-string + (lambda () + (display (if (frame-real? frame) " " "t ")) + (write-frame-short/application frame))) + (source->emacs-readable frame)) + (list 'evaluation + (with-output-to-string + (lambda () + (display (if (frame-real? frame) " " "t ")) + (write-frame-short/expression frame))) + (source->emacs-readable frame)))) + +(define (source->emacs-readable frame) + ;; Return Emacs-readable representation of the filename, line and + ;; column source properties of SOURCE. + (or (frame->source-position frame) 'nil)) + +(define (flags->emacs-readable flags) + ;; Return Emacs-readable representation of trap FLAGS. + (let ((prev #f)) + (map (lambda (flag) + (let ((erf (if (and (keyword? flag) + (not (eq? prev #:return))) + (keyword->symbol flag) + (format #f "~S" flag)))) + (set! prev flag) + erf)) + flags))) + +(define (eval-in-frame stack index expr) + (write-form + (list 'eval-result + (format #f "~S" + (catch #t + (lambda () + (local-eval (with-input-from-string expr read) + (memoized-environment + (frame-source (stack-ref stack + index))))) + (lambda args + (cons 'ERROR args))))))) + +(set! (behaviour-ordering gds-debug-trap) 100) + +;;; Code below here adds support for interaction between the GDS +;;; client program and the Emacs frontend even when not stopped in the +;;; debugger. + +;; A mutex to control attempts by multiple threads to read protocol +;; back from the frontend. +(define gds-read-mutex (make-mutex)) + +;; Read a protocol instruction from the frontend. +(define (gds-read) + ;; Acquire the read mutex. + (lock-mutex gds-read-mutex) + ;; Tell the front end something that identifies us as a thread. + (write-form `(thread-id ,(get-thread-id))) + ;; Now read, then release the mutex and return what was read. + (let ((x (catch #t + (lambda () (read gds-port)) + (lambda ignored the-eof-object)))) + (unlock-mutex gds-read-mutex) + x)) + +(define (gds-accept-input exit-on-continue) + ;; If reading from the GDS connection returns EOF, we will throw to + ;; this catch. + (catch 'server-eof + (lambda () + (let loop ((protocol (gds-read))) + (if (or (eof-object? protocol) + (and exit-on-continue + (eq? (car protocol) 'continue))) + (throw 'server-eof)) + (safely-handle-nondebug-protocol protocol) + (loop (gds-read)))) + (lambda ignored #f))) + +(define (safely-handle-nondebug-protocol protocol) + ;; This catch covers any internal errors in the GDS code or + ;; protocol. + (catch #t + (lambda () + (lazy-catch #t + (lambda () + (handle-nondebug-protocol protocol)) + save-lazy-trap-context-and-rethrow)) + (lambda (key . args) + (write-form + `(eval-results (error . ,(format #f "~s" protocol)) + ,(if last-lazy-trap-context 't 'nil) + "GDS Internal Error +Please report this to , ideally including: +- a description of the scenario in which this error occurred +- which versions of Guile and guile-debugging you are using +- the error stack, which you can get by clicking on the link below, + and then cut and paste into your report. +Thanks!\n\n" + ,(list (with-output-to-string + (lambda () + (write key) + (display ": ") + (write args) + (newline))))))))) + +;; The key that is used to signal a read error changes from 1.6 to +;; 1.8; here we cover all eventualities by discovering the key +;; dynamically. +(define read-error-key + (catch #t + (lambda () + (with-input-from-string "(+ 3 4" read)) + (lambda (key . args) + key))) + +(define (handle-nondebug-protocol protocol) + (case (car protocol) + + ((eval) + (set! last-lazy-trap-context #f) + (apply (lambda (correlator module port-name line column code flags) + (with-input-from-string code + (lambda () + (set-port-filename! (current-input-port) port-name) + (set-port-line! (current-input-port) line) + (set-port-column! (current-input-port) column) + (let ((m (and module (resolve-module-from-root module)))) + (catch read-error-key + (lambda () + (let loop ((exprs '()) (x (read))) + (if (eof-object? x) + ;; Expressions to be evaluated have all + ;; been read. Now evaluate them. + (let loop2 ((exprs (reverse! exprs)) + (results '()) + (n 1)) + (if (null? exprs) + (write-form `(eval-results ,correlator + ,(if last-lazy-trap-context 't 'nil) + ,@results)) + (loop2 (cdr exprs) + (append results (gds-eval (car exprs) m + (if (and (null? (cdr exprs)) + (= n 1)) + #f n))) + (+ n 1)))) + ;; Another complete expression read; add + ;; it to the list. + (begin + (if (and (pair? x) + (memq 'debug flags)) + (install-trap (make + #:expression x + #:behaviour gds-debug-trap))) + (loop (cons x exprs) (read)))))) + (lambda (key . args) + (write-form `(eval-results + ,correlator + ,(if last-lazy-trap-context 't 'nil) + ,(with-output-to-string + (lambda () + (display ";;; Reading expressions") + (display " to evaluate\n") + (apply display-error #f + (current-output-port) args))) + ("error-in-read"))))))))) + (cdr protocol))) + + ((complete) + (let ((matches (apropos-internal + (string-append "^" (regexp-quote (cadr protocol)))))) + (cond ((null? matches) + (write-form '(completion-result nil))) + (else + ;;(write matches (current-error-port)) + ;;(newline (current-error-port)) + (let ((match + (let loop ((match (symbol->string (car matches))) + (matches (cdr matches))) + ;;(write match (current-error-port)) + ;;(newline (current-error-port)) + ;;(write matches (current-error-port)) + ;;(newline (current-error-port)) + (if (null? matches) + match + (if (string-prefix=? match + (symbol->string (car matches))) + (loop match (cdr matches)) + (loop (substring match 0 + (- (string-length match) 1)) + matches)))))) + (if (string=? match (cadr protocol)) + (write-form `(completion-result + ,(map symbol->string matches))) + (write-form `(completion-result + ,match)))))))) + + ((debug-lazy-trap-context) + (if last-lazy-trap-context + (gds-debug-trap last-lazy-trap-context) + (error "There is no stack available to show"))) + + (else + (error "Unexpected protocol:" protocol)))) + +(define (resolve-module-from-root name) + (save-module-excursion + (lambda () + (set-current-module the-root-module) + (resolve-module name)))) + +(define (gds-eval x m part) + ;; Consumer to accept possibly multiple values and present them for + ;; Emacs as a list of strings. + (define (value-consumer . values) + (if (unspecified? (car values)) + '() + (map (lambda (value) + (with-output-to-string (lambda () (write value)))) + values))) + ;; Now do evaluation. + (let ((intro (if part + (format #f ";;; Evaluating expression ~A" part) + ";;; Evaluating")) + (value #f)) + (let* ((do-eval (if m + (lambda () + (display intro) + (display " in module ") + (write (module-name m)) + (newline) + (set! value + (call-with-values (lambda () + (start-stack 'gds-eval-stack + (eval x m))) + value-consumer))) + (lambda () + (display intro) + (display " in current module ") + (write (module-name (current-module))) + (newline) + (set! value + (call-with-values (lambda () + (start-stack 'gds-eval-stack + (primitive-eval x))) + value-consumer))))) + (output + (with-output-to-string + (lambda () + (catch #t + (lambda () + (lazy-catch #t + do-eval + save-lazy-trap-context-and-rethrow)) + (lambda (key . args) + (case key + ((misc-error signal unbound-variable numerical-overflow) + (apply display-error #f + (current-output-port) args) + (set! value '("error-in-evaluation"))) + (else + (display "EXCEPTION: ") + (display key) + (display " ") + (write args) + (newline) + (set! value + '("unhandled-exception-in-evaluation")))))))))) + (list output value)))) + +(define last-lazy-trap-context #f) + +(define (save-lazy-trap-context-and-rethrow key . args) + (set! last-lazy-trap-context + (throw->trap-context key args save-lazy-trap-context-and-rethrow)) + (apply throw key args)) + +(define (run-utility) + (connect-to-gds) + (write (getpid)) + (newline) + (force-output) + (named-module-use! '(guile-user) '(ice-9 session)) + (gds-accept-input #f)) + +(define-method (trap-description (trap )) + (let loop ((description (list (class-name (class-of trap)))) + (next 'installed?)) + (case next + ((installed?) + (loop (if (slot-ref trap 'installed) + (cons 'installed description) + description) + 'conditional?)) + ((conditional?) + (loop (if (slot-ref trap 'condition) + (cons 'conditional description) + description) + 'skip-count)) + ((skip-count) + (loop (let ((skip-count (slot-ref trap 'skip-count))) + (if (zero? skip-count) + description + (cons* skip-count 'skip-count description))) + 'single-shot?)) + ((single-shot?) + (loop (if (slot-ref trap 'single-shot) + (cons 'single-shot description) + description) + 'done)) + (else + (reverse! description))))) + +(define-method (trap-description (trap )) + (let ((description (next-method))) + (set-cdr! description + (cons (procedure-name (slot-ref trap 'procedure)) + (cdr description))) + description)) + +(define-method (trap-description (trap )) + (let ((description (next-method))) + (set-cdr! description + (cons (format #f "~s" (slot-ref trap 'expression)) + (cdr description))) + description)) + +(define-method (trap-description (trap )) + (let ((description (next-method))) + (set-cdr! description + (cons* (slot-ref trap 'file-regexp) + (slot-ref trap 'line) + (slot-ref trap 'column) + (cdr description))) + description)) + +(define (gds-trace-trap trap-context) + (connect-to-gds) + (gds-do-trace trap-context) + (at-exit (tc:depth trap-context) gds-do-trace)) + +(define (gds-do-trace trap-context) + (write-form (list 'trace + (format #f + "~3@a: ~a" + (trace/stack-real-depth trap-context) + (trace/info trap-context))))) + +(define (gds-trace-subtree trap-context) + (connect-to-gds) + (gds-do-trace trap-context) + (let ((step-trap (make #:behaviour gds-do-trace))) + (install-trap step-trap) + (at-exit (tc:depth trap-context) + (lambda (trap-context) + (uninstall-trap step-trap))))) + +;;; (ice-9 gds-client) ends here. diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/gds-server.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/gds-server.scm new file mode 100755 index 0000000000000000000000000000000000000000..f597587294dec3162ac8b73756dd9087012e4781 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/gds-server.scm @@ -0,0 +1,193 @@ +;;;; Guile Debugger UI server + +;;; Copyright (C) 2003 Free Software Foundation, Inc. +;;; +;; This library is free software; you can redistribute it and/or +;; modify it under the terms of the GNU Lesser General Public +;; License as published by the Free Software Foundation; either +;; version 2.1 of the License, or (at your option) any later version. +;; +;; This library is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; Lesser General Public License for more details. +;; +;; You should have received a copy of the GNU Lesser General Public +;; License along with this library; if not, write to the Free Software +;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +(define-module (ice-9 gds-server) + #:export (run-server)) + +;; UI is normally via a pipe to Emacs, so make sure to flush output +;; every time we write. +(define (write-to-ui form) + (write form) + (newline) + (force-output)) + +(define (trc . args) + (write-to-ui (cons '* args))) + +(define (with-error->eof proc port) + (catch #t + (lambda () (proc port)) + (lambda args the-eof-object))) + +(define connection->id (make-object-property)) + +(define (run-server port-or-path) + + (or (integer? port-or-path) + (string? port-or-path) + (error "port-or-path should be an integer (port number) or a string (file name)" + port-or-path)) + + (let ((server (socket (if (integer? port-or-path) PF_INET PF_UNIX) + SOCK_STREAM + 0))) + + ;; Initialize server socket. + (if (integer? port-or-path) + (begin + (setsockopt server SOL_SOCKET SO_REUSEADDR 1) + (bind server AF_INET INADDR_ANY port-or-path)) + (begin + (catch #t + (lambda () (delete-file port-or-path)) + (lambda _ #f)) + (bind server AF_UNIX port-or-path))) + + ;; Start listening. + (listen server 5) + + (let loop ((clients '()) (readable-sockets '())) + + (define (do-read port) + (cond ((eq? port (current-input-port)) + (do-read-from-ui)) + ((eq? port server) + (accept-new-client)) + (else + (do-read-from-client port)))) + + (define (do-read-from-ui) + (trc "reading from ui") + (let* ((form (with-error->eof read (current-input-port))) + (client (assq-ref (map (lambda (port) + (cons (connection->id port) port)) + clients) + (car form)))) + (with-error->eof read-char (current-input-port)) + (if client + (begin + (write (cdr form) client) + (newline client)) + (trc "client not found"))) + clients) + + (define (accept-new-client) + (let ((new-port (car (accept server)))) + ;; Read the client's ID. + (let ((name-form (read new-port))) + ;; Absorb the following newline character. + (read-char new-port) + ;; Check that we have a name form. + (or (eq? (car name-form) 'name) + (error "Invalid name form:" name-form)) + ;; Store an association from the connection to the ID. + (set! (connection->id new-port) (cadr name-form)) + ;; Pass the name form on to Emacs. + (write-to-ui (cons (connection->id new-port) name-form))) + ;; Add the new connection to the set that we select on. + (cons new-port clients))) + + (define (do-read-from-client port) + (trc "reading from client") + (let ((next-char (with-error->eof peek-char port))) + ;;(trc 'next-char next-char) + (cond ((eof-object? next-char) + (write-to-ui (list (connection->id port) 'closed)) + (close port) + (delq port clients)) + ((char=? next-char #\() + (write-to-ui (cons (connection->id port) + (with-error->eof read port))) + clients) + (else + (with-error->eof read-char port) + clients)))) + + ;;(trc 'clients clients) + ;;(trc 'readable-sockets readable-sockets) + + (if (null? readable-sockets) + (loop clients (car (select (cons (current-input-port) + (cons server clients)) + '() + '()))) + (loop (do-read (car readable-sockets)) (cdr readable-sockets)))))) + +;; What happens if there are multiple copies of Emacs running on the +;; same machine, and they all try to start up the GDS server? They +;; can't all listen on the same TCP port, so the short answer is that +;; all of them except the first will get an EADDRINUSE error when +;; trying to bind. +;; +;; We want to be able to handle this scenario, though, so that Scheme +;; code can be evaluated, and help invoked, in any of those Emacsen. +;; So we introduce the idea of a "slave server". When a new GDS +;; server gets an EADDRINUSE bind error, the implication is that there +;; is already a GDS server running, so the new server instead connects +;; to the existing one (by issuing a connect to the GDS port number). +;; +;; Let's call the first server the "master", and the new one the +;; "slave". In principle the master can now proxy any GDS client +;; connections through to the slave, so long as there is sufficient +;; information in the protocol for it to decide when and how to do +;; this. +;; +;; The basic information and mechanism that we need for this is as +;; follows. +;; +;; - A unique ID for each Emacs; this can be each Emacs's PID. When a +;; slave server connects to the master, it announces itself by sending +;; the protocol (emacs ID). +;; +;; - A way for a client to indicate which Emacs it wants to use. At +;; the protocol level, this is an extra argument in the (name ...) +;; protocol. (The absence of this argument means "no preference". A +;; simplistic master server might then decide to use its own Emacs; a +;; cleverer one might monitor which Emacs appears to be most in use, +;; and use that one.) At the API level this can be an optional +;; argument to the `gds-connect' procedure, and the Emacs GDS code +;; would obviously set this argument when starting a client from +;; within Emacs. +;; +;; We also want a strategy for continuing seamlessly if the master +;; server shuts down. +;; +;; - Each slave server will detect this as an error on the connection +;; to the master socket. Each server then tries to bind to the GDS +;; port again (a race which the OS will resolve), and if that fails, +;; connect again. The result of this is that there should be a new +;; master, and the others all slaves connected to the new master. +;; +;; - Each client will also detect this as an error on the connection +;; to the (master) server. Either the client should try to connect +;; again (perhaps after a short delay), or the reconnection can be +;; delayed until the next time that the client requires the server. +;; (Probably the latter, all done within `gds-read'.) +;; +;; (Historical note: Before this master-slave idea, clients were +;; identified within gds-server.scm and gds*.el by an ID which was +;; actually the file descriptor of their connection to the server. +;; That is no good in the new scheme, because each client's ID must +;; persist when the master server changes, so we now use the client's +;; PID instead. We didn't use PID before because the client/server +;; code was written to be completely asynchronous, which made it +;; tricky for the server to discover each client's PID and associate +;; it with a particular connection. Now we solve that problem by +;; handling the initial protocol exchange synchronously.) +(define (run-slave-server port) + 'not-implemented) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/getopt-long.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/getopt-long.scm new file mode 100755 index 0000000000000000000000000000000000000000..9e39e60c0c9005b974c8731b0767d64a92da4a9d --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/getopt-long.scm @@ -0,0 +1,425 @@ +;;; Copyright (C) 1998, 2001, 2006 Free Software Foundation, Inc. +;;; +;; This library is free software; you can redistribute it and/or +;; modify it under the terms of the GNU Lesser General Public +;; License as published by the Free Software Foundation; either +;; version 2.1 of the License, or (at your option) any later version. +;; +;; This library is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; Lesser General Public License for more details. +;; +;; You should have received a copy of the GNU Lesser General Public +;; License along with this library; if not, write to the Free Software +;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +;;; Author: Russ McManus (rewritten by Thien-Thi Nguyen) + +;;; Commentary: + +;;; This module implements some complex command line option parsing, in +;;; the spirit of the GNU C library function `getopt_long'. Both long +;;; and short options are supported. +;;; +;;; The theory is that people should be able to constrain the set of +;;; options they want to process using a grammar, rather than some arbitrary +;;; structure. The grammar makes the option descriptions easy to read. +;;; +;;; `getopt-long' is a procedure for parsing command-line arguments in a +;;; manner consistent with other GNU programs. `option-ref' is a procedure +;;; that facilitates processing of the `getopt-long' return value. + +;;; (getopt-long ARGS GRAMMAR) +;;; Parse the arguments ARGS according to the argument list grammar GRAMMAR. +;;; +;;; ARGS should be a list of strings. Its first element should be the +;;; name of the program; subsequent elements should be the arguments +;;; that were passed to the program on the command line. The +;;; `program-arguments' procedure returns a list of this form. +;;; +;;; GRAMMAR is a list of the form: +;;; ((OPTION (PROPERTY VALUE) ...) ...) +;;; +;;; Each OPTION should be a symbol. `getopt-long' will accept a +;;; command-line option named `--OPTION'. +;;; Each option can have the following (PROPERTY VALUE) pairs: +;;; +;;; (single-char CHAR) --- Accept `-CHAR' as a single-character +;;; equivalent to `--OPTION'. This is how to specify traditional +;;; Unix-style flags. +;;; (required? BOOL) --- If BOOL is true, the option is required. +;;; getopt-long will raise an error if it is not found in ARGS. +;;; (value BOOL) --- If BOOL is #t, the option accepts a value; if +;;; it is #f, it does not; and if it is the symbol +;;; `optional', the option may appear in ARGS with or +;;; without a value. +;;; (predicate FUNC) --- If the option accepts a value (i.e. you +;;; specified `(value #t)' for this option), then getopt +;;; will apply FUNC to the value, and throw an exception +;;; if it returns #f. FUNC should be a procedure which +;;; accepts a string and returns a boolean value; you may +;;; need to use quasiquotes to get it into GRAMMAR. +;;; +;;; The (PROPERTY VALUE) pairs may occur in any order, but each +;;; property may occur only once. By default, options do not have +;;; single-character equivalents, are not required, and do not take +;;; values. +;;; +;;; In ARGS, single-character options may be combined, in the usual +;;; Unix fashion: ("-x" "-y") is equivalent to ("-xy"). If an option +;;; accepts values, then it must be the last option in the +;;; combination; the value is the next argument. So, for example, using +;;; the following grammar: +;;; ((apples (single-char #\a)) +;;; (blimps (single-char #\b) (value #t)) +;;; (catalexis (single-char #\c) (value #t))) +;;; the following argument lists would be acceptable: +;;; ("-a" "-b" "bang" "-c" "couth") ("bang" and "couth" are the values +;;; for "blimps" and "catalexis") +;;; ("-ab" "bang" "-c" "couth") (same) +;;; ("-ac" "couth" "-b" "bang") (same) +;;; ("-abc" "couth" "bang") (an error, since `-b' is not the +;;; last option in its combination) +;;; +;;; If an option's value is optional, then `getopt-long' decides +;;; whether it has a value by looking at what follows it in ARGS. If +;;; the next element is does not appear to be an option itself, then +;;; that element is the option's value. +;;; +;;; The value of a long option can appear as the next element in ARGS, +;;; or it can follow the option name, separated by an `=' character. +;;; Thus, using the same grammar as above, the following argument lists +;;; are equivalent: +;;; ("--apples" "Braeburn" "--blimps" "Goodyear") +;;; ("--apples=Braeburn" "--blimps" "Goodyear") +;;; ("--blimps" "Goodyear" "--apples=Braeburn") +;;; +;;; If the option "--" appears in ARGS, argument parsing stops there; +;;; subsequent arguments are returned as ordinary arguments, even if +;;; they resemble options. So, in the argument list: +;;; ("--apples" "Granny Smith" "--" "--blimp" "Goodyear") +;;; `getopt-long' will recognize the `apples' option as having the +;;; value "Granny Smith", but it will not recognize the `blimp' +;;; option; it will return the strings "--blimp" and "Goodyear" as +;;; ordinary argument strings. +;;; +;;; The `getopt-long' function returns the parsed argument list as an +;;; assocation list, mapping option names --- the symbols from GRAMMAR +;;; --- onto their values, or #t if the option does not accept a value. +;;; Unused options do not appear in the alist. +;;; +;;; All arguments that are not the value of any option are returned +;;; as a list, associated with the empty list. +;;; +;;; `getopt-long' throws an exception if: +;;; - it finds an unrecognized property in GRAMMAR +;;; - the value of the `single-char' property is not a character +;;; - it finds an unrecognized option in ARGS +;;; - a required option is omitted +;;; - an option that requires an argument doesn't get one +;;; - an option that doesn't accept an argument does get one (this can +;;; only happen using the long option `--opt=value' syntax) +;;; - an option predicate fails +;;; +;;; So, for example: +;;; +;;; (define grammar +;;; `((lockfile-dir (required? #t) +;;; (value #t) +;;; (single-char #\k) +;;; (predicate ,file-is-directory?)) +;;; (verbose (required? #f) +;;; (single-char #\v) +;;; (value #f)) +;;; (x-includes (single-char #\x)) +;;; (rnet-server (single-char #\y) +;;; (predicate ,string?)))) +;;; +;;; (getopt-long '("my-prog" "-vk" "/tmp" "foo1" "--x-includes=/usr/include" +;;; "--rnet-server=lamprod" "--" "-fred" "foo2" "foo3") +;;; grammar) +;;; => ((() "foo1" "-fred" "foo2" "foo3") +;;; (rnet-server . "lamprod") +;;; (x-includes . "/usr/include") +;;; (lockfile-dir . "/tmp") +;;; (verbose . #t)) + +;;; (option-ref OPTIONS KEY DEFAULT) +;;; Return value in alist OPTIONS using KEY, a symbol; or DEFAULT if not +;;; found. The value is either a string or `#t'. +;;; +;;; For example, using the `getopt-long' return value from above: +;;; +;;; (option-ref (getopt-long ...) 'x-includes 42) => "/usr/include" +;;; (option-ref (getopt-long ...) 'not-a-key! 31) => 31 + +;;; Code: + +(define-module (ice-9 getopt-long) + :use-module ((ice-9 common-list) :select (some remove-if-not)) + :export (getopt-long option-ref)) + +(define option-spec-fields '(name + value + required? + single-char + predicate + value-policy)) + +(define option-spec (make-record-type 'option-spec option-spec-fields)) +(define make-option-spec (record-constructor option-spec option-spec-fields)) + +(define (define-one-option-spec-field-accessor field) + `(define ,(symbol-append 'option-spec-> field) ;;; name slib-compat + (record-accessor option-spec ',field))) + +(define (define-one-option-spec-field-modifier field) + `(define ,(symbol-append 'set-option-spec- field '!) ;;; name slib-compat + (record-modifier option-spec ',field))) + +(defmacro define-all-option-spec-accessors/modifiers () + `(begin + ,@(map define-one-option-spec-field-accessor option-spec-fields) + ,@(map define-one-option-spec-field-modifier option-spec-fields))) + +(define-all-option-spec-accessors/modifiers) + +(define make-option-spec + (let ((ctor (record-constructor option-spec '(name)))) + (lambda (name) + (ctor name)))) + +(define (parse-option-spec desc) + (let ((spec (make-option-spec (symbol->string (car desc))))) + (for-each (lambda (desc-elem) + (let ((given (lambda () (cadr desc-elem)))) + (case (car desc-elem) + ((required?) + (set-option-spec-required?! spec (given))) + ((value) + (set-option-spec-value-policy! spec (given))) + ((single-char) + (or (char? (given)) + (error "`single-char' value must be a char!")) + (set-option-spec-single-char! spec (given))) + ((predicate) + (set-option-spec-predicate! + spec ((lambda (pred) + (lambda (name val) + (or (not val) + (pred val) + (error "option predicate failed:" name)))) + (given)))) + (else + (error "invalid getopt-long option property:" + (car desc-elem)))))) + (cdr desc)) + spec)) + +(define (split-arg-list argument-list) + ;; Scan ARGUMENT-LIST for "--" and return (BEFORE-LS . AFTER-LS). + ;; Discard the "--". If no "--" is found, AFTER-LS is empty. + (let loop ((yes '()) (no argument-list)) + (cond ((null? no) (cons (reverse yes) no)) + ((string=? "--" (car no)) (cons (reverse yes) (cdr no))) + (else (loop (cons (car no) yes) (cdr no)))))) + +(define short-opt-rx (make-regexp "^-([a-zA-Z]+)(.*)")) +(define long-opt-no-value-rx (make-regexp "^--([^=]+)$")) +(define long-opt-with-value-rx (make-regexp "^--([^=]+)=(.*)")) + +(define (match-substring match which) + ;; condensed from (ice-9 regex) `match:{substring,start,end}' + (let ((sel (vector-ref match (1+ which)))) + (substring (vector-ref match 0) (car sel) (cdr sel)))) + +(define (expand-clumped-singles opt-ls) + ;; example: ("--xyz" "-abc5d") => ("--xyz" "-a" "-b" "-c" "5d") + (let loop ((opt-ls opt-ls) (ret-ls '())) + (cond ((null? opt-ls) + (reverse ret-ls)) ;;; retval + ((regexp-exec short-opt-rx (car opt-ls)) + => (lambda (match) + (let ((singles (reverse + (map (lambda (c) + (string-append "-" (make-string 1 c))) + (string->list + (match-substring match 1))))) + (extra (match-substring match 2))) + (loop (cdr opt-ls) + (append (if (string=? "" extra) + singles + (cons extra singles)) + ret-ls))))) + (else (loop (cdr opt-ls) + (cons (car opt-ls) ret-ls)))))) + +(define (looks-like-an-option string) + (some (lambda (rx) + (regexp-exec rx string)) + `(,short-opt-rx + ,long-opt-with-value-rx + ,long-opt-no-value-rx))) + +(define (process-options specs argument-ls) + ;; Use SPECS to scan ARGUMENT-LS; return (FOUND . ETC). + ;; FOUND is an unordered list of option specs for found options, while ETC + ;; is an order-maintained list of elements in ARGUMENT-LS that are neither + ;; options nor their values. + (let ((idx (map (lambda (spec) + (cons (option-spec->name spec) spec)) + specs)) + (sc-idx (map (lambda (spec) + (cons (make-string 1 (option-spec->single-char spec)) + spec)) + (remove-if-not option-spec->single-char specs)))) + (let loop ((argument-ls argument-ls) (found '()) (etc '())) + (let ((eat! (lambda (spec ls) + (let ((val!loop (lambda (val n-ls n-found n-etc) + (set-option-spec-value! + spec + ;; handle multiple occurrances + (cond ((option-spec->value spec) + => (lambda (cur) + ((if (list? cur) cons list) + val cur))) + (else val))) + (loop n-ls n-found n-etc))) + (ERR:no-arg (lambda () + (error (string-append + "option must be specified" + " with argument:") + (option-spec->name spec))))) + (cond + ((eq? 'optional (option-spec->value-policy spec)) + (if (or (null? (cdr ls)) + (looks-like-an-option (cadr ls))) + (val!loop #t + (cdr ls) + (cons spec found) + etc) + (val!loop (cadr ls) + (cddr ls) + (cons spec found) + etc))) + ((eq? #t (option-spec->value-policy spec)) + (if (or (null? (cdr ls)) + (looks-like-an-option (cadr ls))) + (ERR:no-arg) + (val!loop (cadr ls) + (cddr ls) + (cons spec found) + etc))) + (else + (val!loop #t + (cdr ls) + (cons spec found) + etc))))))) + (if (null? argument-ls) + (cons found (reverse etc)) ;;; retval + (cond ((regexp-exec short-opt-rx (car argument-ls)) + => (lambda (match) + (let* ((c (match-substring match 1)) + (spec (or (assoc-ref sc-idx c) + (error "no such option:" c)))) + (eat! spec argument-ls)))) + ((regexp-exec long-opt-no-value-rx (car argument-ls)) + => (lambda (match) + (let* ((opt (match-substring match 1)) + (spec (or (assoc-ref idx opt) + (error "no such option:" opt)))) + (eat! spec argument-ls)))) + ((regexp-exec long-opt-with-value-rx (car argument-ls)) + => (lambda (match) + (let* ((opt (match-substring match 1)) + (spec (or (assoc-ref idx opt) + (error "no such option:" opt)))) + (if (option-spec->value-policy spec) + (eat! spec (append + (list 'ignored + (match-substring match 2)) + (cdr argument-ls))) + (error "option does not support argument:" + opt))))) + (else + (loop (cdr argument-ls) + found + (cons (car argument-ls) etc))))))))) + +(define (getopt-long program-arguments option-desc-list) + "Process options, handling both long and short options, similar to +the glibc function 'getopt_long'. PROGRAM-ARGUMENTS should be a value +similar to what (program-arguments) returns. OPTION-DESC-LIST is a +list of option descriptions. Each option description must satisfy the +following grammar: + + :: ( . ) + :: ( . ) + | () + :: + | + | + | + | + :: (required? ) + :: (single-char ) + :: (value #t) + (value #f) + (value optional) + :: (predicate <1-ary-function>) + + The procedure returns an alist of option names and values. Each +option name is a symbol. The option value will be '#t' if no value +was specified. There is a special item in the returned alist with a +key of the empty list, (): the list of arguments that are not options +or option values. + By default, options are not required, and option values are not +required. By default, single character equivalents are not supported; +if you want to allow the user to use single character options, you need +to add a `single-char' clause to the option description." + (let* ((specifications (map parse-option-spec option-desc-list)) + (pair (split-arg-list (cdr program-arguments))) + (split-ls (expand-clumped-singles (car pair))) + (non-split-ls (cdr pair)) + (found/etc (process-options specifications split-ls)) + (found (car found/etc)) + (rest-ls (append (cdr found/etc) non-split-ls))) + (for-each (lambda (spec) + (let ((name (option-spec->name spec)) + (val (option-spec->value spec))) + (and (option-spec->required? spec) + (or (memq spec found) + (error "option must be specified:" name))) + (and (memq spec found) + (eq? #t (option-spec->value-policy spec)) + (or val + (error "option must be specified with argument:" + name))) + (let ((pred (option-spec->predicate spec))) + (and pred (pred name val))))) + specifications) + (cons (cons '() rest-ls) + (let ((multi-count (map (lambda (desc) + (cons (car desc) 0)) + option-desc-list))) + (map (lambda (spec) + (let ((name (string->symbol (option-spec->name spec)))) + (cons name + ;; handle multiple occurrances + (let ((maybe-ls (option-spec->value spec))) + (if (list? maybe-ls) + (let* ((look (assq name multi-count)) + (idx (cdr look)) + (val (list-ref maybe-ls idx))) + (set-cdr! look (1+ idx)) ; ugh! + val) + maybe-ls))))) + found))))) + +(define (option-ref options key default) + "Return value in alist OPTIONS using KEY, a symbol; or DEFAULT if not found. +The value is either a string or `#t'." + (or (assq-ref options key) default)) + +;;; getopt-long.scm ends here diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/hcons.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/hcons.scm new file mode 100755 index 0000000000000000000000000000000000000000..6323506d296a117b4624d48c502e6a1229888c36 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/hcons.scm @@ -0,0 +1,80 @@ +;;; installed-scm-file + +;;;; Copyright (C) 1995, 1996, 1998, 2001, 2003, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; + + +(define-module (ice-9 hcons) + :export (hashq-cons-hash hashq-cons-assoc hashq-cons-get-handle + hashq-cons-create-handle! hashq-cons-ref hashq-cons-set! hashq-cons + hashq-conser make-gc-buffer)) + + +;;; {Eq? hash-consing} +;;; +;;; A hash conser maintains a private universe of pairs s.t. if +;;; two cons calls pass eq? arguments, the pairs returned are eq?. +;;; +;;; A hash conser does not contribute life to the pairs it returns. +;;; + +(define (hashq-cons-hash pair n) + (modulo (logxor (hashq (car pair) 4194303) + (hashq (cdr pair) 4194303)) + n)) + +(define (hashq-cons-assoc key l) + (and (not (null? l)) + (or (and (pair? l) ; If not a pair, use its cdr? + (pair? (car l)) + (pair? (caar l)) + (eq? (car key) (caaar l)) + (eq? (cdr key) (cdaar l)) + (car l)) + (hashq-cons-assoc key (cdr l))))) + +(define (hashq-cons-get-handle table key) + (hashx-get-handle hashq-cons-hash hashq-cons-assoc table key)) + +(define (hashq-cons-create-handle! table key init) + (hashx-create-handle! hashq-cons-hash hashq-cons-assoc table key init)) + +(define (hashq-cons-ref table key) + (hashx-ref hashq-cons-hash hashq-cons-assoc table key #f)) + +(define (hashq-cons-set! table key val) + (hashx-set! hashq-cons-hash hashq-cons-assoc table key val)) + +(define (hashq-cons table a d) + (car (hashq-cons-create-handle! table (cons a d) #f))) + +(define (hashq-conser hash-tab-or-size) + (let ((table (if (vector? hash-tab-or-size) + hash-tab-or-size + (make-doubly-weak-hash-table hash-tab-or-size)))) + (lambda (a d) (hashq-cons table a d)))) + + + + +(define (make-gc-buffer n) + (let ((ring (make-list n #f))) + (append! ring ring) + (lambda (next) + (set-car! ring next) + (set! ring (cdr ring)) + next))) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/history.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/history.scm new file mode 100755 index 0000000000000000000000000000000000000000..921a25741e50cce2155428481299e30c6d6b8086 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/history.scm @@ -0,0 +1,41 @@ +;;;; Copyright (C) 2000, 2001, 2004, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; + +;;;; A simple value history support + +(define-module (ice-9 history)) + +(process-define-module '((value-history))) + +(define (use-value-history x) + (module-use! (current-module) + (resolve-interface '(value-history)))) + +(define save-value-history + (let ((count 0) + (history (resolve-module '(value-history)))) + (lambda (v) + (if (not (unspecified? v)) + (let* ((c (1+ count)) + (s (string->symbol (simple-format #f "$~A" c)))) + (simple-format #t "~A = " s) + (module-define! history s v) + (module-export! history (list s)) + (set! count c)))))) + +(add-hook! before-eval-hook use-value-history) +(add-hook! before-print-hook save-value-history) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/lineio.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/lineio.scm new file mode 100755 index 0000000000000000000000000000000000000000..f122268dff08405ff26fc235f21c857c44c5bd05 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/lineio.scm @@ -0,0 +1,115 @@ +;;; installed-scm-file + +;;;; Copyright (C) 1996, 1998, 2001, 2003, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; + + + +(define-module (ice-9 lineio) + :use-module (ice-9 readline) + :export (unread-string read-string lineio-port? + make-line-buffering-input-port)) + + +;;; {Line Buffering Input Ports} +;;; +;;; [This is a work-around to get past certain deficiencies in the capabilities +;;; of ports. Eventually, ports should be fixed and this module nuked.] +;;; +;;; A line buffering input port supports: +;;; +;;; read-string which returns the next line of input +;;; unread-string which pushes a line back onto the stream +;;; +;;; The implementation of unread-string is kind of limited; it doesn't +;;; interact properly with unread-char, or any of the other port +;;; reading functions. Only read-string will get you back the things that +;;; unread-string accepts. +;;; +;;; Normally a "line" is all characters up to and including a newline. +;;; If lines are put back using unread-string, they can be broken arbitrarily +;;; -- that is, read-string returns strings passed to unread-string (or +;;; shared substrings of them). +;;; + +;; read-string port +;; unread-string port str +;; Read (or buffer) a line from PORT. +;; +;; Not all ports support these functions -- only those with +;; 'unread-string and 'read-string properties, bound to hooks +;; implementing these functions. +;; +(define (unread-string str line-buffering-input-port) + ((object-property line-buffering-input-port 'unread-string) str)) + +;; +(define (read-string line-buffering-input-port) + ((object-property line-buffering-input-port 'read-string))) + + +(define (lineio-port? port) + (not (not (object-property port 'read-string)))) + +;; make-line-buffering-input-port port +;; Return a wrapper for PORT. The wrapper handles read-string/unread-string. +;; +;; The port returned by this function reads newline terminated lines from PORT. +;; It buffers these characters internally, and parsels them out via calls +;; to read-char, read-string, and unread-string. +;; + +(define (make-line-buffering-input-port underlying-port) + (let* (;; buffers - a list of strings put back by unread-string or cached + ;; using read-line. + ;; + (buffers '()) + + ;; getc - return the next character from a buffer or from the underlying + ;; port. + ;; + (getc (lambda () + (if (not buffers) + (read-char underlying-port) + (let ((c (string-ref (car buffers) 0))) + (if (= 1 (string-length (car buffers))) + (set! buffers (cdr buffers)) + (set-car! buffers (substring (car buffers) 1))) + c)))) + + (propogate-close (lambda () (close-port underlying-port))) + + (self (make-soft-port (vector #f #f #f getc propogate-close) "r")) + + (unread-string (lambda (str) + (and (< 0 (string-length str)) + (set! buffers (cons str buffers))))) + + (read-string (lambda () + (cond + ((not (null? buffers)) + (let ((answer (car buffers))) + (set! buffers (cdr buffers)) + answer)) + (else + (read-line underlying-port 'concat)))))) ;handle-newline->concat + + (set-object-property! self 'unread-string unread-string) + (set-object-property! self 'read-string read-string) + self)) + + diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/list.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/list.scm new file mode 100755 index 0000000000000000000000000000000000000000..af83d174274c281bd96fe6319706642e3b20339c --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/list.scm @@ -0,0 +1,36 @@ +;;;; List functions not provided in R5RS or srfi-1 + +;;; Copyright (C) 2003, 2006 Free Software Foundation, Inc. +;;; +;; This library is free software; you can redistribute it and/or +;; modify it under the terms of the GNU Lesser General Public +;; License as published by the Free Software Foundation; either +;; version 2.1 of the License, or (at your option) any later version. +;; +;; This library is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; Lesser General Public License for more details. +;; +;; You should have received a copy of the GNU Lesser General Public +;; License along with this library; if not, write to the Free Software +;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +(define-module (ice-9 list) + :export (rassoc rassv rassq)) + +(define (generic-rassoc key alist =) + (let loop ((ls alist)) + (and (not (null? ls)) + (if (= key (cdar ls)) + (car ls) + (loop (cdr ls)))))) + +(define (rassoc key alist . =) + (generic-rassoc key alist (if (null? =) equal? (car =)))) + +(define (rassv key alist) + (generic-rassoc key alist eqv?)) + +(define (rassq key alist) + (generic-rassoc key alist eq?)) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/ls.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/ls.scm new file mode 100755 index 0000000000000000000000000000000000000000..e848be32af880d6f00e8119bc8f5bb468cfc5adb --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/ls.scm @@ -0,0 +1,96 @@ +;;;; ls.scm --- functions for browsing modules +;;;; +;;;; Copyright (C) 1995, 1996, 1997, 1999, 2001, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; + +(define-module (ice-9 ls) + :use-module (ice-9 common-list) + :export (local-definitions-in definitions-in ls lls + recursive-local-define)) + +;;;; +;;; local-definitions-in root name +;;; Returns a list of names defined locally in the named +;;; subdirectory of root. +;;; definitions-in root name +;;; Returns a list of all names defined in the named +;;; subdirectory of root. The list includes alll locally +;;; defined names as well as all names inherited from a +;;; member of a use-list. +;;; +;;; A convenient interface for examining the nature of things: +;;; +;;; ls . various-names +;;; +;;; With no arguments, return a list of definitions in +;;; `(current-module)'. +;;; +;;; With just one argument, interpret that argument as the +;;; name of a subdirectory of the current module and +;;; return a list of names defined there. +;;; +;;; With more than one argument, still compute +;;; subdirectory lists, but return a list: +;;; (( . ) +;;; ( . ) +;;; ...) +;;; +;;; lls . various-names +;;; +;;; Analogous to `ls', but with local definitions only. + +(define (local-definitions-in root names) + (let ((m (nested-ref root names)) + (answer '())) + (if (not (module? m)) + (set! answer m) + (module-for-each (lambda (k v) (set! answer (cons k answer))) m)) + answer)) + +(define (definitions-in root names) + (let ((m (nested-ref root names))) + (if (not (module? m)) + m + (reduce union + (cons (local-definitions-in m '()) + (map (lambda (m2) (definitions-in m2 '())) + (module-uses m))))))) + +(define (ls . various-refs) + (if (pair? various-refs) + (if (cdr various-refs) + (map (lambda (ref) + (cons ref (definitions-in (current-module) ref))) + various-refs) + (definitions-in (current-module) (car various-refs))) + (definitions-in (current-module) '()))) + +(define (lls . various-refs) + (if (pair? various-refs) + (if (cdr various-refs) + (map (lambda (ref) + (cons ref (local-definitions-in (current-module) ref))) + various-refs) + (local-definitions-in (current-module) (car various-refs))) + (local-definitions-in (current-module) '()))) + +(define (recursive-local-define name value) + (let ((parent (reverse! (cdr (reverse name))))) + (and parent (make-modules-in (current-module) parent)) + (local-define name value))) + +;;; ls.scm ends here diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/mapping.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/mapping.scm new file mode 100755 index 0000000000000000000000000000000000000000..c4ef4fe995a041276d360ce1d6ca10874efe8e25 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/mapping.scm @@ -0,0 +1,128 @@ +;;; installed-scm-file + +;;;; Copyright (C) 1996, 2001, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; + + + +(define-module (ice-9 mapping) + :use-module (ice-9 poe) + :export (mapping-hooks-type make-mapping-hooks mapping-hooks? + mapping-hooks-get-handle mapping-hooks-create-handle + mapping-hooks-remove mapping-type make-mapping mapping? + mapping-hooks mapping-data set-mapping-hooks! set-mapping-data! + mapping-get-handle mapping-create-handle! mapping-remove! + mapping-ref mapping-set! hash-table-mapping-hooks + make-hash-table-mapping hash-table-mapping)) + +(define mapping-hooks-type (make-record-type 'mapping-hooks '(get-handle + create-handle + remove))) + + +(define make-mapping-hooks (perfect-funcq 17 (record-constructor mapping-hooks-type))) +(define mapping-hooks? (record-predicate mapping-hooks-type)) +(define mapping-hooks-get-handle (record-accessor mapping-hooks-type 'get-handle)) +(define mapping-hooks-create-handle (record-accessor mapping-hooks-type 'create-handle)) +(define mapping-hooks-remove (record-accessor mapping-hooks-type 'remove)) + +(define mapping-type (make-record-type 'mapping '(hooks data))) +(define make-mapping (record-constructor mapping-type)) +(define mapping? (record-predicate mapping-type)) +(define mapping-hooks (record-accessor mapping-type 'hooks)) +(define mapping-data (record-accessor mapping-type 'data)) +(define set-mapping-hooks! (record-modifier mapping-type 'hooks)) +(define set-mapping-data! (record-modifier mapping-type 'data)) + +(define (mapping-get-handle map key) + ((mapping-hooks-get-handle (mapping-hooks map)) map key)) +(define (mapping-create-handle! map key . opts) + (apply (mapping-hooks-create-handle (mapping-hooks map)) map key opts)) +(define (mapping-remove! map key) + ((mapping-hooks-remove (mapping-hooks map)) map key)) + +(define (mapping-ref map key . dflt) + (cond + ((mapping-get-handle map key) => cdr) + (dflt => car) + (else #f))) + +(define (mapping-set! map key val) + (set-cdr! (mapping-create-handle! map key #f) val)) + + + +(define hash-table-mapping-hooks + (let ((wrap (lambda (proc) (lambda (1st . rest) (apply proc (mapping-data 1st) rest))))) + + (perfect-funcq 17 + (lambda (hash-proc assoc-proc delete-proc) + (let ((procs (list hash-proc assoc-proc delete-proc))) + (cond + ((equal? procs `(,hashq ,assq ,delq!)) + (make-mapping-hooks (wrap hashq-get-handle) + (wrap hashq-create-handle!) + (wrap hashq-remove!))) + ((equal? procs `(,hashv ,assv ,delv!)) + (make-mapping-hooks (wrap hashv-get-handle) + (wrap hashv-create-handle!) + (wrap hashv-remove!))) + ((equal? procs `(,hash ,assoc ,delete!)) + (make-mapping-hooks (wrap hash-get-handle) + (wrap hash-create-handle!) + (wrap hash-remove!))) + (else + (make-mapping-hooks (wrap + (lambda (table key) + (hashx-get-handle hash-proc assoc-proc table key))) + (wrap + (lambda (table key) + (hashx-create-handle hash-proc assoc-proc table key))) + (wrap + (lambda (table key) + (hashx-get-handle hash-proc assoc-proc delete-proc table key))))))))))) + +(define (make-hash-table-mapping table hash-proc assoc-proc delete-proc) + (make-mapping (hash-table-mapping-hooks hash-proc assoc-proc delete-proc) table)) + +(define (hash-table-mapping . options) + (let* ((size (or (and options (number? (car options)) (car options)) + 71)) + (hash-proc (or (kw-arg-ref options #:hash-proc) hash)) + (assoc-proc (or (kw-arg-ref options #:assoc-proc) + (cond + ((eq? hash-proc hash) assoc) + ((eq? hash-proc hashv) assv) + ((eq? hash-proc hashq) assq) + (else (error 'hash-table-mapping + "Hash-procedure specified with no known assoc function." + hash-proc))))) + (delete-proc (or (kw-arg-ref options #:delete-proc) + (cond + ((eq? hash-proc hash) delete!) + ((eq? hash-proc hashv) delv!) + ((eq? hash-proc hashq) delq!) + (else (error 'hash-table-mapping + "Hash-procedure specified with no known delete function." + hash-proc))))) + (table-constructor (or (kw-arg-ref options #:table-constructor) + (lambda (len) (make-vector len '()))))) + (make-hash-table-mapping (table-constructor size) + hash-proc + assoc-proc + delete-proc))) + diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/match.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/match.scm new file mode 100755 index 0000000000000000000000000000000000000000..e6fe56063c65291badee95faa49049a49437bcbc --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/match.scm @@ -0,0 +1,199 @@ +;;; installed-scm-file + +;;;; Copyright (C) 2001, 2006, 2008 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; + +(define-module (ice-9 match) + :use-module (ice-9 pretty-print) + :export (match match-lambda match-lambda* match-define + match-let match-let* match-letrec + define-structure define-const-structure + match:andmap + match:error match:set-error + match:error-control match:set-error-control + match:structure-control match:set-structure-control + match:runtime-structures match:set-runtime-structures)) + +;; The original code can be found at the Scheme Repository +;; +;; http://www.cs.indiana.edu/scheme-repository/code.match.html +;; +;; or Andrew K. Wright's web page: +;; +;; http://www.star-lab.com/wright/code.html + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Pattern Matching Syntactic Extensions for Scheme +;; +(define match:version "Version 1.19, Sep 15, 1995") +;; +;; Written by Andrew K. Wright, 1993 (wright@research.nj.nec.com). +;; Adapted from code originally written by Bruce F. Duba, 1991. +;; This package also includes a modified version of Kent Dybvig's +;; define-structure (see Dybvig, R.K., The Scheme Programming Language, +;; Prentice-Hall, NJ, 1987). +;; +;; This macro package extends Scheme with several new expression forms. +;; Following is a brief summary of the new forms. See the associated +;; LaTeX documentation for a full description of their functionality. +;; +;; +;; match expressions: +;; +;; exp ::= ... +;; | (match exp clause ...) +;; | (match-lambda clause ...) +;; | (match-lambda* clause ...) +;; | (match-let ((pat exp) ...) body) +;; | (match-let* ((pat exp) ...) body) +;; | (match-letrec ((pat exp) ...) body) +;; | (match-define pat exp) +;; +;; clause ::= (pat body) | (pat => exp) +;; +;; patterns: matches: +;; +;; pat ::= identifier anything, and binds identifier +;; | _ anything +;; | () the empty list +;; | #t #t +;; | #f #f +;; | string a string +;; | number a number +;; | character a character +;; | 'sexp an s-expression +;; | 'symbol a symbol (special case of s-expr) +;; | (pat_1 ... pat_n) list of n elements +;; | (pat_1 ... pat_n . pat_{n+1}) list of n or more +;; | (pat_1 ... pat_n pat_n+1 ooo) list of n or more, each element +;; of remainder must match pat_n+1 +;; | #(pat_1 ... pat_n) vector of n elements +;; | #(pat_1 ... pat_n pat_n+1 ooo) vector of n or more, each element +;; of remainder must match pat_n+1 +;; | #&pat box +;; | ($ struct-name pat_1 ... pat_n) a structure +;; | (= field pat) a field of a structure +;; | (and pat_1 ... pat_n) if all of pat_1 thru pat_n match +;; | (or pat_1 ... pat_n) if any of pat_1 thru pat_n match +;; | (not pat_1 ... pat_n) if all pat_1 thru pat_n don't match +;; | (? predicate pat_1 ... pat_n) if predicate true and all of +;; pat_1 thru pat_n match +;; | (set! identifier) anything, and binds setter +;; | (get! identifier) anything, and binds getter +;; | `qp a quasi-pattern +;; +;; ooo ::= ... zero or more +;; | ___ zero or more +;; | ..k k or more +;; | __k k or more +;; +;; quasi-patterns: matches: +;; +;; qp ::= () the empty list +;; | #t #t +;; | #f #f +;; | string a string +;; | number a number +;; | character a character +;; | identifier a symbol +;; | (qp_1 ... qp_n) list of n elements +;; | (qp_1 ... qp_n . qp_{n+1}) list of n or more +;; | (qp_1 ... qp_n qp_n+1 ooo) list of n or more, each element +;; of remainder must match qp_n+1 +;; | #(qp_1 ... qp_n) vector of n elements +;; | #(qp_1 ... qp_n qp_n+1 ooo) vector of n or more, each element +;; of remainder must match qp_n+1 +;; | #&qp box +;; | ,pat a pattern +;; | ,@pat a pattern +;; +;; The names (quote, quasiquote, unquote, unquote-splicing, ?, _, $, +;; and, or, not, set!, get!, ..., ___) cannot be used as pattern variables. +;; +;; +;; structure expressions: +;; +;; exp ::= ... +;; | (define-structure (id_0 id_1 ... id_n)) +;; | (define-structure (id_0 id_1 ... id_n) +;; ((id_{n+1} exp_1) ... (id_{n+m} exp_m))) +;; | (define-const-structure (id_0 arg_1 ... arg_n)) +;; | (define-const-structure (id_0 arg_1 ... arg_n) +;; ((arg_{n+1} exp_1) ... (arg_{n+m} exp_m))) +;; +;; arg ::= id | (! id) | (@ id) +;; +;; +;; match:error-control controls what code is generated for failed matches. +;; Possible values: +;; 'unspecified - do nothing, ie., evaluate (cond [#f #f]) +;; 'fail - call match:error, or die at car or cdr +;; 'error - call match:error with the unmatched value +;; 'match - call match:error with the unmatched value _and_ +;; the quoted match expression +;; match:error-control is set by calling match:set-error-control with +;; the new value. +;; +;; match:error is called for a failed match. +;; match:error is set by calling match:set-error with the new value. +;; +;; match:structure-control controls the uniqueness of structures +;; (does not exist for Scheme 48 version). +;; Possible values: +;; 'vector - (default) structures are vectors with a symbol in position 0 +;; 'disjoint - structures are fully disjoint from all other values +;; match:structure-control is set by calling match:set-structure-control +;; with the new value. +;; +;; match:runtime-structures controls whether local structure declarations +;; generate new structures each time they are reached +;; (does not exist for Scheme 48 version). +;; Possible values: +;; #t - (default) each runtime occurrence generates a new structure +;; #f - each lexical occurrence generates a new structure +;; +;; End of user visible/modifiable stuff. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define match:error (lambda (val . args) (for-each pretty-print args) (error "no matching clause for " val))) +(define match:andmap (lambda (f l) (if (null? l) (and) (and (f (car l)) (match:andmap f (cdr l)))))) +(define match:syntax-err (lambda (obj msg) (error msg obj))) +(define match:disjoint-structure-tags (quote ())) +(define match:make-structure-tag (lambda (name) (if (or (eq? match:structure-control (quote disjoint)) match:runtime-structures) (let ((tag (gensym))) (set! match:disjoint-structure-tags (cons tag match:disjoint-structure-tags)) tag) (string->symbol (string-append "<" (symbol->string name) ">"))))) +(define match:structure? (lambda (tag) (memq tag match:disjoint-structure-tags))) +(define match:structure-control (quote vector)) +(define match:set-structure-control (lambda (v) (set! match:structure-control v))) +(define match:set-error (lambda (v) (set! match:error v))) +(define match:error-control (quote error)) +(define match:set-error-control (lambda (v) (set! match:error-control v))) +(define match:disjoint-predicates (cons (quote null) (quote (pair? symbol? boolean? number? string? char? procedure? vector?)))) +(define match:vector-structures (quote ())) +(define match:expanders (letrec ((genmatch (lambda (x clauses match-expr) (let* ((length>= (gensym)) (eb-errf (error-maker match-expr)) (blist (car eb-errf)) (plist (map (lambda (c) (let* ((x (bound (validate-pattern (car c)))) (p (car x)) (bv (cadr x)) (bindings (caddr x)) (code (gensym)) (fail (and (pair? (cdr c)) (pair? (cadr c)) (eq? (caadr c) (quote =>)) (symbol? (cadadr c)) (pair? (cdadr c)) (null? (cddadr c)) (pair? (cddr c)) (cadadr c))) (bv2 (if fail (cons fail bv) bv)) (body (if fail (cddr c) (cdr c)))) (set! blist (cons (quasiquote ((unquote code) (lambda (unquote bv2) (unquote-splicing body)))) (append bindings blist))) (list p code bv (and fail (gensym)) #f))) clauses)) (code (gen x (quote ()) plist (cdr eb-errf) length>= (gensym)))) (unreachable plist match-expr) (inline-let (quasiquote (let (((unquote length>=) (lambda (n) (lambda (l) (>= (length l) n)))) (unquote-splicing blist)) (unquote code))))))) (genletrec (lambda (pat exp body match-expr) (let* ((length>= (gensym)) (eb-errf (error-maker match-expr)) (x (bound (validate-pattern pat))) (p (car x)) (bv (cadr x)) (bindings (caddr x)) (code (gensym)) (plist (list (list p code bv #f #f))) (x (gensym)) (m (gen x (quote ()) plist (cdr eb-errf) length>= (gensym))) (gs (map (lambda (_) (gensym)) bv))) (unreachable plist match-expr) (quasiquote (letrec (((unquote length>=) (lambda (n) (lambda (l) (>= (length l) n)))) (unquote-splicing (map (lambda (v) (quasiquote ((unquote v) #f))) bv)) ((unquote x) (unquote exp)) ((unquote code) (lambda (unquote gs) (unquote-splicing (map (lambda (v g) (quasiquote (set! (unquote v) (unquote g)))) bv gs)) (unquote-splicing body))) (unquote-splicing bindings) (unquote-splicing (car eb-errf))) (unquote m)))))) (gendefine (lambda (pat exp match-expr) (let* ((length>= (gensym)) (eb-errf (error-maker match-expr)) (x (bound (validate-pattern pat))) (p (car x)) (bv (cadr x)) (bindings (caddr x)) (code (gensym)) (plist (list (list p code bv #f #f))) (x (gensym)) (m (gen x (quote ()) plist (cdr eb-errf) length>= (gensym))) (gs (map (lambda (_) (gensym)) bv))) (unreachable plist match-expr) (quasiquote (begin (unquote-splicing (map (lambda (v) (quasiquote (define (unquote v) #f))) bv)) (unquote (inline-let (quasiquote (let (((unquote length>=) (lambda (n) (lambda (l) (>= (length l) n)))) ((unquote x) (unquote exp)) ((unquote code) (lambda (unquote gs) (unquote-splicing (map (lambda (v g) (quasiquote (set! (unquote v) (unquote g)))) bv gs)) (cond (#f #f)))) (unquote-splicing bindings) (unquote-splicing (car eb-errf))) (unquote m)))))))))) (pattern-var? (lambda (x) (and (symbol? x) (not (dot-dot-k? x)) (not (memq x (quote (quasiquote quote unquote unquote-splicing ? _ $ = and or not set! get! ... ___))))))) (dot-dot-k? (lambda (s) (and (symbol? s) (if (memq s (quote (... ___))) 0 (let* ((s (symbol->string s)) (n (string-length s))) (and (<= 3 n) (memq (string-ref s 0) (quote (#\. #\_))) (memq (string-ref s 1) (quote (#\. #\_))) (match:andmap char-numeric? (string->list (substring s 2 n))) (string->number (substring s 2 n)))))))) (error-maker (lambda (match-expr) (cond ((eq? match:error-control (quote unspecified)) (cons (quote ()) (lambda (x) (quasiquote (cond (#f #f)))))) ((memq match:error-control (quote (error fail))) (cons (quote ()) (lambda (x) (quasiquote (match:error (unquote x)))))) ((eq? match:error-control (quote match)) (let ((errf (gensym)) (arg (gensym))) (cons (quasiquote (((unquote errf) (lambda ((unquote arg)) (match:error (unquote arg) (quote (unquote match-expr))))))) (lambda (x) (quasiquote ((unquote errf) (unquote x))))))) (else (match:syntax-err (quote (unspecified error fail match)) "invalid value for match:error-control, legal values are"))))) (unreachable (lambda (plist match-expr) (for-each (lambda (x) (if (not (car (cddddr x))) (begin (display "Warning: unreachable pattern ") (display (car x)) (display " in ") (display match-expr) (newline)))) plist))) (validate-pattern (lambda (pattern) (letrec ((simple? (lambda (x) (or (string? x) (boolean? x) (char? x) (number? x) (null? x)))) (ordinary (lambda (p) (let ((g157 (lambda (x y) (cons (ordinary x) (ordinary y))))) (if (simple? p) ((lambda (p) p) p) (if (equal? p (quote _)) ((lambda () (quote _))) (if (pattern-var? p) ((lambda (p) p) p) (if (pair? p) (if (equal? (car p) (quote quasiquote)) (if (and (pair? (cdr p)) (null? (cddr p))) ((lambda (p) (quasi p)) (cadr p)) (g157 (car p) (cdr p))) (if (equal? (car p) (quote quote)) (if (and (pair? (cdr p)) (null? (cddr p))) ((lambda (p) p) p) (g157 (car p) (cdr p))) (if (equal? (car p) (quote ?)) (if (and (pair? (cdr p)) (list? (cddr p))) ((lambda (pred ps) (quasiquote (? (unquote pred) (unquote-splicing (map ordinary ps))))) (cadr p) (cddr p)) (g157 (car p) (cdr p))) (if (equal? (car p) (quote =)) (if (and (pair? (cdr p)) (pair? (cddr p)) (null? (cdddr p))) ((lambda (sel p) (quasiquote (= (unquote sel) (unquote (ordinary p))))) (cadr p) (caddr p)) (g157 (car p) (cdr p))) (if (equal? (car p) (quote and)) (if (and (list? (cdr p)) (pair? (cdr p))) ((lambda (ps) (quasiquote (and (unquote-splicing (map ordinary ps))))) (cdr p)) (g157 (car p) (cdr p))) (if (equal? (car p) (quote or)) (if (and (list? (cdr p)) (pair? (cdr p))) ((lambda (ps) (quasiquote (or (unquote-splicing (map ordinary ps))))) (cdr p)) (g157 (car p) (cdr p))) (if (equal? (car p) (quote not)) (if (and (list? (cdr p)) (pair? (cdr p))) ((lambda (ps) (quasiquote (not (unquote-splicing (map ordinary ps))))) (cdr p)) (g157 (car p) (cdr p))) (if (equal? (car p) (quote $)) (if (and (pair? (cdr p)) (symbol? (cadr p)) (list? (cddr p))) ((lambda (r ps) (quasiquote ($ (unquote r) (unquote-splicing (map ordinary ps))))) (cadr p) (cddr p)) (g157 (car p) (cdr p))) (if (equal? (car p) (quote set!)) (if (and (pair? (cdr p)) (pattern-var? (cadr p)) (null? (cddr p))) ((lambda (p) p) p) (g157 (car p) (cdr p))) (if (equal? (car p) (quote get!)) (if (and (pair? (cdr p)) (pattern-var? (cadr p)) (null? (cddr p))) ((lambda (p) p) p) (g157 (car p) (cdr p))) (if (equal? (car p) (quote unquote)) (g157 (car p) (cdr p)) (if (equal? (car p) (quote unquote-splicing)) (g157 (car p) (cdr p)) (if (and (pair? (cdr p)) (dot-dot-k? (cadr p)) (null? (cddr p))) ((lambda (p ddk) (quasiquote ((unquote (ordinary p)) (unquote ddk)))) (car p) (cadr p)) (g157 (car p) (cdr p))))))))))))))) (if (vector? p) ((lambda (p) (let* ((pl (vector->list p)) (rpl (reverse pl))) (apply vector (if (and (not (null? rpl)) (dot-dot-k? (car rpl))) (reverse (cons (car rpl) (map ordinary (cdr rpl)))) (map ordinary pl))))) p) ((lambda () (match:syntax-err pattern "syntax error in pattern"))))))))))) (quasi (lambda (p) (let ((g178 (lambda (x y) (cons (quasi x) (quasi y))))) (if (simple? p) ((lambda (p) p) p) (if (symbol? p) ((lambda (p) (quasiquote (quote (unquote p)))) p) (if (pair? p) (if (equal? (car p) (quote unquote)) (if (and (pair? (cdr p)) (null? (cddr p))) ((lambda (p) (ordinary p)) (cadr p)) (g178 (car p) (cdr p))) (if (and (pair? (car p)) (equal? (caar p) (quote unquote-splicing)) (pair? (cdar p)) (null? (cddar p))) (if (null? (cdr p)) ((lambda (p) (ordinary p)) (cadar p)) ((lambda (p y) (append (ordlist p) (quasi y))) (cadar p) (cdr p))) (if (and (pair? (cdr p)) (dot-dot-k? (cadr p)) (null? (cddr p))) ((lambda (p ddk) (quasiquote ((unquote (quasi p)) (unquote ddk)))) (car p) (cadr p)) (g178 (car p) (cdr p))))) (if (vector? p) ((lambda (p) (let* ((pl (vector->list p)) (rpl (reverse pl))) (apply vector (if (dot-dot-k? (car rpl)) (reverse (cons (car rpl) (map quasi (cdr rpl)))) (map ordinary pl))))) p) ((lambda () (match:syntax-err pattern "syntax error in pattern")))))))))) (ordlist (lambda (p) (cond ((null? p) (quote ())) ((pair? p) (cons (ordinary (car p)) (ordlist (cdr p)))) (else (match:syntax-err pattern "invalid use of unquote-splicing in pattern")))))) (ordinary pattern)))) (bound (lambda (pattern) (letrec ((pred-bodies (quote ())) (bound (lambda (p a k) (cond ((eq? (quote _) p) (k p a)) ((symbol? p) (if (memq p a) (match:syntax-err pattern "duplicate variable in pattern")) (k p (cons p a))) ((and (pair? p) (eq? (quote quote) (car p))) (k p a)) ((and (pair? p) (eq? (quote ?) (car p))) (cond ((not (null? (cddr p))) (bound (quasiquote (and (? (unquote (cadr p))) (unquote-splicing (cddr p)))) a k)) ((or (not (symbol? (cadr p))) (memq (cadr p) a)) (let ((g (gensym))) (set! pred-bodies (cons (quasiquote ((unquote g) (unquote (cadr p)))) pred-bodies)) (k (quasiquote (? (unquote g))) a))) (else (k p a)))) ((and (pair? p) (eq? (quote =) (car p))) (cond ((or (not (symbol? (cadr p))) (memq (cadr p) a)) (let ((g (gensym))) (set! pred-bodies (cons (quasiquote ((unquote g) (unquote (cadr p)))) pred-bodies)) (bound (quasiquote (= (unquote g) (unquote (caddr p)))) a k))) (else (bound (caddr p) a (lambda (p2 a) (k (quasiquote (= (unquote (cadr p)) (unquote p2))) a)))))) ((and (pair? p) (eq? (quote and) (car p))) (bound* (cdr p) a (lambda (p a) (k (quasiquote (and (unquote-splicing p))) a)))) ((and (pair? p) (eq? (quote or) (car p))) (bound (cadr p) a (lambda (first-p first-a) (let or* ((plist (cddr p)) (k (lambda (plist) (k (quasiquote (or (unquote first-p) (unquote-splicing plist))) first-a)))) (if (null? plist) (k plist) (bound (car plist) a (lambda (car-p car-a) (if (not (permutation car-a first-a)) (match:syntax-err pattern "variables of or-pattern differ in")) (or* (cdr plist) (lambda (cdr-p) (k (cons car-p cdr-p))))))))))) ((and (pair? p) (eq? (quote not) (car p))) (cond ((not (null? (cddr p))) (bound (quasiquote (not (or (unquote-splicing (cdr p))))) a k)) (else (bound (cadr p) a (lambda (p2 a2) (if (not (permutation a a2)) (match:syntax-err p "no variables allowed in")) (k (quasiquote (not (unquote p2))) a)))))) ((and (pair? p) (pair? (cdr p)) (dot-dot-k? (cadr p))) (bound (car p) a (lambda (q b) (let ((bvars (find-prefix b a))) (k (quasiquote ((unquote q) (unquote (cadr p)) (unquote bvars) (unquote (gensym)) (unquote (gensym)) (unquote (map (lambda (_) (gensym)) bvars)))) b))))) ((and (pair? p) (eq? (quote $) (car p))) (bound* (cddr p) a (lambda (p1 a) (k (quasiquote ($ (unquote (cadr p)) (unquote-splicing p1))) a)))) ((and (pair? p) (eq? (quote set!) (car p))) (if (memq (cadr p) a) (k p a) (k p (cons (cadr p) a)))) ((and (pair? p) (eq? (quote get!) (car p))) (if (memq (cadr p) a) (k p a) (k p (cons (cadr p) a)))) ((pair? p) (bound (car p) a (lambda (car-p a) (bound (cdr p) a (lambda (cdr-p a) (k (cons car-p cdr-p) a)))))) ((vector? p) (boundv (vector->list p) a (lambda (pl a) (k (list->vector pl) a)))) (else (k p a))))) (boundv (lambda (plist a k) (let ((g184 (lambda () (k plist a)))) (if (pair? plist) (if (and (pair? (cdr plist)) (dot-dot-k? (cadr plist)) (null? (cddr plist))) ((lambda () (bound plist a k))) (if (null? plist) (g184) ((lambda (x y) (bound x a (lambda (car-p a) (boundv y a (lambda (cdr-p a) (k (cons car-p cdr-p) a)))))) (car plist) (cdr plist)))) (if (null? plist) (g184) (match:error plist)))))) (bound* (lambda (plist a k) (if (null? plist) (k plist a) (bound (car plist) a (lambda (car-p a) (bound* (cdr plist) a (lambda (cdr-p a) (k (cons car-p cdr-p) a)))))))) (find-prefix (lambda (b a) (if (eq? b a) (quote ()) (cons (car b) (find-prefix (cdr b) a))))) (permutation (lambda (p1 p2) (and (= (length p1) (length p2)) (match:andmap (lambda (x1) (memq x1 p2)) p1))))) (bound pattern (quote ()) (lambda (p a) (list p (reverse a) pred-bodies)))))) (inline-let (lambda (let-exp) (letrec ((occ (lambda (x e) (let loop ((e e)) (cond ((pair? e) (+ (loop (car e)) (loop (cdr e)))) ((eq? x e) 1) (else 0))))) (subst (lambda (e old new) (let loop ((e e)) (cond ((pair? e) (cons (loop (car e)) (loop (cdr e)))) ((eq? old e) new) (else e))))) (const? (lambda (sexp) (or (symbol? sexp) (boolean? sexp) (string? sexp) (char? sexp) (number? sexp) (null? sexp) (and (pair? sexp) (eq? (car sexp) (quote quote)) (pair? (cdr sexp)) (symbol? (cadr sexp)) (null? (cddr sexp)))))) (isval? (lambda (sexp) (or (const? sexp) (and (pair? sexp) (memq (car sexp) (quote (lambda quote match-lambda match-lambda*))))))) (small? (lambda (sexp) (or (const? sexp) (and (pair? sexp) (eq? (car sexp) (quote lambda)) (pair? (cdr sexp)) (pair? (cddr sexp)) (const? (caddr sexp)) (null? (cdddr sexp))))))) (let loop ((b (cadr let-exp)) (new-b (quote ())) (e (caddr let-exp))) (cond ((null? b) (if (null? new-b) e (quasiquote (let (unquote (reverse new-b)) (unquote e))))) ((isval? (cadr (car b))) (let* ((x (caar b)) (n (occ x e))) (cond ((= 0 n) (loop (cdr b) new-b e)) ((or (= 1 n) (small? (cadr (car b)))) (loop (cdr b) new-b (subst e x (cadr (car b))))) (else (loop (cdr b) (cons (car b) new-b) e))))) (else (loop (cdr b) (cons (car b) new-b) e))))))) (gen (lambda (x sf plist erract length>= eta) (if (null? plist) (erract x) (let* ((v (quote ())) (val (lambda (x) (cdr (assq x v)))) (fail (lambda (sf) (gen x sf (cdr plist) erract length>= eta))) (success (lambda (sf) (set-car! (cddddr (car plist)) #t) (let* ((code (cadr (car plist))) (bv (caddr (car plist))) (fail-sym (cadddr (car plist)))) (if fail-sym (let ((ap (quasiquote ((unquote code) (unquote fail-sym) (unquote-splicing (map val bv)))))) (quasiquote (call-with-current-continuation (lambda ((unquote fail-sym)) (let (((unquote fail-sym) (lambda () ((unquote fail-sym) (unquote (fail sf)))))) (unquote ap)))))) (quasiquote ((unquote code) (unquote-splicing (map val bv))))))))) (let next ((p (caar plist)) (e x) (sf sf) (kf fail) (ks success)) (cond ((eq? (quote _) p) (ks sf)) ((symbol? p) (set! v (cons (cons p e) v)) (ks sf)) ((null? p) (emit (quasiquote (null? (unquote e))) sf kf ks)) ((equal? p (quote (quote ()))) (emit (quasiquote (null? (unquote e))) sf kf ks)) ((string? p) (emit (quasiquote (equal? (unquote e) (unquote p))) sf kf ks)) ((boolean? p) (emit (quasiquote (equal? (unquote e) (unquote p))) sf kf ks)) ((char? p) (emit (quasiquote (equal? (unquote e) (unquote p))) sf kf ks)) ((number? p) (emit (quasiquote (equal? (unquote e) (unquote p))) sf kf ks)) ((and (pair? p) (eq? (quote quote) (car p))) (emit (quasiquote (equal? (unquote e) (unquote p))) sf kf ks)) ((and (pair? p) (eq? (quote ?) (car p))) (let ((tst (quasiquote ((unquote (cadr p)) (unquote e))))) (emit tst sf kf ks))) ((and (pair? p) (eq? (quote =) (car p))) (next (caddr p) (quasiquote ((unquote (cadr p)) (unquote e))) sf kf ks)) ((and (pair? p) (eq? (quote and) (car p))) (let loop ((p (cdr p)) (sf sf)) (if (null? p) (ks sf) (next (car p) e sf kf (lambda (sf) (loop (cdr p) sf)))))) ((and (pair? p) (eq? (quote or) (car p))) (let ((or-v v)) (let loop ((p (cdr p)) (sf sf)) (if (null? p) (kf sf) (begin (set! v or-v) (next (car p) e sf (lambda (sf) (loop (cdr p) sf)) ks)))))) ((and (pair? p) (eq? (quote not) (car p))) (next (cadr p) e sf ks kf)) ((and (pair? p) (eq? (quote $) (car p))) (let* ((tag (cadr p)) (fields (cdr p)) (rlen (length fields)) (tst (quasiquote ((unquote (symbol-append tag (quote ?))) (unquote e))))) (emit tst sf kf (let rloop ((n 1)) (lambda (sf) (if (= n rlen) (ks sf) (next (list-ref fields n) (quasiquote ((unquote (symbol-append tag (quote -) n)) (unquote e))) sf kf (rloop (+ 1 n))))))))) ((and (pair? p) (eq? (quote set!) (car p))) (set! v (cons (cons (cadr p) (setter e p)) v)) (ks sf)) ((and (pair? p) (eq? (quote get!) (car p))) (set! v (cons (cons (cadr p) (getter e p)) v)) (ks sf)) ((and (pair? p) (pair? (cdr p)) (dot-dot-k? (cadr p))) (emit (quasiquote (list? (unquote e))) sf kf (lambda (sf) (let* ((k (dot-dot-k? (cadr p))) (ks (lambda (sf) (let ((bound (list-ref p 2))) (cond ((eq? (car p) (quote _)) (ks sf)) ((null? bound) (let* ((ptst (next (car p) eta sf (lambda (sf) #f) (lambda (sf) #t))) (tst (if (and (pair? ptst) (symbol? (car ptst)) (pair? (cdr ptst)) (eq? eta (cadr ptst)) (null? (cddr ptst))) (car ptst) (quasiquote (lambda ((unquote eta)) (unquote ptst)))))) (assm (quasiquote (match:andmap (unquote tst) (unquote e))) (kf sf) (ks sf)))) ((and (symbol? (car p)) (equal? (list (car p)) bound)) (next (car p) e sf kf ks)) (else (let* ((gloop (list-ref p 3)) (ge (list-ref p 4)) (fresh (list-ref p 5)) (p1 (next (car p) (quasiquote (car (unquote ge))) sf kf (lambda (sf) (quasiquote ((unquote gloop) (cdr (unquote ge)) (unquote-splicing (map (lambda (b f) (quasiquote (cons (unquote (val b)) (unquote f)))) bound fresh)))))))) (set! v (append (map cons bound (map (lambda (x) (quasiquote (reverse (unquote x)))) fresh)) v)) (quasiquote (let (unquote gloop) (((unquote ge) (unquote e)) (unquote-splicing (map (lambda (x) (quasiquote ((unquote x) (quote ())))) fresh))) (if (null? (unquote ge)) (unquote (ks sf)) (unquote p1))))))))))) (case k ((0) (ks sf)) ((1) (emit (quasiquote (pair? (unquote e))) sf kf ks)) (else (emit (quasiquote (((unquote length>=) (unquote k)) (unquote e))) sf kf ks))))))) ((pair? p) (emit (quasiquote (pair? (unquote e))) sf kf (lambda (sf) (next (car p) (add-a e) sf kf (lambda (sf) (next (cdr p) (add-d e) sf kf ks)))))) ((and (vector? p) (>= (vector-length p) 6) (dot-dot-k? (vector-ref p (- (vector-length p) 5)))) (let* ((vlen (- (vector-length p) 6)) (k (dot-dot-k? (vector-ref p (+ vlen 1)))) (minlen (+ vlen k)) (bound (vector-ref p (+ vlen 2)))) (emit (quasiquote (vector? (unquote e))) sf kf (lambda (sf) (assm (quasiquote (>= (vector-length (unquote e)) (unquote minlen))) (kf sf) ((let vloop ((n 0)) (lambda (sf) (cond ((not (= n vlen)) (next (vector-ref p n) (quasiquote (vector-ref (unquote e) (unquote n))) sf kf (vloop (+ 1 n)))) ((eq? (vector-ref p vlen) (quote _)) (ks sf)) (else (let* ((gloop (vector-ref p (+ vlen 3))) (ind (vector-ref p (+ vlen 4))) (fresh (vector-ref p (+ vlen 5))) (p1 (next (vector-ref p vlen) (quasiquote (vector-ref (unquote e) (unquote ind))) sf kf (lambda (sf) (quasiquote ((unquote gloop) (- (unquote ind) 1) (unquote-splicing (map (lambda (b f) (quasiquote (cons (unquote (val b)) (unquote f)))) bound fresh)))))))) (set! v (append (map cons bound fresh) v)) (quasiquote (let (unquote gloop) (((unquote ind) (- (vector-length (unquote e)) 1)) (unquote-splicing (map (lambda (x) (quasiquote ((unquote x) (quote ())))) fresh))) (if (> (unquote minlen) (unquote ind)) (unquote (ks sf)) (unquote p1))))))))) sf)))))) ((vector? p) (let ((vlen (vector-length p))) (emit (quasiquote (vector? (unquote e))) sf kf (lambda (sf) (emit (quasiquote (equal? (vector-length (unquote e)) (unquote vlen))) sf kf (let vloop ((n 0)) (lambda (sf) (if (= n vlen) (ks sf) (next (vector-ref p n) (quasiquote (vector-ref (unquote e) (unquote n))) sf kf (vloop (+ 1 n))))))))))) (else (display "FATAL ERROR IN PATTERN MATCHER") (newline) (error #f "THIS NEVER HAPPENS")))))))) (emit (lambda (tst sf kf ks) (cond ((in tst sf) (ks sf)) ((in (quasiquote (not (unquote tst))) sf) (kf sf)) (else (let* ((e (cadr tst)) (implied (cond ((eq? (car tst) (quote equal?)) (let ((p (caddr tst))) (cond ((string? p) (quasiquote ((string? (unquote e))))) ((boolean? p) (quasiquote ((boolean? (unquote e))))) ((char? p) (quasiquote ((char? (unquote e))))) ((number? p) (quasiquote ((number? (unquote e))))) ((and (pair? p) (eq? (quote quote) (car p))) (quasiquote ((symbol? (unquote e))))) (else (quote ()))))) ((eq? (car tst) (quote null?)) (quasiquote ((list? (unquote e))))) ((vec-structure? tst) (quasiquote ((vector? (unquote e))))) (else (quote ())))) (not-imp (case (car tst) ((list?) (quasiquote ((not (null? (unquote e)))))) (else (quote ())))) (s (ks (cons tst (append implied sf)))) (k (kf (cons (quasiquote (not (unquote tst))) (append not-imp sf))))) (assm tst k s)))))) (assm (lambda (tst f s) (cond ((equal? s f) s) ((and (eq? s #t) (eq? f #f)) tst) ((and (eq? (car tst) (quote pair?)) (memq match:error-control (quote (unspecified fail))) (memq (car f) (quote (cond match:error))) (guarantees s (cadr tst))) s) ((and (pair? s) (eq? (car s) (quote if)) (equal? (cadddr s) f)) (if (eq? (car (cadr s)) (quote and)) (quasiquote (if (and (unquote tst) (unquote-splicing (cdr (cadr s)))) (unquote (caddr s)) (unquote f))) (quasiquote (if (and (unquote tst) (unquote (cadr s))) (unquote (caddr s)) (unquote f))))) ((and (pair? s) (equal? (car s) (quote call-with-current-continuation)) (pair? (cdr s)) (pair? (cadr s)) (equal? (caadr s) (quote lambda)) (pair? (cdadr s)) (pair? (cadadr s)) (null? (cdr (cadadr s))) (pair? (cddadr s)) (pair? (car (cddadr s))) (equal? (caar (cddadr s)) (quote let)) (pair? (cdar (cddadr s))) (pair? (cadar (cddadr s))) (pair? (caadar (cddadr s))) (pair? (cdr (caadar (cddadr s)))) (pair? (cadr (caadar (cddadr s)))) (equal? (caadr (caadar (cddadr s))) (quote lambda)) (pair? (cdadr (caadar (cddadr s)))) (null? (cadadr (caadar (cddadr s)))) (pair? (cddadr (caadar (cddadr s)))) (pair? (car (cddadr (caadar (cddadr s))))) (pair? (cdar (cddadr (caadar (cddadr s))))) (null? (cddar (cddadr (caadar (cddadr s))))) (null? (cdr (cddadr (caadar (cddadr s))))) (null? (cddr (caadar (cddadr s)))) (null? (cdadar (cddadr s))) (pair? (cddar (cddadr s))) (null? (cdddar (cddadr s))) (null? (cdr (cddadr s))) (null? (cddr s)) (equal? f (cadar (cddadr (caadar (cddadr s)))))) (let ((k (car (cadadr s))) (fail (car (caadar (cddadr s)))) (s2 (caddar (cddadr s)))) (quasiquote (call-with-current-continuation (lambda ((unquote k)) (let (((unquote fail) (lambda () ((unquote k) (unquote f))))) (unquote (assm tst (quasiquote ((unquote fail))) s2)))))))) ((and #f (pair? s) (equal? (car s) (quote let)) (pair? (cdr s)) (pair? (cadr s)) (pair? (caadr s)) (pair? (cdaadr s)) (pair? (car (cdaadr s))) (equal? (caar (cdaadr s)) (quote lambda)) (pair? (cdar (cdaadr s))) (null? (cadar (cdaadr s))) (pair? (cddar (cdaadr s))) (null? (cdddar (cdaadr s))) (null? (cdr (cdaadr s))) (null? (cdadr s)) (pair? (cddr s)) (null? (cdddr s)) (equal? (caddar (cdaadr s)) f)) (let ((fail (caaadr s)) (s2 (caddr s))) (quasiquote (let (((unquote fail) (lambda () (unquote f)))) (unquote (assm tst (quasiquote ((unquote fail))) s2)))))) (else (quasiquote (if (unquote tst) (unquote s) (unquote f))))))) (guarantees (lambda (code x) (let ((a (add-a x)) (d (add-d x))) (let loop ((code code)) (cond ((not (pair? code)) #f) ((memq (car code) (quote (cond match:error))) #t) ((or (equal? code a) (equal? code d)) #t) ((eq? (car code) (quote if)) (or (loop (cadr code)) (and (loop (caddr code)) (loop (cadddr code))))) ((eq? (car code) (quote lambda)) #f) ((and (eq? (car code) (quote let)) (symbol? (cadr code))) #f) (else (or (loop (car code)) (loop (cdr code))))))))) (in (lambda (e l) (or (member e l) (and (eq? (car e) (quote list?)) (or (member (quasiquote (null? (unquote (cadr e)))) l) (member (quasiquote (pair? (unquote (cadr e)))) l))) (and (eq? (car e) (quote not)) (let* ((srch (cadr e)) (const-class (equal-test? srch))) (cond (const-class (let mem ((l l)) (if (null? l) #f (let ((x (car l))) (or (and (equal? (cadr x) (cadr srch)) (disjoint? x) (not (equal? const-class (car x)))) (equal? x (quasiquote (not ((unquote const-class) (unquote (cadr srch)))))) (and (equal? (cadr x) (cadr srch)) (equal-test? x) (not (equal? (caddr srch) (caddr x)))) (mem (cdr l))))))) ((disjoint? srch) (let mem ((l l)) (if (null? l) #f (let ((x (car l))) (or (and (equal? (cadr x) (cadr srch)) (disjoint? x) (not (equal? (car x) (car srch)))) (mem (cdr l))))))) ((eq? (car srch) (quote list?)) (let mem ((l l)) (if (null? l) #f (let ((x (car l))) (or (and (equal? (cadr x) (cadr srch)) (disjoint? x) (not (memq (car x) (quote (list? pair? null?))))) (mem (cdr l))))))) ((vec-structure? srch) (let mem ((l l)) (if (null? l) #f (let ((x (car l))) (or (and (equal? (cadr x) (cadr srch)) (or (disjoint? x) (vec-structure? x)) (not (equal? (car x) (quote vector?))) (not (equal? (car x) (car srch)))) (equal? x (quasiquote (not (vector? (unquote (cadr srch)))))) (mem (cdr l))))))) (else #f))))))) (equal-test? (lambda (tst) (and (eq? (car tst) (quote equal?)) (let ((p (caddr tst))) (cond ((string? p) (quote string?)) ((boolean? p) (quote boolean?)) ((char? p) (quote char?)) ((number? p) (quote number?)) ((and (pair? p) (pair? (cdr p)) (null? (cddr p)) (eq? (quote quote) (car p)) (symbol? (cadr p))) (quote symbol?)) (else #f)))))) (disjoint? (lambda (tst) (memq (car tst) match:disjoint-predicates))) (vec-structure? (lambda (tst) (memq (car tst) match:vector-structures))) (add-a (lambda (a) (let ((new (and (pair? a) (assq (car a) c---rs)))) (if new (cons (cadr new) (cdr a)) (quasiquote (car (unquote a))))))) (add-d (lambda (a) (let ((new (and (pair? a) (assq (car a) c---rs)))) (if new (cons (cddr new) (cdr a)) (quasiquote (cdr (unquote a))))))) (c---rs (quote ((car caar . cdar) (cdr cadr . cddr) (caar caaar . cdaar) (cadr caadr . cdadr) (cdar cadar . cddar) (cddr caddr . cdddr) (caaar caaaar . cdaaar) (caadr caaadr . cdaadr) (cadar caadar . cdadar) (caddr caaddr . cdaddr) (cdaar cadaar . cddaar) (cdadr cadadr . cddadr) (cddar caddar . cdddar) (cdddr cadddr . cddddr)))) (setter (lambda (e p) (let ((mk-setter (lambda (s) (symbol-append (quote set-) s (quote !))))) (cond ((not (pair? e)) (match:syntax-err p "unnested set! pattern")) ((eq? (car e) (quote vector-ref)) (quasiquote (let ((x (unquote (cadr e)))) (lambda (y) (vector-set! x (unquote (caddr e)) y))))) ((eq? (car e) (quote unbox)) (quasiquote (let ((x (unquote (cadr e)))) (lambda (y) (set-box! x y))))) ((eq? (car e) (quote car)) (quasiquote (let ((x (unquote (cadr e)))) (lambda (y) (set-car! x y))))) ((eq? (car e) (quote cdr)) (quasiquote (let ((x (unquote (cadr e)))) (lambda (y) (set-cdr! x y))))) ((let ((a (assq (car e) get-c---rs))) (and a (quasiquote (let ((x ((unquote (cadr a)) (unquote (cadr e))))) (lambda (y) ((unquote (mk-setter (cddr a))) x y))))))) (else (quasiquote (let ((x (unquote (cadr e)))) (lambda (y) ((unquote (mk-setter (car e))) x y))))))))) (getter (lambda (e p) (cond ((not (pair? e)) (match:syntax-err p "unnested get! pattern")) ((eq? (car e) (quote vector-ref)) (quasiquote (let ((x (unquote (cadr e)))) (lambda () (vector-ref x (unquote (caddr e))))))) ((eq? (car e) (quote unbox)) (quasiquote (let ((x (unquote (cadr e)))) (lambda () (unbox x))))) ((eq? (car e) (quote car)) (quasiquote (let ((x (unquote (cadr e)))) (lambda () (car x))))) ((eq? (car e) (quote cdr)) (quasiquote (let ((x (unquote (cadr e)))) (lambda () (cdr x))))) ((let ((a (assq (car e) get-c---rs))) (and a (quasiquote (let ((x ((unquote (cadr a)) (unquote (cadr e))))) (lambda () ((unquote (cddr a)) x))))))) (else (quasiquote (let ((x (unquote (cadr e)))) (lambda () ((unquote (car e)) x)))))))) (get-c---rs (quote ((caar car . car) (cadr cdr . car) (cdar car . cdr) (cddr cdr . cdr) (caaar caar . car) (caadr cadr . car) (cadar cdar . car) (caddr cddr . car) (cdaar caar . cdr) (cdadr cadr . cdr) (cddar cdar . cdr) (cdddr cddr . cdr) (caaaar caaar . car) (caaadr caadr . car) (caadar cadar . car) (caaddr caddr . car) (cadaar cdaar . car) (cadadr cdadr . car) (caddar cddar . car) (cadddr cdddr . car) (cdaaar caaar . cdr) (cdaadr caadr . cdr) (cdadar cadar . cdr) (cdaddr caddr . cdr) (cddaar cdaar . cdr) (cddadr cdadr . cdr) (cdddar cddar . cdr) (cddddr cdddr . cdr)))) (symbol-append (lambda l (string->symbol (apply string-append (map (lambda (x) (cond ((symbol? x) (symbol->string x)) ((number? x) (number->string x)) (else x))) l))))) (rac (lambda (l) (if (null? (cdr l)) (car l) (rac (cdr l))))) (rdc (lambda (l) (if (null? (cdr l)) (quote ()) (cons (car l) (rdc (cdr l))))))) (list genmatch genletrec gendefine pattern-var?))) +(defmacro match args (cond ((and (list? args) (<= 1 (length args)) (match:andmap (lambda (y) (and (list? y) (<= 2 (length y)))) (cdr args))) (let* ((exp (car args)) (clauses (cdr args)) (e (if (symbol? exp) exp (gensym)))) (if (symbol? exp) ((car match:expanders) e clauses (quasiquote (match (unquote-splicing args)))) (quasiquote (let (((unquote e) (unquote exp))) (unquote ((car match:expanders) e clauses (quasiquote (match (unquote-splicing args)))))))))) (else (match:syntax-err (quasiquote (match (unquote-splicing args))) "syntax error in")))) +(defmacro match-lambda args (if (and (list? args) (match:andmap (lambda (g195) (if (and (pair? g195) (list? (cdr g195))) (pair? (cdr g195)) #f)) args)) ((lambda () (let ((e (gensym))) (quasiquote (lambda ((unquote e)) (match (unquote e) (unquote-splicing args))))))) ((lambda () (match:syntax-err (quasiquote (match-lambda (unquote-splicing args))) "syntax error in"))))) +(defmacro match-lambda* args (if (and (list? args) (match:andmap (lambda (g203) (if (and (pair? g203) (list? (cdr g203))) (pair? (cdr g203)) #f)) args)) ((lambda () (let ((e (gensym))) (quasiquote (lambda (unquote e) (match (unquote e) (unquote-splicing args))))))) ((lambda () (match:syntax-err (quasiquote (match-lambda* (unquote-splicing args))) "syntax error in"))))) +(defmacro match-let args (let ((g227 (lambda (pat exp body) (quasiquote (match (unquote exp) ((unquote pat) (unquote-splicing body)))))) (g223 (lambda (pat exp body) (let ((g (map (lambda (x) (gensym)) pat)) (vpattern (list->vector pat))) (quasiquote (let (unquote (map list g exp)) (match (vector (unquote-splicing g)) ((unquote vpattern) (unquote-splicing body)))))))) (g215 (lambda () (match:syntax-err (quasiquote (match-let (unquote-splicing args))) "syntax error in"))) (g214 (lambda (p1 e1 p2 e2 body) (let ((g1 (gensym)) (g2 (gensym))) (quasiquote (let (((unquote g1) (unquote e1)) ((unquote g2) (unquote e2))) (match (cons (unquote g1) (unquote g2)) (((unquote p1) unquote p2) (unquote-splicing body)))))))) (g205 (cadddr match:expanders))) (if (pair? args) (if (symbol? (car args)) (if (and (pair? (cdr args)) (list? (cadr args))) (let g230 ((g231 (cadr args)) (g229 (quote ())) (g228 (quote ()))) (if (null? g231) (if (and (list? (cddr args)) (pair? (cddr args))) ((lambda (name pat exp body) (if (match:andmap (cadddr match:expanders) pat) (quasiquote (let (unquote-splicing args))) (quasiquote (letrec (((unquote name) (match-lambda* ((unquote pat) (unquote-splicing body))))) ((unquote name) (unquote-splicing exp)))))) (car args) (reverse g228) (reverse g229) (cddr args)) (g215)) (if (and (pair? (car g231)) (pair? (cdar g231)) (null? (cddar g231))) (g230 (cdr g231) (cons (cadar g231) g229) (cons (caar g231) g228)) (g215)))) (g215)) (if (list? (car args)) (if (match:andmap (lambda (g236) (if (and (pair? g236) (g205 (car g236)) (pair? (cdr g236))) (null? (cddr g236)) #f)) (car args)) (if (and (list? (cdr args)) (pair? (cdr args))) ((lambda () (quasiquote (let (unquote-splicing args))))) (let g218 ((g219 (car args)) (g217 (quote ())) (g216 (quote ()))) (if (null? g219) (g215) (if (and (pair? (car g219)) (pair? (cdar g219)) (null? (cddar g219))) (g218 (cdr g219) (cons (cadar g219) g217) (cons (caar g219) g216)) (g215))))) (if (and (pair? (car args)) (pair? (caar args)) (pair? (cdaar args)) (null? (cddaar args))) (if (null? (cdar args)) (if (and (list? (cdr args)) (pair? (cdr args))) (g227 (caaar args) (cadaar args) (cdr args)) (let g218 ((g219 (car args)) (g217 (quote ())) (g216 (quote ()))) (if (null? g219) (g215) (if (and (pair? (car g219)) (pair? (cdar g219)) (null? (cddar g219))) (g218 (cdr g219) (cons (cadar g219) g217) (cons (caar g219) g216)) (g215))))) (if (and (pair? (cdar args)) (pair? (cadar args)) (pair? (cdadar args)) (null? (cdr (cdadar args))) (null? (cddar args))) (if (and (list? (cdr args)) (pair? (cdr args))) (g214 (caaar args) (cadaar args) (caadar args) (car (cdadar args)) (cdr args)) (let g218 ((g219 (car args)) (g217 (quote ())) (g216 (quote ()))) (if (null? g219) (g215) (if (and (pair? (car g219)) (pair? (cdar g219)) (null? (cddar g219))) (g218 (cdr g219) (cons (cadar g219) g217) (cons (caar g219) g216)) (g215))))) (let g218 ((g219 (car args)) (g217 (quote ())) (g216 (quote ()))) (if (null? g219) (if (and (list? (cdr args)) (pair? (cdr args))) (g223 (reverse g216) (reverse g217) (cdr args)) (g215)) (if (and (pair? (car g219)) (pair? (cdar g219)) (null? (cddar g219))) (g218 (cdr g219) (cons (cadar g219) g217) (cons (caar g219) g216)) (g215)))))) (let g218 ((g219 (car args)) (g217 (quote ())) (g216 (quote ()))) (if (null? g219) (if (and (list? (cdr args)) (pair? (cdr args))) (g223 (reverse g216) (reverse g217) (cdr args)) (g215)) (if (and (pair? (car g219)) (pair? (cdar g219)) (null? (cddar g219))) (g218 (cdr g219) (cons (cadar g219) g217) (cons (caar g219) g216)) (g215)))))) (if (pair? (car args)) (if (and (pair? (caar args)) (pair? (cdaar args)) (null? (cddaar args))) (if (null? (cdar args)) (if (and (list? (cdr args)) (pair? (cdr args))) (g227 (caaar args) (cadaar args) (cdr args)) (let g218 ((g219 (car args)) (g217 (quote ())) (g216 (quote ()))) (if (null? g219) (g215) (if (and (pair? (car g219)) (pair? (cdar g219)) (null? (cddar g219))) (g218 (cdr g219) (cons (cadar g219) g217) (cons (caar g219) g216)) (g215))))) (if (and (pair? (cdar args)) (pair? (cadar args)) (pair? (cdadar args)) (null? (cdr (cdadar args))) (null? (cddar args))) (if (and (list? (cdr args)) (pair? (cdr args))) (g214 (caaar args) (cadaar args) (caadar args) (car (cdadar args)) (cdr args)) (let g218 ((g219 (car args)) (g217 (quote ())) (g216 (quote ()))) (if (null? g219) (g215) (if (and (pair? (car g219)) (pair? (cdar g219)) (null? (cddar g219))) (g218 (cdr g219) (cons (cadar g219) g217) (cons (caar g219) g216)) (g215))))) (let g218 ((g219 (car args)) (g217 (quote ())) (g216 (quote ()))) (if (null? g219) (if (and (list? (cdr args)) (pair? (cdr args))) (g223 (reverse g216) (reverse g217) (cdr args)) (g215)) (if (and (pair? (car g219)) (pair? (cdar g219)) (null? (cddar g219))) (g218 (cdr g219) (cons (cadar g219) g217) (cons (caar g219) g216)) (g215)))))) (let g218 ((g219 (car args)) (g217 (quote ())) (g216 (quote ()))) (if (null? g219) (if (and (list? (cdr args)) (pair? (cdr args))) (g223 (reverse g216) (reverse g217) (cdr args)) (g215)) (if (and (pair? (car g219)) (pair? (cdar g219)) (null? (cddar g219))) (g218 (cdr g219) (cons (cadar g219) g217) (cons (caar g219) g216)) (g215))))) (g215)))) (g215)))) +(defmacro match-let* args (let ((g245 (lambda () (match:syntax-err (quasiquote (match-let* (unquote-splicing args))) "syntax error in")))) (if (pair? args) (if (null? (car args)) (if (and (list? (cdr args)) (pair? (cdr args))) ((lambda (body) (quasiquote (let* (unquote-splicing args)))) (cdr args)) (g245)) (if (and (pair? (car args)) (pair? (caar args)) (pair? (cdaar args)) (null? (cddaar args)) (list? (cdar args)) (list? (cdr args)) (pair? (cdr args))) ((lambda (pat exp rest body) (if ((cadddr match:expanders) pat) (quasiquote (let (((unquote pat) (unquote exp))) (match-let* (unquote rest) (unquote-splicing body)))) (quasiquote (match (unquote exp) ((unquote pat) (match-let* (unquote rest) (unquote-splicing body))))))) (caaar args) (cadaar args) (cdar args) (cdr args)) (g245))) (g245)))) +(defmacro match-letrec args (let ((g269 (cadddr match:expanders)) (g268 (lambda (p1 e1 p2 e2 body) (quasiquote (match-letrec ((((unquote p1) unquote p2) (cons (unquote e1) (unquote e2)))) (unquote-splicing body))))) (g264 (lambda () (match:syntax-err (quasiquote (match-letrec (unquote-splicing args))) "syntax error in"))) (g263 (lambda (pat exp body) (quasiquote (match-letrec (((unquote (list->vector pat)) (vector (unquote-splicing exp)))) (unquote-splicing body))))) (g255 (lambda (pat exp body) ((cadr match:expanders) pat exp body (quasiquote (match-letrec (((unquote pat) (unquote exp))) (unquote-splicing body))))))) (if (pair? args) (if (list? (car args)) (if (match:andmap (lambda (g275) (if (and (pair? g275) (g269 (car g275)) (pair? (cdr g275))) (null? (cddr g275)) #f)) (car args)) (if (and (list? (cdr args)) (pair? (cdr args))) ((lambda () (quasiquote (letrec (unquote-splicing args))))) (let g258 ((g259 (car args)) (g257 (quote ())) (g256 (quote ()))) (if (null? g259) (g264) (if (and (pair? (car g259)) (pair? (cdar g259)) (null? (cddar g259))) (g258 (cdr g259) (cons (cadar g259) g257) (cons (caar g259) g256)) (g264))))) (if (and (pair? (car args)) (pair? (caar args)) (pair? (cdaar args)) (null? (cddaar args))) (if (null? (cdar args)) (if (and (list? (cdr args)) (pair? (cdr args))) (g255 (caaar args) (cadaar args) (cdr args)) (let g258 ((g259 (car args)) (g257 (quote ())) (g256 (quote ()))) (if (null? g259) (g264) (if (and (pair? (car g259)) (pair? (cdar g259)) (null? (cddar g259))) (g258 (cdr g259) (cons (cadar g259) g257) (cons (caar g259) g256)) (g264))))) (if (and (pair? (cdar args)) (pair? (cadar args)) (pair? (cdadar args)) (null? (cdr (cdadar args))) (null? (cddar args))) (if (and (list? (cdr args)) (pair? (cdr args))) (g268 (caaar args) (cadaar args) (caadar args) (car (cdadar args)) (cdr args)) (let g258 ((g259 (car args)) (g257 (quote ())) (g256 (quote ()))) (if (null? g259) (g264) (if (and (pair? (car g259)) (pair? (cdar g259)) (null? (cddar g259))) (g258 (cdr g259) (cons (cadar g259) g257) (cons (caar g259) g256)) (g264))))) (let g258 ((g259 (car args)) (g257 (quote ())) (g256 (quote ()))) (if (null? g259) (if (and (list? (cdr args)) (pair? (cdr args))) (g263 (reverse g256) (reverse g257) (cdr args)) (g264)) (if (and (pair? (car g259)) (pair? (cdar g259)) (null? (cddar g259))) (g258 (cdr g259) (cons (cadar g259) g257) (cons (caar g259) g256)) (g264)))))) (let g258 ((g259 (car args)) (g257 (quote ())) (g256 (quote ()))) (if (null? g259) (if (and (list? (cdr args)) (pair? (cdr args))) (g263 (reverse g256) (reverse g257) (cdr args)) (g264)) (if (and (pair? (car g259)) (pair? (cdar g259)) (null? (cddar g259))) (g258 (cdr g259) (cons (cadar g259) g257) (cons (caar g259) g256)) (g264)))))) (if (pair? (car args)) (if (and (pair? (caar args)) (pair? (cdaar args)) (null? (cddaar args))) (if (null? (cdar args)) (if (and (list? (cdr args)) (pair? (cdr args))) (g255 (caaar args) (cadaar args) (cdr args)) (let g258 ((g259 (car args)) (g257 (quote ())) (g256 (quote ()))) (if (null? g259) (g264) (if (and (pair? (car g259)) (pair? (cdar g259)) (null? (cddar g259))) (g258 (cdr g259) (cons (cadar g259) g257) (cons (caar g259) g256)) (g264))))) (if (and (pair? (cdar args)) (pair? (cadar args)) (pair? (cdadar args)) (null? (cdr (cdadar args))) (null? (cddar args))) (if (and (list? (cdr args)) (pair? (cdr args))) (g268 (caaar args) (cadaar args) (caadar args) (car (cdadar args)) (cdr args)) (let g258 ((g259 (car args)) (g257 (quote ())) (g256 (quote ()))) (if (null? g259) (g264) (if (and (pair? (car g259)) (pair? (cdar g259)) (null? (cddar g259))) (g258 (cdr g259) (cons (cadar g259) g257) (cons (caar g259) g256)) (g264))))) (let g258 ((g259 (car args)) (g257 (quote ())) (g256 (quote ()))) (if (null? g259) (if (and (list? (cdr args)) (pair? (cdr args))) (g263 (reverse g256) (reverse g257) (cdr args)) (g264)) (if (and (pair? (car g259)) (pair? (cdar g259)) (null? (cddar g259))) (g258 (cdr g259) (cons (cadar g259) g257) (cons (caar g259) g256)) (g264)))))) (let g258 ((g259 (car args)) (g257 (quote ())) (g256 (quote ()))) (if (null? g259) (if (and (list? (cdr args)) (pair? (cdr args))) (g263 (reverse g256) (reverse g257) (cdr args)) (g264)) (if (and (pair? (car g259)) (pair? (cdar g259)) (null? (cddar g259))) (g258 (cdr g259) (cons (cadar g259) g257) (cons (caar g259) g256)) (g264))))) (g264))) (g264)))) +(defmacro match-define args (let ((g279 (cadddr match:expanders)) (g278 (lambda () (match:syntax-err (quasiquote (match-define (unquote-splicing args))) "syntax error in")))) (if (pair? args) (if (g279 (car args)) (if (and (pair? (cdr args)) (null? (cddr args))) ((lambda () (quasiquote (begin (define (unquote-splicing args)))))) (g278)) (if (and (pair? (cdr args)) (null? (cddr args))) ((lambda (pat exp) ((caddr match:expanders) pat exp (quasiquote (match-define (unquote-splicing args))))) (car args) (cadr args)) (g278))) (g278)))) +(define match:runtime-structures #f) +(define match:set-runtime-structures (lambda (v) (set! match:runtime-structures v))) +(define match:primitive-vector? vector?) +(defmacro defstruct args (let ((field? (lambda (x) (if (symbol? x) ((lambda () #t)) (if (and (pair? x) (symbol? (car x)) (pair? (cdr x)) (symbol? (cadr x)) (null? (cddr x))) ((lambda () #t)) ((lambda () #f)))))) (selector-name (lambda (x) (if (symbol? x) ((lambda () x)) (if (and (pair? x) (symbol? (car x)) (pair? (cdr x)) (null? (cddr x))) ((lambda (s) s) (car x)) (match:error x))))) (mutator-name (lambda (x) (if (symbol? x) ((lambda () #f)) (if (and (pair? x) (pair? (cdr x)) (symbol? (cadr x)) (null? (cddr x))) ((lambda (s) s) (cadr x)) (match:error x))))) (filter-map-with-index (lambda (f l) (letrec ((mapi (lambda (l i) (cond ((null? l) (quote ())) ((f (car l) i) => (lambda (x) (cons x (mapi (cdr l) (+ 1 i))))) (else (mapi (cdr l) (+ 1 i))))))) (mapi l 1))))) (let ((g296 (lambda () (match:syntax-err (quasiquote ((unquote defstruct) (unquote-splicing args))) "syntax error in")))) (if (and (pair? args) (symbol? (car args)) (pair? (cdr args)) (symbol? (cadr args)) (pair? (cddr args)) (symbol? (caddr args)) (list? (cdddr args))) (let g298 ((g299 (cdddr args)) (g297 (quote ()))) (if (null? g299) ((lambda (name constructor predicate fields) (let* ((selectors (map selector-name fields)) (mutators (map mutator-name fields)) (tag (if match:runtime-structures (gensym) (quasiquote (quote (unquote (match:make-structure-tag name)))))) (vectorP (cond ((eq? match:structure-control (quote disjoint)) (quote match:primitive-vector?)) ((eq? match:structure-control (quote vector)) (quote vector?))))) (cond ((eq? match:structure-control (quote disjoint)) (if (eq? vector? match:primitive-vector?) (set! vector? (lambda (v) (and (match:primitive-vector? v) (or (zero? (vector-length v)) (not (symbol? (vector-ref v 0))) (not (match:structure? (vector-ref v 0)))))))) (if (not (memq predicate match:disjoint-predicates)) (set! match:disjoint-predicates (cons predicate match:disjoint-predicates)))) ((eq? match:structure-control (quote vector)) (if (not (memq predicate match:vector-structures)) (set! match:vector-structures (cons predicate match:vector-structures)))) (else (match:syntax-err (quote (vector disjoint)) "invalid value for match:structure-control, legal values are"))) (quasiquote (begin (unquote-splicing (if match:runtime-structures (quasiquote ((define (unquote tag) (match:make-structure-tag (quote (unquote name)))))) (quote ()))) (define (unquote constructor) (lambda (unquote selectors) (vector (unquote tag) (unquote-splicing selectors)))) (define (unquote predicate) (lambda (obj) (and ((unquote vectorP) obj) (= (vector-length obj) (unquote (+ 1 (length selectors)))) (eq? (vector-ref obj 0) (unquote tag))))) (unquote-splicing (filter-map-with-index (lambda (n i) (quasiquote (define (unquote n) (lambda (obj) (vector-ref obj (unquote i)))))) selectors)) (unquote-splicing (filter-map-with-index (lambda (n i) (and n (quasiquote (define (unquote n) (lambda (obj newval) (vector-set! obj (unquote i) newval)))))) mutators)))))) (car args) (cadr args) (caddr args) (reverse g297)) (if (field? (car g299)) (g298 (cdr g299) (cons (car g299) g297)) (g296)))) (g296))))) +(defmacro define-structure args (let ((g311 (lambda () (match:syntax-err (quasiquote (define-structure (unquote-splicing args))) "syntax error in")))) (if (and (pair? args) (pair? (car args)) (list? (cdar args))) (if (null? (cdr args)) ((lambda (name id1) (quasiquote (define-structure ((unquote name) (unquote-splicing id1)) ()))) (caar args) (cdar args)) (if (and (pair? (cdr args)) (list? (cadr args))) (let g308 ((g309 (cadr args)) (g307 (quote ())) (g306 (quote ()))) (if (null? g309) (if (null? (cddr args)) ((lambda (name id1 id2 val) (let ((mk-id (lambda (id) (if (and (pair? id) (equal? (car id) (quote @)) (pair? (cdr id)) (symbol? (cadr id)) (null? (cddr id))) ((lambda (x) x) (cadr id)) ((lambda () (quasiquote (! (unquote id))))))))) (quasiquote (define-const-structure ((unquote name) (unquote-splicing (map mk-id id1))) (unquote (map (lambda (id v) (quasiquote ((unquote (mk-id id)) (unquote v)))) id2 val)))))) (caar args) (cdar args) (reverse g306) (reverse g307)) (g311)) (if (and (pair? (car g309)) (pair? (cdar g309)) (null? (cddar g309))) (g308 (cdr g309) (cons (cadar g309) g307) (cons (caar g309) g306)) (g311)))) (g311))) (g311)))) +(defmacro define-const-structure args (let ((field? (lambda (id) (if (symbol? id) ((lambda () #t)) (if (and (pair? id) (equal? (car id) (quote !)) (pair? (cdr id)) (symbol? (cadr id)) (null? (cddr id))) ((lambda () #t)) ((lambda () #f)))))) (field-name (lambda (x) (if (symbol? x) x (cadr x)))) (has-mutator? (lambda (x) (not (symbol? x)))) (filter-map-with-index (lambda (f l) (letrec ((mapi (lambda (l i) (cond ((null? l) (quote ())) ((f (car l) i) => (lambda (x) (cons x (mapi (cdr l) (+ 1 i))))) (else (mapi (cdr l) (+ 1 i))))))) (mapi l 1)))) (symbol-append (lambda l (string->symbol (apply string-append (map (lambda (x) (cond ((symbol? x) (symbol->string x)) ((number? x) (number->string x)) (else x))) l)))))) (let ((g335 (lambda () (match:syntax-err (quasiquote (define-const-structure (unquote-splicing args))) "syntax error in")))) (if (and (pair? args) (pair? (car args)) (list? (cdar args))) (if (null? (cdr args)) ((lambda (name id1) (quasiquote (define-const-structure ((unquote name) (unquote-splicing id1)) ()))) (caar args) (cdar args)) (if (symbol? (caar args)) (let g328 ((g329 (cdar args)) (g327 (quote ()))) (if (null? g329) (if (and (pair? (cdr args)) (list? (cadr args))) (let g332 ((g333 (cadr args)) (g331 (quote ())) (g330 (quote ()))) (if (null? g333) (if (null? (cddr args)) ((lambda (name id1 id2 val) (let* ((id1id2 (append id1 id2)) (raw-constructor (symbol-append (quote make-raw-) name)) (constructor (symbol-append (quote make-) name)) (predicate (symbol-append name (quote ?)))) (quasiquote (begin ((unquote defstruct) (unquote name) (unquote raw-constructor) (unquote predicate) (unquote-splicing (filter-map-with-index (lambda (arg i) (if (has-mutator? arg) (quasiquote ((unquote (symbol-append name (quote -) i)) (unquote (symbol-append (quote set-) name (quote -) i (quote !))))) (symbol-append name (quote -) i))) id1id2))) (unquote (if (null? id2) (quasiquote (define (unquote constructor) (unquote raw-constructor))) (let* ((make-fresh (lambda (x) (if (eq? (quote _) x) (gensym) x))) (names1 (map make-fresh (map field-name id1))) (names2 (map make-fresh (map field-name id2)))) (quasiquote (define (unquote constructor) (lambda (unquote names1) (let* (unquote (map list names2 val)) ((unquote raw-constructor) (unquote-splicing names1) (unquote-splicing names2))))))))) (unquote-splicing (filter-map-with-index (lambda (field i) (if (eq? (field-name field) (quote _)) #f (quasiquote (define (unquote (symbol-append name (quote -) (field-name field))) (unquote (symbol-append name (quote -) i)))))) id1id2)) (unquote-splicing (filter-map-with-index (lambda (field i) (if (or (eq? (field-name field) (quote _)) (not (has-mutator? field))) #f (quasiquote (define (unquote (symbol-append (quote set-) name (quote -) (field-name field) (quote !))) (unquote (symbol-append (quote set-) name (quote -) i (quote !))))))) id1id2)))))) (caar args) (reverse g327) (reverse g330) (reverse g331)) (g335)) (if (and (pair? (car g333)) (field? (caar g333)) (pair? (cdar g333)) (null? (cddar g333))) (g332 (cdr g333) (cons (cadar g333) g331) (cons (caar g333) g330)) (g335)))) (g335)) (if (field? (car g329)) (g328 (cdr g329) (cons (car g329) g327)) (g335)))) (g335))) (g335))))) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/networking.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/networking.scm new file mode 100755 index 0000000000000000000000000000000000000000..c0218821ff5d5329255bcd05ffdf92f50cf71ad9 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/networking.scm @@ -0,0 +1,84 @@ +;;; installed-scm-file + +;;;; Copyright (C) 1999, 2005, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; + +(define (gethostbyaddr addr) (gethost addr)) +(define (gethostbyname name) (gethost name)) + +(define (getnetbyaddr addr) (getnet addr)) +(define (getnetbyname name) (getnet name)) + +(define (getprotobyname name) (getproto name)) +(define (getprotobynumber addr) (getproto addr)) + +(define (getservbyname name proto) (getserv name proto)) +(define (getservbyport port proto) (getserv port proto)) + +(define (sethostent . stayopen) + (if (pair? stayopen) + (sethost (car stayopen)) + (sethost #f))) +(define (setnetent . stayopen) + (if (pair? stayopen) + (setnet (car stayopen)) + (setnet #f))) +(define (setprotoent . stayopen) + (if (pair? stayopen) + (setproto (car stayopen)) + (setproto #f))) +(define (setservent . stayopen) + (if (pair? stayopen) + (setserv (car stayopen)) + (setserv #f))) + +(define (gethostent) (gethost)) +(define (getnetent) (getnet)) +(define (getprotoent) (getproto)) +(define (getservent) (getserv)) + +(define (endhostent) (sethost)) +(define (endnetent) (setnet)) +(define (endprotoent) (setproto)) +(define (endservent) (setserv)) + +(define (hostent:name obj) (vector-ref obj 0)) +(define (hostent:aliases obj) (vector-ref obj 1)) +(define (hostent:addrtype obj) (vector-ref obj 2)) +(define (hostent:length obj) (vector-ref obj 3)) +(define (hostent:addr-list obj) (vector-ref obj 4)) + +(define (netent:name obj) (vector-ref obj 0)) +(define (netent:aliases obj) (vector-ref obj 1)) +(define (netent:addrtype obj) (vector-ref obj 2)) +(define (netent:net obj) (vector-ref obj 3)) + +(define (protoent:name obj) (vector-ref obj 0)) +(define (protoent:aliases obj) (vector-ref obj 1)) +(define (protoent:proto obj) (vector-ref obj 2)) + +(define (servent:name obj) (vector-ref obj 0)) +(define (servent:aliases obj) (vector-ref obj 1)) +(define (servent:port obj) (vector-ref obj 2)) +(define (servent:proto obj) (vector-ref obj 3)) + +(define (sockaddr:fam obj) (vector-ref obj 0)) +(define (sockaddr:path obj) (vector-ref obj 1)) +(define (sockaddr:addr obj) (vector-ref obj 1)) +(define (sockaddr:port obj) (vector-ref obj 2)) +(define (sockaddr:flowinfo obj) (vector-ref obj 3)) +(define (sockaddr:scopeid obj) (vector-ref obj 4)) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/null.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/null.scm new file mode 100755 index 0000000000000000000000000000000000000000..b9212e605da882852eb347343a6eb1bc30d357c0 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/null.scm @@ -0,0 +1,35 @@ +;;;; Copyright (C) 2000, 2001, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; + +;;;; The null environment - only syntactic bindings + +(define-module (ice-9 null) + :use-module (ice-9 syncase) + :re-export-syntax (define quote lambda if set! + + cond case and or + + let let* letrec + + begin do + + delay + + quasiquote + + define-syntax + let-syntax letrec-syntax)) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/occam-channel.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/occam-channel.scm new file mode 100755 index 0000000000000000000000000000000000000000..e28f73d3b7a1f62eed223b44dd1e988cf1af31e2 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/occam-channel.scm @@ -0,0 +1,262 @@ +;;;; Occam-like channels + +;;; Copyright (C) 2003, 2006 Free Software Foundation, Inc. +;;; +;; This library is free software; you can redistribute it and/or +;; modify it under the terms of the GNU Lesser General Public +;; License as published by the Free Software Foundation; either +;; version 2.1 of the License, or (at your option) any later version. +;; +;; This library is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; Lesser General Public License for more details. +;; +;; You should have received a copy of the GNU Lesser General Public +;; License along with this library; if not, write to the Free Software +;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +(define-module (ice-9 occam-channel) + #:use-syntax (ice-9 syncase) + #:use-module (oop goops) + #:use-module (ice-9 threads) + #:export-syntax (alt + ;; macro use: + oc:lock oc:unlock oc:consequence + oc:immediate-dispatch oc:late-dispatch oc:first-channel + oc:set-handshake-channel oc:unset-handshake-channel) + #:export (make-channel + ? + ! + make-timer + ;; macro use: + handshake-channel mutex + sender-waiting? + immediate-receive late-receive + ) + ) + +(define no-data '(no-data)) +(define receiver-waiting '(receiver-waiting)) + +(define-class ()) + +(define-class () + (handshake-channel #:accessor handshake-channel) + (data #:accessor data #:init-value no-data) + (cv #:accessor cv #:init-form (make-condition-variable)) + (mutex #:accessor mutex #:init-form (make-mutex))) + +(define-method (initialize (ch ) initargs) + (next-method) + (set! (handshake-channel ch) ch)) + +(define-method (make-channel) + (make )) + +(define-method (sender-waiting? (ch )) + (not (eq? (data ch) no-data))) + +(define-method (receiver-waiting? (ch )) + (eq? (data ch) receiver-waiting)) + +(define-method (immediate-receive (ch )) + (signal-condition-variable (cv ch)) + (let ((res (data ch))) + (set! (data ch) no-data) + res)) + +(define-method (late-receive (ch )) + (let ((res (data ch))) + (set! (data ch) no-data) + res)) + +(define-method (? (ch )) + (lock-mutex (mutex ch)) + (let ((res (cond ((receiver-waiting? ch) + (unlock-mutex (mutex ch)) + (scm-error 'misc-error '? + "another process is already receiving on ~A" + (list ch) #f)) + ((sender-waiting? ch) + (immediate-receive ch)) + (else + (set! (data ch) receiver-waiting) + (wait-condition-variable (cv ch) (mutex ch)) + (late-receive ch))))) + (unlock-mutex (mutex ch)) + res)) + +(define-method (! (ch )) + (! ch *unspecified*)) + +(define-method (! (ch ) (x )) + (lock-mutex (mutex (handshake-channel ch))) + (cond ((receiver-waiting? ch) + (set! (data ch) x) + (signal-condition-variable (cv (handshake-channel ch)))) + ((sender-waiting? ch) + (unlock-mutex (mutex (handshake-channel ch))) + (scm-error 'misc-error '! "another process is already sending on ~A" + (list ch) #f)) + (else + (set! (data ch) x) + (wait-condition-variable (cv ch) (mutex ch)))) + (unlock-mutex (mutex (handshake-channel ch)))) + +;;; Add protocols? + +(define-class () + (port #:accessor port #:init-keyword #:port)) + +(define-method (make-channel (port )) + (make #:port port)) + +(define-method (? (ch )) + (read (port ch))) + +(define-method (! (ch )) + (write (port ch))) + +(define-class ()) + +(define the-timer (make )) + +(define timer-cv (make-condition-variable)) +(define timer-mutex (make-mutex)) + +(define (make-timer) + the-timer) + +(define (timeofday->us t) + (+ (* 1000000 (car t)) (cdr t))) + +(define (us->timeofday n) + (cons (quotient n 1000000) + (remainder n 1000000))) + +(define-method (? (ch )) + (timeofday->us (gettimeofday))) + +(define-method (? (ch ) (t )) + (lock-mutex timer-mutex) + (wait-condition-variable timer-cv timer-mutex (us->timeofday t)) + (unlock-mutex timer-mutex)) + +;;; (alt CLAUSE ...) +;;; +;;; CLAUSE ::= ((? CH) FORM ...) +;;; | (EXP (? CH) FORM ...) +;;; | (EXP FORM ...) +;;; +;;; where FORM ... can be => (lambda (x) ...) +;;; +;;; *fixme* Currently only handles :s +;;; + +(define-syntax oc:lock + (syntax-rules (?) + ((_ ((? ch) form ...)) (lock-mutex (mutex ch))) + ((_ (exp (? ch) form ...)) (lock-mutex (mutex ch))) + ((_ (exp form ...)) #f))) + +(define-syntax oc:unlock + (syntax-rules (?) + ((_ ((? ch) form ...)) (unlock-mutex (mutex ch))) + ((_ (exp (? ch) form ...)) (unlock-mutex (mutex ch))) + ((_ (exp form ...)) #f))) + +(define-syntax oc:consequence + (syntax-rules (=>) + ((_ data) data) + ((_ data => (lambda (x) e1 e2 ...)) + (let ((x data)) e1 e2 ...)) + ((_ data e1 e2 ...) + (begin data e1 e2 ...)))) + +(define-syntax oc:immediate-dispatch + (syntax-rules (?) + ((_ ((? ch) e1 ...)) + ((sender-waiting? ch) + (oc:consequence (immediate-receive ch) e1 ...))) + ((_ (exp (? ch) e1 ...)) + ((and exp (sender-waiting? ch)) + (oc:consequence (immediate-receive ch) e1 ...))) + ((_ (exp e1 ...)) + (exp e1 ...)))) + +(define-syntax oc:late-dispatch + (syntax-rules (?) + ((_ ((? ch) e1 ...)) + ((sender-waiting? ch) + (oc:consequence (late-receive ch) e1 ...))) + ((_ (exp (? ch) e1 ...)) + ((and exp (sender-waiting? ch)) + (oc:consequence (late-receive ch) e1 ...))) + ((_ (exp e1 ...)) + (#f)))) + +(define-syntax oc:first-channel + (syntax-rules (?) + ((_ ((? ch) e1 ...) c2 ...) + ch) + ((_ (exp (? ch) e1 ...) c2 ...) + ch) + ((_ c1 c2 ...) + (first-channel c2 ...)))) + +(define-syntax oc:set-handshake-channel + (syntax-rules (?) + ((_ ((? ch) e1 ...) handshake) + (set! (handshake-channel ch) handshake)) + ((_ (exp (? ch) e1 ...) handshake) + (and exp (set! (handshake-channel ch) handshake))) + ((_ (exp e1 ...) handshake) + #f))) + +(define-syntax oc:unset-handshake-channel + (syntax-rules (?) + ((_ ((? ch) e1 ...)) + (set! (handshake-channel ch) ch)) + ((_ (exp (? ch) e1 ...)) + (and exp (set! (handshake-channel ch) ch))) + ((_ (exp e1 ...)) + #f))) + +(define-syntax alt + (lambda (x) + (define (else-clause? x) + (syntax-case x (else) + ((_) #f) + ((_ (else e1 e2 ...)) #t) + ((_ c1 c2 ...) (else-clause? (syntax (_ c2 ...)))))) + + (syntax-case x (else) + ((_ c1 c2 ...) + (else-clause? x) + (syntax (begin + (oc:lock c1) + (oc:lock c2) ... + (let ((res (cond (oc:immediate-dispatch c1) + (oc:immediate-dispatch c2) ...))) + (oc:unlock c1) + (oc:unlock c2) ... + res)))) + ((_ c1 c2 ...) + (syntax (begin + (oc:lock c1) + (oc:lock c2) ... + (let ((res (cond (oc:immediate-dispatch c1) + (oc:immediate-dispatch c2) ... + (else (let ((ch (oc:first-channel c1 c2 ...))) + (oc:set-handshake-channel c1 ch) + (oc:set-handshake-channel c2 ch) ... + (wait-condition-variable (cv ch) + (mutex ch)) + (oc:unset-handshake-channel c1) + (oc:unset-handshake-channel c2) ... + (cond (oc:late-dispatch c1) + (oc:late-dispatch c2) ...)))))) + (oc:unlock c1) + (oc:unlock c2) ... + res))))))) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/optargs.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/optargs.scm new file mode 100755 index 0000000000000000000000000000000000000000..99329c7502ebccb8f5006079d499b87901dff9bc --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/optargs.scm @@ -0,0 +1,425 @@ +;;;; optargs.scm -- support for optional arguments +;;;; +;;;; Copyright (C) 1997, 1998, 1999, 2001, 2002, 2004, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; +;;;; Contributed by Maciej Stachowiak + + + +;;; Commentary: + +;;; {Optional Arguments} +;;; +;;; The C interface for creating Guile procedures has a very handy +;;; "optional argument" feature. This module attempts to provide +;;; similar functionality for procedures defined in Scheme with +;;; a convenient and attractive syntax. +;;; +;;; exported macros are: +;;; let-optional +;;; let-optional* +;;; let-keywords +;;; let-keywords* +;;; lambda* +;;; define* +;;; define*-public +;;; defmacro* +;;; defmacro*-public +;;; +;;; +;;; Summary of the lambda* extended parameter list syntax (brackets +;;; are used to indicate grouping only): +;;; +;;; ext-param-list ::= [identifier]* [#:optional [ext-var-decl]+]? +;;; [#:key [ext-var-decl]+ [#:allow-other-keys]?]? +;;; [[#:rest identifier]|[. identifier]]? +;;; +;;; ext-var-decl ::= identifier | ( identifier expression ) +;;; +;;; The characters `*', `+' and `?' are not to be taken literally; they +;;; mean respectively, zero or more occurences, one or more occurences, +;;; and one or zero occurences. +;;; + +;;; Code: + +(define-module (ice-9 optargs) + :export-syntax (let-optional + let-optional* + let-keywords + let-keywords* + define* lambda* + define*-public + defmacro* + defmacro*-public)) + +;; let-optional rest-arg (binding ...) . body +;; let-optional* rest-arg (binding ...) . body +;; macros used to bind optional arguments +;; +;; These two macros give you an optional argument interface that is +;; very "Schemey" and introduces no fancy syntax. They are compatible +;; with the scsh macros of the same name, but are slightly +;; extended. Each of binding may be of one of the forms or +;; ( ). rest-arg should be the rest-argument of +;; the procedures these are used from. The items in rest-arg are +;; sequentially bound to the variable namess are given. When rest-arg +;; runs out, the remaining vars are bound either to the default values +;; or to `#f' if no default value was specified. rest-arg remains +;; bound to whatever may have been left of rest-arg. +;; + +(defmacro let-optional (REST-ARG BINDINGS . BODY) + (let-optional-template REST-ARG BINDINGS BODY 'let)) + +(defmacro let-optional* (REST-ARG BINDINGS . BODY) + (let-optional-template REST-ARG BINDINGS BODY 'let*)) + + + +;; let-keywords rest-arg allow-other-keys? (binding ...) . body +;; let-keywords* rest-arg allow-other-keys? (binding ...) . body +;; macros used to bind keyword arguments +;; +;; These macros pick out keyword arguments from rest-arg, but do not +;; modify it. This is consistent at least with Common Lisp, which +;; duplicates keyword args in the rest arg. More explanation of what +;; keyword arguments in a lambda list look like can be found below in +;; the documentation for lambda*. Bindings can have the same form as +;; for let-optional. If allow-other-keys? is false, an error will be +;; thrown if anything that looks like a keyword argument but does not +;; match a known keyword parameter will result in an error. +;; + + +(defmacro let-keywords (REST-ARG ALLOW-OTHER-KEYS? BINDINGS . BODY) + (let-keywords-template REST-ARG ALLOW-OTHER-KEYS? BINDINGS BODY 'let)) + +(defmacro let-keywords* (REST-ARG ALLOW-OTHER-KEYS? BINDINGS . BODY) + (let-keywords-template REST-ARG ALLOW-OTHER-KEYS? BINDINGS BODY 'let*)) + + +;; some utility procedures for implementing the various let-forms. + +(define (let-o-k-template REST-ARG BINDINGS BODY let-type proc) + (let ((bindings (map (lambda (x) + (if (list? x) + x + (list x #f))) + BINDINGS))) + `(,let-type ,(map proc bindings) ,@BODY))) + +(define (let-optional-template REST-ARG BINDINGS BODY let-type) + (if (null? BINDINGS) + `(let () ,@BODY) + (let-o-k-template REST-ARG BINDINGS BODY let-type + (lambda (optional) + `(,(car optional) + (cond + ((not (null? ,REST-ARG)) + (let ((result (car ,REST-ARG))) + ,(list 'set! REST-ARG + `(cdr ,REST-ARG)) + result)) + (else + ,(cadr optional)))))))) + +(define (let-keywords-template REST-ARG ALLOW-OTHER-KEYS? BINDINGS BODY let-type) + (if (null? BINDINGS) + `(let () ,@BODY) + (let* ((kb-list-gensym (gensym "kb:G")) + (bindfilter (lambda (key) + `(,(car key) + (cond + ((assq ',(car key) ,kb-list-gensym) + => cdr) + (else + ,(cadr key))))))) + `(let* ((ra->kbl ,rest-arg->keyword-binding-list) + (,kb-list-gensym (ra->kbl ,REST-ARG ',(map + (lambda (x) (symbol->keyword (if (pair? x) (car x) x))) + BINDINGS) + ,ALLOW-OTHER-KEYS?))) + ,(let-o-k-template REST-ARG BINDINGS BODY let-type bindfilter))))) + + +(define (rest-arg->keyword-binding-list rest-arg keywords allow-other-keys?) + (if (null? rest-arg) + '() + (let loop ((first (car rest-arg)) + (rest (cdr rest-arg)) + (accum '())) + (let ((next (lambda (a) + (if (null? (cdr rest)) + a + (loop (cadr rest) (cddr rest) a))))) + (if (keyword? first) + (cond + ((memq first keywords) + (if (null? rest) + (error "Keyword argument has no value.") + (next (cons (cons (keyword->symbol first) + (car rest)) accum)))) + ((not allow-other-keys?) + (error "Unknown keyword in arguments.")) + (else (if (null? rest) + accum + (next accum)))) + (if (null? rest) + accum + (loop (car rest) (cdr rest) accum))))))) + + +;; lambda* args . body +;; lambda extended for optional and keyword arguments +;; +;; lambda* creates a procedure that takes optional arguments. These +;; are specified by putting them inside brackets at the end of the +;; paramater list, but before any dotted rest argument. For example, +;; (lambda* (a b #:optional c d . e) '()) +;; creates a procedure with fixed arguments a and b, optional arguments c +;; and d, and rest argument e. If the optional arguments are omitted +;; in a call, the variables for them are bound to `#f'. +;; +;; lambda* can also take keyword arguments. For example, a procedure +;; defined like this: +;; (lambda* (#:key xyzzy larch) '()) +;; can be called with any of the argument lists (#:xyzzy 11) +;; (#:larch 13) (#:larch 42 #:xyzzy 19) (). Whichever arguments +;; are given as keywords are bound to values. +;; +;; Optional and keyword arguments can also be given default values +;; which they take on when they are not present in a call, by giving a +;; two-item list in place of an optional argument, for example in: +;; (lambda* (foo #:optional (bar 42) #:key (baz 73)) (list foo bar baz)) +;; foo is a fixed argument, bar is an optional argument with default +;; value 42, and baz is a keyword argument with default value 73. +;; Default value expressions are not evaluated unless they are needed +;; and until the procedure is called. +;; +;; lambda* now supports two more special parameter list keywords. +;; +;; lambda*-defined procedures now throw an error by default if a +;; keyword other than one of those specified is found in the actual +;; passed arguments. However, specifying #:allow-other-keys +;; immediately after the keyword argument declarations restores the +;; previous behavior of ignoring unknown keywords. lambda* also now +;; guarantees that if the same keyword is passed more than once, the +;; last one passed is the one that takes effect. For example, +;; ((lambda* (#:key (heads 0) (tails 0)) (display (list heads tails))) +;; #:heads 37 #:tails 42 #:heads 99) +;; would result in (99 47) being displayed. +;; +;; #:rest is also now provided as a synonym for the dotted syntax rest +;; argument. The argument lists (a . b) and (a #:rest b) are equivalent in +;; all respects to lambda*. This is provided for more similarity to DSSSL, +;; MIT-Scheme and Kawa among others, as well as for refugees from other +;; Lisp dialects. + + +(defmacro lambda* (ARGLIST . BODY) + (parse-arglist + ARGLIST + (lambda (non-optional-args optionals keys aok? rest-arg) + ;; Check for syntax errors. + (if (not (every? symbol? non-optional-args)) + (error "Syntax error in fixed argument declaration.")) + (if (not (every? ext-decl? optionals)) + (error "Syntax error in optional argument declaration.")) + (if (not (every? ext-decl? keys)) + (error "Syntax error in keyword argument declaration.")) + (if (not (or (symbol? rest-arg) (eq? #f rest-arg))) + (error "Syntax error in rest argument declaration.")) + ;; generate the code. + (let ((rest-gensym (or rest-arg (gensym "lambda*:G"))) + (lambda-gensym (gensym "lambda*:L"))) + (if (not (and (null? optionals) (null? keys))) + `(let ((,lambda-gensym + (lambda (,@non-optional-args . ,rest-gensym) + ;; Make sure that if the proc had a docstring, we put it + ;; here where it will be visible. + ,@(if (and (not (null? BODY)) + (string? (car BODY))) + (list (car BODY)) + '()) + (let-optional* + ,rest-gensym + ,optionals + (let-keywords* ,rest-gensym + ,aok? + ,keys + ,@(if (and (not rest-arg) (null? keys)) + `((if (not (null? ,rest-gensym)) + (error "Too many arguments."))) + '()) + (let () + ,@BODY)))))) + (set-procedure-property! ,lambda-gensym 'arglist + '(,non-optional-args + ,optionals + ,keys + ,aok? + ,rest-arg)) + ,lambda-gensym) + `(lambda (,@non-optional-args . ,(if rest-arg rest-arg '())) + ,@BODY)))))) + + +(define (every? pred lst) + (or (null? lst) + (and (pred (car lst)) + (every? pred (cdr lst))))) + +(define (ext-decl? obj) + (or (symbol? obj) + (and (list? obj) (= 2 (length obj)) (symbol? (car obj))))) + +;; XXX - not tail recursive +(define (improper-list-copy obj) + (if (pair? obj) + (cons (car obj) (improper-list-copy (cdr obj))) + obj)) + +(define (parse-arglist arglist cont) + (define (split-list-at val lst cont) + (cond + ((memq val lst) + => (lambda (pos) + (if (memq val (cdr pos)) + (error (with-output-to-string + (lambda () + (map display `(,val + " specified more than once in argument list."))))) + (cont (reverse (cdr (memq val (reverse lst)))) (cdr pos) #t)))) + (else (cont lst '() #f)))) + (define (parse-opt-and-fixed arglist keys aok? rest cont) + (split-list-at + #:optional arglist + (lambda (before after split?) + (if (and split? (null? after)) + (error "#:optional specified but no optional arguments declared.") + (cont before after keys aok? rest))))) + (define (parse-keys arglist rest cont) + (split-list-at + #:allow-other-keys arglist + (lambda (aok-before aok-after aok-split?) + (if (and aok-split? (not (null? aok-after))) + (error "#:allow-other-keys not at end of keyword argument declarations.") + (split-list-at + #:key aok-before + (lambda (key-before key-after key-split?) + (cond + ((and aok-split? (not key-split?)) + (error "#:allow-other-keys specified but no keyword arguments declared.")) + (key-split? + (cond + ((null? key-after) (error "#:key specified but no keyword arguments declared.")) + ((memq #:optional key-after) (error "#:optional arguments declared after #:key arguments.")) + (else (parse-opt-and-fixed key-before key-after aok-split? rest cont)))) + (else (parse-opt-and-fixed arglist '() #f rest cont))))))))) + (define (parse-rest arglist cont) + (cond + ((null? arglist) (cont '() '() '() #f #f)) + ((not (pair? arglist)) (cont '() '() '() #f arglist)) + ((not (list? arglist)) + (let* ((copy (improper-list-copy arglist)) + (lp (last-pair copy)) + (ra (cdr lp))) + (set-cdr! lp '()) + (if (memq #:rest copy) + (error "Cannot specify both #:rest and dotted rest argument.") + (parse-keys copy ra cont)))) + (else (split-list-at + #:rest arglist + (lambda (before after split?) + (if split? + (case (length after) + ((0) (error "#:rest not followed by argument.")) + ((1) (parse-keys before (car after) cont)) + (else (error "#:rest argument must be declared last."))) + (parse-keys before #f cont))))))) + + (parse-rest arglist cont)) + + + +;; define* args . body +;; define*-public args . body +;; define and define-public extended for optional and keyword arguments +;; +;; define* and define*-public support optional arguments with +;; a similar syntax to lambda*. They also support arbitrary-depth +;; currying, just like Guile's define. Some examples: +;; (define* (x y #:optional a (z 3) #:key w . u) (display (list y z u))) +;; defines a procedure x with a fixed argument y, an optional agument +;; a, another optional argument z with default value 3, a keyword argument w, +;; and a rest argument u. +;; (define-public* ((foo #:optional bar) #:optional baz) '()) +;; This illustrates currying. A procedure foo is defined, which, +;; when called with an optional argument bar, returns a procedure that +;; takes an optional argument baz. +;; +;; Of course, define*[-public] also supports #:rest and #:allow-other-keys +;; in the same way as lambda*. + +(defmacro define* (ARGLIST . BODY) + (define*-guts 'define ARGLIST BODY)) + +(defmacro define*-public (ARGLIST . BODY) + (define*-guts 'define-public ARGLIST BODY)) + +;; The guts of define* and define*-public. +(define (define*-guts DT ARGLIST BODY) + (define (nest-lambda*s arglists) + (if (null? arglists) + BODY + `((lambda* ,(car arglists) ,@(nest-lambda*s (cdr arglists)))))) + (define (define*-guts-helper ARGLIST arglists) + (let ((first (car ARGLIST)) + (al (cons (cdr ARGLIST) arglists))) + (if (symbol? first) + `(,DT ,first ,@(nest-lambda*s al)) + (define*-guts-helper first al)))) + (if (symbol? ARGLIST) + `(,DT ,ARGLIST ,@BODY) + (define*-guts-helper ARGLIST '()))) + + + +;; defmacro* name args . body +;; defmacro*-public args . body +;; defmacro and defmacro-public extended for optional and keyword arguments +;; +;; These are just like defmacro and defmacro-public except that they +;; take lambda*-style extended paramter lists, where #:optional, +;; #:key, #:allow-other-keys and #:rest are allowed with the usual +;; semantics. Here is an example of a macro with an optional argument: +;; (defmacro* transmorgify (a #:optional b) + +(defmacro defmacro* (NAME ARGLIST . BODY) + (defmacro*-guts 'define NAME ARGLIST BODY)) + +(defmacro defmacro*-public (NAME ARGLIST . BODY) + (defmacro*-guts 'define-public NAME ARGLIST BODY)) + +;; The guts of defmacro* and defmacro*-public +(define (defmacro*-guts DT NAME ARGLIST BODY) + `(,DT ,NAME + (,(lambda (transformer) (defmacro:transformer transformer)) + (lambda* ,ARGLIST ,@BODY)))) + +;;; optargs.scm ends here diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/poe.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/poe.scm new file mode 100755 index 0000000000000000000000000000000000000000..fe963db08517420663848e9172bac48c6bd3b28c --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/poe.scm @@ -0,0 +1,122 @@ +;;; installed-scm-file + +;;;; Copyright (C) 1996, 2001, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; + + +(define-module (ice-9 poe) + :use-module (ice-9 hcons) + :export (pure-funcq perfect-funcq)) + + + + +;;; {Pure Functions} +;;; +;;; A pure function (of some sort) is characterized by two equality +;;; relations: one on argument lists and one on return values. +;;; A pure function is one that when applied to equal arguments lists +;;; yields equal results. +;;; +;;; If the equality relationship on return values can be eq?, it may make +;;; sense to cache values returned by the function. Choosing the right +;;; equality relation on arguments is tricky. +;;; + + +;;; {pure-funcq} +;;; +;;; The simplest case of pure functions are those in which results +;;; are only certainly eq? if all of the arguments are. These functions +;;; are called "pure-funcq", for obvious reasons. +;;; + + +(define funcq-memo (make-weak-key-hash-table 523)) ; !!! randomly selected values +(define funcq-buffer (make-gc-buffer 256)) + +(define (funcq-hash arg-list n) + (let ((it (let loop ((x 0) + (arg-list arg-list)) + (if (null? arg-list) + (modulo x n) + (loop (logior x (hashq (car arg-list) 4194303)) + (cdr arg-list)))))) + it)) + +;; return true if lists X and Y are the same length and each element is `eq?' +(define (eq?-list x y) + (if (null? x) + (null? y) + (and (not (null? y)) + (eq? (car x) (car y)) + (eq?-list (cdr x) (cdr y))))) + +(define (funcq-assoc arg-list alist) + (if (null? alist) + #f + (if (eq?-list arg-list (caar alist)) + (car alist) + (funcq-assoc arg-list (cdr alist))))) + + + +(define (pure-funcq base-func) + (lambda args + (let ((cached (hashx-get-handle funcq-hash funcq-assoc funcq-memo (cons base-func args)))) + (if cached + (begin + (funcq-buffer (car cached)) + (cdr cached)) + + (let ((val (apply base-func args)) + (key (cons base-func args))) + (funcq-buffer key) + (hashx-set! funcq-hash funcq-assoc funcq-memo key val) + val))))) + + + +;;; {Perfect funq} +;;; +;;; A pure funq may sometimes forget its past but a perfect +;;; funcq never does. +;;; + +(define (perfect-funcq size base-func) + (define funcq-memo (make-hash-table size)) + + (lambda args + (let ((cached (hashx-get-handle funcq-hash funcq-assoc funcq-memo (cons base-func args)))) + (if cached + (begin + (funcq-buffer (car cached)) + (cdr cached)) + + (let ((val (apply base-func args)) + (key (cons base-func args))) + (funcq-buffer key) + (hashx-set! funcq-hash funcq-assoc funcq-memo key val) + val))))) + + + + + + + + diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/popen.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/popen.scm new file mode 100755 index 0000000000000000000000000000000000000000..275faaa0c76375771e83a2e67b19ddbfebf051e6 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/popen.scm @@ -0,0 +1,215 @@ +;; popen emulation, for non-stdio based ports. + +;;;; Copyright (C) 1998, 1999, 2000, 2001, 2003, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; + +(define-module (ice-9 popen) + :export (port/pid-table open-pipe* open-pipe close-pipe open-input-pipe + open-output-pipe open-input-output-pipe)) + +(define (make-rw-port read-port write-port) + (make-soft-port + (vector + (lambda (c) (write-char c write-port)) + (lambda (s) (display s write-port)) + (lambda () (force-output write-port)) + (lambda () (read-char read-port)) + (lambda () (close-port read-port) (close-port write-port))) + "r+")) + +;; a guardian to ensure the cleanup is done correctly when +;; an open pipe is gc'd or a close-port is used. +(define pipe-guardian (make-guardian)) + +;; a weak hash-table to store the process ids. +(define port/pid-table (make-weak-key-hash-table 31)) + +(define (ensure-fdes port mode) + (or (false-if-exception (fileno port)) + (open-fdes *null-device* mode))) + +;; run a process connected to an input, an output or an +;; input/output port +;; mode: OPEN_READ, OPEN_WRITE or OPEN_BOTH +;; returns port/pid pair. +(define (open-process mode prog . args) + (let* ((reading (or (equal? mode OPEN_READ) + (equal? mode OPEN_BOTH))) + (writing (or (equal? mode OPEN_WRITE) + (equal? mode OPEN_BOTH))) + (c2p (if reading (pipe) #f)) ; child to parent + (p2c (if writing (pipe) #f))) ; parent to child + + (if c2p (setvbuf (cdr c2p) _IONBF)) + (if p2c (setvbuf (cdr p2c) _IONBF)) + (let ((pid (primitive-fork))) + (cond ((= pid 0) + ;; child + (set-batch-mode?! #t) + + ;; select the three file descriptors to be used as + ;; standard descriptors 0, 1, 2 for the new + ;; process. They are pipes to/from the parent or taken + ;; from the current Scheme input/output/error ports if + ;; possible. + + (let ((input-fdes (if writing + (fileno (car p2c)) + (ensure-fdes (current-input-port) + O_RDONLY))) + (output-fdes (if reading + (fileno (cdr c2p)) + (ensure-fdes (current-output-port) + O_WRONLY))) + (error-fdes (ensure-fdes (current-error-port) + O_WRONLY))) + + ;; close all file descriptors in ports inherited from + ;; the parent except for the three selected above. + ;; this is to avoid causing problems for other pipes in + ;; the parent. + + ;; use low-level system calls, not close-port or the + ;; scsh routines, to avoid side-effects such as + ;; flushing port buffers or evicting ports. + + (port-for-each (lambda (pt-entry) + (false-if-exception + (let ((pt-fileno (fileno pt-entry))) + (if (not (or (= pt-fileno input-fdes) + (= pt-fileno output-fdes) + (= pt-fileno error-fdes))) + (close-fdes pt-fileno)))))) + + ;; Copy the three selected descriptors to the standard + ;; descriptors 0, 1, 2, if not already there + + (cond ((not (= input-fdes 0)) + (if (= output-fdes 0) + (set! output-fdes (dup->fdes 0))) + (if (= error-fdes 0) + (set! error-fdes (dup->fdes 0))) + (dup2 input-fdes 0) + ;; it's possible input-fdes is error-fdes + (if (not (= input-fdes error-fdes)) + (close-fdes input-fdes)))) + + (cond ((not (= output-fdes 1)) + (if (= error-fdes 1) + (set! error-fdes (dup->fdes 1))) + (dup2 output-fdes 1) + ;; it's possible output-fdes is error-fdes + (if (not (= output-fdes error-fdes)) + (close-fdes output-fdes)))) + + (cond ((not (= error-fdes 2)) + (dup2 error-fdes 2) + (close-fdes error-fdes))) + + (apply execlp prog prog args))) + + (else + ;; parent + (if c2p (close-port (cdr c2p))) + (if p2c (close-port (car p2c))) + (cons (cond ((not writing) (car c2p)) + ((not reading) (cdr p2c)) + (else (make-rw-port (car c2p) + (cdr p2c)))) + pid)))))) + +(define (open-pipe* mode command . args) + "Executes the program @var{command} with optional arguments +@var{args} (all strings) in a subprocess. +A port to the process (based on pipes) is created and returned. +@var{modes} specifies whether an input, an output or an input-output +port to the process is created: it should be the value of +@code{OPEN_READ}, @code{OPEN_WRITE} or @code{OPEN_BOTH}." + (let* ((port/pid (apply open-process mode command args)) + (port (car port/pid))) + (pipe-guardian port) + (hashq-set! port/pid-table port (cdr port/pid)) + port)) + +(define (open-pipe command mode) + "Executes the shell command @var{command} (a string) in a subprocess. +A port to the process (based on pipes) is created and returned. +@var{modes} specifies whether an input, an output or an input-output +port to the process is created: it should be the value of +@code{OPEN_READ}, @code{OPEN_WRITE} or @code{OPEN_BOTH}." + (open-pipe* mode "/bin/sh" "-c" command)) + +(define (fetch-pid port) + (let ((pid (hashq-ref port/pid-table port))) + (hashq-remove! port/pid-table port) + pid)) + +(define (close-process port/pid) + (close-port (car port/pid)) + (cdr (waitpid (cdr port/pid)))) + +;; for the background cleanup handler: just clean up without reporting +;; errors. also avoids blocking the process: if the child isn't ready +;; to be collected, puts it back into the guardian's live list so it +;; can be tried again the next time the cleanup runs. +(define (close-process-quietly port/pid) + (catch 'system-error + (lambda () + (close-port (car port/pid))) + (lambda args #f)) + (catch 'system-error + (lambda () + (let ((pid/status (waitpid (cdr port/pid) WNOHANG))) + (cond ((= (car pid/status) 0) + ;; not ready for collection + (pipe-guardian (car port/pid)) + (hashq-set! port/pid-table + (car port/pid) (cdr port/pid)))))) + (lambda args #f))) + +(define (close-pipe p) + "Closes the pipe created by @code{open-pipe}, then waits for the process +to terminate and returns its status value, @xref{Processes, waitpid}, for +information on how to interpret this value." + (let ((pid (fetch-pid p))) + (if (not pid) + (error "close-pipe: pipe not in table")) + (close-process (cons p pid)))) + +(define reap-pipes + (lambda () + (let loop ((p (pipe-guardian))) + (cond (p + ;; maybe removed already by close-pipe. + (let ((pid (fetch-pid p))) + (if pid + (close-process-quietly (cons p pid)))) + (loop (pipe-guardian))))))) + +(add-hook! after-gc-hook reap-pipes) + +(define (open-input-pipe command) + "Equivalent to @code{open-pipe} with mode @code{OPEN_READ}" + (open-pipe command OPEN_READ)) + +(define (open-output-pipe command) + "Equivalent to @code{open-pipe} with mode @code{OPEN_WRITE}" + (open-pipe command OPEN_WRITE)) + +(define (open-input-output-pipe command) + "Equivalent to @code{open-pipe} with mode @code{OPEN_BOTH}" + (open-pipe command OPEN_BOTH)) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/posix.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/posix.scm new file mode 100755 index 0000000000000000000000000000000000000000..53d01a026a582f406d1c52025d671b9abf96b94a --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/posix.scm @@ -0,0 +1,69 @@ +;;; installed-scm-file + +;;;; Copyright (C) 1999, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; + +(define (stat:dev f) (vector-ref f 0)) +(define (stat:ino f) (vector-ref f 1)) +(define (stat:mode f) (vector-ref f 2)) +(define (stat:nlink f) (vector-ref f 3)) +(define (stat:uid f) (vector-ref f 4)) +(define (stat:gid f) (vector-ref f 5)) +(define (stat:rdev f) (vector-ref f 6)) +(define (stat:size f) (vector-ref f 7)) +(define (stat:atime f) (vector-ref f 8)) +(define (stat:mtime f) (vector-ref f 9)) +(define (stat:ctime f) (vector-ref f 10)) +(define (stat:blksize f) (vector-ref f 11)) +(define (stat:blocks f) (vector-ref f 12)) + +;; derived from stat mode. +(define (stat:type f) (vector-ref f 13)) +(define (stat:perms f) (vector-ref f 14)) + +(define (passwd:name obj) (vector-ref obj 0)) +(define (passwd:passwd obj) (vector-ref obj 1)) +(define (passwd:uid obj) (vector-ref obj 2)) +(define (passwd:gid obj) (vector-ref obj 3)) +(define (passwd:gecos obj) (vector-ref obj 4)) +(define (passwd:dir obj) (vector-ref obj 5)) +(define (passwd:shell obj) (vector-ref obj 6)) + +(define (group:name obj) (vector-ref obj 0)) +(define (group:passwd obj) (vector-ref obj 1)) +(define (group:gid obj) (vector-ref obj 2)) +(define (group:mem obj) (vector-ref obj 3)) + +(define (utsname:sysname obj) (vector-ref obj 0)) +(define (utsname:nodename obj) (vector-ref obj 1)) +(define (utsname:release obj) (vector-ref obj 2)) +(define (utsname:version obj) (vector-ref obj 3)) +(define (utsname:machine obj) (vector-ref obj 4)) + +(define (getpwent) (getpw)) +(define (setpwent) (setpw #t)) +(define (endpwent) (setpw)) + +(define (getpwnam name) (getpw name)) +(define (getpwuid uid) (getpw uid)) + +(define (getgrent) (getgr)) +(define (setgrent) (setgr #t)) +(define (endgrent) (setgr)) + +(define (getgrnam name) (getgr name)) +(define (getgrgid id) (getgr id)) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/pretty-print.scm b/node-addon-lilypond/output/share/guile/1.8/ice-9/pretty-print.scm new file mode 100755 index 0000000000000000000000000000000000000000..bef76ddcb69780ae98046cffaa0c24003ff1359c --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/pretty-print.scm @@ -0,0 +1,278 @@ +;;;; -*-scheme-*- +;;;; +;;;; Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; +(define-module (ice-9 pretty-print) + :use-module (ice-9 optargs) + :export (pretty-print)) + +;; From SLIB. + +;;"genwrite.scm" generic write used by pretty-print and truncated-print. +;; Copyright (c) 1991, Marc Feeley +;; Author: Marc Feeley (feeley@iro.umontreal.ca) +;; Distribution restrictions: none + +(define genwrite:newline-str (make-string 1 #\newline)) + +(define (generic-write obj display? width per-line-prefix output) + + (define (read-macro? l) + (define (length1? l) (and (pair? l) (null? (cdr l)))) + (let ((head (car l)) (tail (cdr l))) + (case head + ((quote quasiquote unquote unquote-splicing) (length1? tail)) + (else #f)))) + + (define (read-macro-body l) + (cadr l)) + + (define (read-macro-prefix l) + (let ((head (car l))) + (case head + ((quote) "'") + ((quasiquote) "`") + ((unquote) ",") + ((unquote-splicing) ",@")))) + + (define (out str col) + (and col (output str) (+ col (string-length str)))) + + (define (wr obj col) + (cond ((and (pair? obj) + (read-macro? obj)) + (wr (read-macro-body obj) + (out (read-macro-prefix obj) col))) + (else + (out (object->string obj (if display? display write)) col)))) + + (define (pp obj col) + + (define (spaces n col) + (if (> n 0) + (if (> n 7) + (spaces (- n 8) (out " " col)) + (out (substring " " 0 n) col)) + col)) + + (define (indent to col) + (and col + (if (< to col) + (and (out genwrite:newline-str col) + (out per-line-prefix 0) + (spaces to 0)) + (spaces (- to col) col)))) + + (define (pr obj col extra pp-pair) + (if (or (pair? obj) (vector? obj)) ; may have to split on multiple lines + (let ((result '()) + (left (min (+ (- (- width col) extra) 1) max-expr-width))) + (generic-write obj display? #f "" + (lambda (str) + (set! result (cons str result)) + (set! left (- left (string-length str))) + (> left 0))) + (if (> left 0) ; all can be printed on one line + (out (reverse-string-append result) col) + (if (pair? obj) + (pp-pair obj col extra) + (pp-list (vector->list obj) (out "#" col) extra pp-expr)))) + (wr obj col))) + + (define (pp-expr expr col extra) + (if (read-macro? expr) + (pr (read-macro-body expr) + (out (read-macro-prefix expr) col) + extra + pp-expr) + (let ((head (car expr))) + (if (symbol? head) + (let ((proc (style head))) + (if proc + (proc expr col extra) + (if (> (string-length (symbol->string head)) + max-call-head-width) + (pp-general expr col extra #f #f #f pp-expr) + (pp-call expr col extra pp-expr)))) + (pp-list expr col extra pp-expr))))) + + ; (head item1 + ; item2 + ; item3) + (define (pp-call expr col extra pp-item) + (let ((col* (wr (car expr) (out "(" col)))) + (and col + (pp-down (cdr expr) col* (+ col* 1) extra pp-item)))) + + ; (item1 + ; item2 + ; item3) + (define (pp-list l col extra pp-item) + (let ((col (out "(" col))) + (pp-down l col col extra pp-item))) + + (define (pp-down l col1 col2 extra pp-item) + (let loop ((l l) (col col1)) + (and col + (cond ((pair? l) + (let ((rest (cdr l))) + (let ((extra (if (null? rest) (+ extra 1) 0))) + (loop rest + (pr (car l) (indent col2 col) extra pp-item))))) + ((null? l) + (out ")" col)) + (else + (out ")" + (pr l + (indent col2 (out "." (indent col2 col))) + (+ extra 1) + pp-item))))))) + + (define (pp-general expr col extra named? pp-1 pp-2 pp-3) + + (define (tail1 rest col1 col2 col3) + (if (and pp-1 (pair? rest)) + (let* ((val1 (car rest)) + (rest (cdr rest)) + (extra (if (null? rest) (+ extra 1) 0))) + (tail2 rest col1 (pr val1 (indent col3 col2) extra pp-1) col3)) + (tail2 rest col1 col2 col3))) + + (define (tail2 rest col1 col2 col3) + (if (and pp-2 (pair? rest)) + (let* ((val1 (car rest)) + (rest (cdr rest)) + (extra (if (null? rest) (+ extra 1) 0))) + (tail3 rest col1 (pr val1 (indent col3 col2) extra pp-2))) + (tail3 rest col1 col2))) + + (define (tail3 rest col1 col2) + (pp-down rest col2 col1 extra pp-3)) + + (let* ((head (car expr)) + (rest (cdr expr)) + (col* (wr head (out "(" col)))) + (if (and named? (pair? rest)) + (let* ((name (car rest)) + (rest (cdr rest)) + (col** (wr name (out " " col*)))) + (tail1 rest (+ col indent-general) col** (+ col** 1))) + (tail1 rest (+ col indent-general) col* (+ col* 1))))) + + (define (pp-expr-list l col extra) + (pp-list l col extra pp-expr)) + + (define (pp-LAMBDA expr col extra) + (pp-general expr col extra #f pp-expr-list #f pp-expr)) + + (define (pp-IF expr col extra) + (pp-general expr col extra #f pp-expr #f pp-expr)) + + (define (pp-COND expr col extra) + (pp-call expr col extra pp-expr-list)) + + (define (pp-CASE expr col extra) + (pp-general expr col extra #f pp-expr #f pp-expr-list)) + + (define (pp-AND expr col extra) + (pp-call expr col extra pp-expr)) + + (define (pp-LET expr col extra) + (let* ((rest (cdr expr)) + (named? (and (pair? rest) (symbol? (car rest))))) + (pp-general expr col extra named? pp-expr-list #f pp-expr))) + + (define (pp-BEGIN expr col extra) + (pp-general expr col extra #f #f #f pp-expr)) + + (define (pp-DO expr col extra) + (pp-general expr col extra #f pp-expr-list pp-expr-list pp-expr)) + + ; define formatting style (change these to suit your style) + + (define indent-general 2) + + (define max-call-head-width 5) + + (define max-expr-width 50) + + (define (style head) + (case head + ((lambda let* letrec define) pp-LAMBDA) + ((if set!) pp-IF) + ((cond) pp-COND) + ((case) pp-CASE) + ((and or) pp-AND) + ((let) pp-LET) + ((begin) pp-BEGIN) + ((do) pp-DO) + (else #f))) + + (pr obj col 0 pp-expr)) + + (out per-line-prefix 0) + (if width + (out genwrite:newline-str (pp obj 0)) + (wr obj 0)) + ;; Return `unspecified' + (if #f #f)) + +; (reverse-string-append l) = (apply string-append (reverse l)) + +(define (reverse-string-append l) + + (define (rev-string-append l i) + (if (pair? l) + (let* ((str (car l)) + (len (string-length str)) + (result (rev-string-append (cdr l) (+ i len)))) + (let loop ((j 0) (k (- (- (string-length result) i) len))) + (if (< j len) + (begin + (string-set! result k (string-ref str j)) + (loop (+ j 1) (+ k 1))) + result))) + (make-string i))) + + (rev-string-append l 0)) + +(define (pretty-print obj . opts) + "Pretty-print OBJ on PORT, which is a keyword argument defaulting to +the current output port. Formatting can be controlled by a number of +keyword arguments: Each line in the output is preceded by the string +PER-LINE-PREFIX, which is empty by default. The output lines will be +at most WIDTH characters wide; the default is 79. If DISPLAY? is +true, display rather than write representation will be used. + +Instead of with a keyword argument, you can also specify the output +port directly after OBJ, like (pretty-print OBJ PORT)." + (if (pair? opts) + (if (keyword? (car opts)) + (apply pretty-print-with-keys obj opts) + (apply pretty-print-with-keys obj #:port (car opts) (cdr opts))) + (pretty-print-with-keys obj))) + +(define* (pretty-print-with-keys obj + #:key + (port (current-output-port)) + (width 79) + (display? #f) + (per-line-prefix "")) + (generic-write obj display? + (- width (string-length per-line-prefix)) + per-line-prefix + (lambda (s) (display s port) #t))) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/psyntax.pp b/node-addon-lilypond/output/share/guile/1.8/ice-9/psyntax.pp new file mode 100755 index 0000000000000000000000000000000000000000..4abf7bcc9bd49a047582bd35f801d4968f545713 --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/psyntax.pp @@ -0,0 +1,11 @@ +(letrec ((syntmp-lambda-var-list-164 (lambda (syntmp-vars-549) (let syntmp-lvl-550 ((syntmp-vars-551 syntmp-vars-549) (syntmp-ls-552 (quote ())) (syntmp-w-553 (quote (())))) (cond ((pair? syntmp-vars-551) (syntmp-lvl-550 (cdr syntmp-vars-551) (cons (syntmp-wrap-143 (car syntmp-vars-551) syntmp-w-553) syntmp-ls-552) syntmp-w-553)) ((syntmp-id?-115 syntmp-vars-551) (cons (syntmp-wrap-143 syntmp-vars-551 syntmp-w-553) syntmp-ls-552)) ((null? syntmp-vars-551) syntmp-ls-552) ((syntmp-syntax-object?-101 syntmp-vars-551) (syntmp-lvl-550 (syntmp-syntax-object-expression-102 syntmp-vars-551) syntmp-ls-552 (syntmp-join-wraps-134 syntmp-w-553 (syntmp-syntax-object-wrap-103 syntmp-vars-551)))) ((syntmp-annotation?-89 syntmp-vars-551) (syntmp-lvl-550 (annotation-expression syntmp-vars-551) syntmp-ls-552 syntmp-w-553)) (else (cons syntmp-vars-551 syntmp-ls-552)))))) (syntmp-gen-var-163 (lambda (syntmp-id-554) (let ((syntmp-id-555 (if (syntmp-syntax-object?-101 syntmp-id-554) (syntmp-syntax-object-expression-102 syntmp-id-554) syntmp-id-554))) (if (syntmp-annotation?-89 syntmp-id-555) (gensym (symbol->string (annotation-expression syntmp-id-555))) (gensym (symbol->string syntmp-id-555)))))) (syntmp-strip-162 (lambda (syntmp-x-556 syntmp-w-557) (if (memq (quote top) (syntmp-wrap-marks-118 syntmp-w-557)) (if (or (syntmp-annotation?-89 syntmp-x-556) (and (pair? syntmp-x-556) (syntmp-annotation?-89 (car syntmp-x-556)))) (syntmp-strip-annotation-161 syntmp-x-556 #f) syntmp-x-556) (let syntmp-f-558 ((syntmp-x-559 syntmp-x-556)) (cond ((syntmp-syntax-object?-101 syntmp-x-559) (syntmp-strip-162 (syntmp-syntax-object-expression-102 syntmp-x-559) (syntmp-syntax-object-wrap-103 syntmp-x-559))) ((pair? syntmp-x-559) (let ((syntmp-a-560 (syntmp-f-558 (car syntmp-x-559))) (syntmp-d-561 (syntmp-f-558 (cdr syntmp-x-559)))) (if (and (eq? syntmp-a-560 (car syntmp-x-559)) (eq? syntmp-d-561 (cdr syntmp-x-559))) syntmp-x-559 (cons syntmp-a-560 syntmp-d-561)))) ((vector? syntmp-x-559) (let ((syntmp-old-562 (vector->list syntmp-x-559))) (let ((syntmp-new-563 (map syntmp-f-558 syntmp-old-562))) (if (andmap eq? syntmp-old-562 syntmp-new-563) syntmp-x-559 (list->vector syntmp-new-563))))) (else syntmp-x-559)))))) (syntmp-strip-annotation-161 (lambda (syntmp-x-564 syntmp-parent-565) (cond ((pair? syntmp-x-564) (let ((syntmp-new-566 (cons #f #f))) (begin (when syntmp-parent-565 (set-annotation-stripped! syntmp-parent-565 syntmp-new-566)) (set-car! syntmp-new-566 (syntmp-strip-annotation-161 (car syntmp-x-564) #f)) (set-cdr! syntmp-new-566 (syntmp-strip-annotation-161 (cdr syntmp-x-564) #f)) syntmp-new-566))) ((syntmp-annotation?-89 syntmp-x-564) (or (annotation-stripped syntmp-x-564) (syntmp-strip-annotation-161 (annotation-expression syntmp-x-564) syntmp-x-564))) ((vector? syntmp-x-564) (let ((syntmp-new-567 (make-vector (vector-length syntmp-x-564)))) (begin (when syntmp-parent-565 (set-annotation-stripped! syntmp-parent-565 syntmp-new-567)) (let syntmp-loop-568 ((syntmp-i-569 (- (vector-length syntmp-x-564) 1))) (unless (syntmp-fx<-88 syntmp-i-569 0) (vector-set! syntmp-new-567 syntmp-i-569 (syntmp-strip-annotation-161 (vector-ref syntmp-x-564 syntmp-i-569) #f)) (syntmp-loop-568 (syntmp-fx--86 syntmp-i-569 1)))) syntmp-new-567))) (else syntmp-x-564)))) (syntmp-ellipsis?-160 (lambda (syntmp-x-570) (and (syntmp-nonsymbol-id?-114 syntmp-x-570) (syntmp-free-id=?-138 syntmp-x-570 (quote #(syntax-object ... ((top) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i")) #(ribcage (lambda-var-list gen-var strip strip-annotation ellipsis? chi-void eval-local-transformer chi-local-syntax chi-lambda-clause chi-body chi-macro chi-application chi-expr chi chi-top syntax-type chi-when-list chi-install-global chi-top-sequence chi-sequence source-wrap wrap bound-id-member? distinct-bound-ids? valid-bound-ids? bound-id=? free-id=? id-var-name same-marks? join-marks join-wraps smart-append make-binding-wrap extend-ribcage! make-empty-ribcage new-mark anti-mark the-anti-mark top-marked? top-wrap empty-wrap set-ribcage-labels! set-ribcage-marks! set-ribcage-symnames! ribcage-labels ribcage-marks ribcage-symnames ribcage? make-ribcage gen-labels gen-label make-rename rename-marks rename-new rename-old subst-rename? wrap-subst wrap-marks make-wrap id-sym-name&marks id-sym-name id? nonsymbol-id? global-extend lookup macros-only-env extend-var-env extend-env null-env binding-value binding-type make-binding arg-check source-annotation no-source unannotate set-syntax-object-wrap! set-syntax-object-expression! syntax-object-wrap syntax-object-expression syntax-object? make-syntax-object build-lexical-var build-letrec build-named-let build-let build-sequence build-data build-primref build-lambda build-global-definition build-global-assignment build-global-reference build-lexical-assignment build-lexical-reference build-conditional build-application get-global-definition-hook put-global-definition-hook gensym-hook error-hook local-eval-hook top-level-eval-hook annotation? fx< fx= fx- fx+ noexpand) ((top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top)) ("i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i")) #(ribcage (define-structure) ((top)) ("i"))))))))) (syntmp-chi-void-159 (lambda () (list (quote void)))) (syntmp-eval-local-transformer-158 (lambda (syntmp-expanded-571) (let ((syntmp-p-572 (syntmp-local-eval-hook-91 syntmp-expanded-571))) (if (procedure? syntmp-p-572) syntmp-p-572 (syntax-error syntmp-p-572 "nonprocedure transformer"))))) (syntmp-chi-local-syntax-157 (lambda (syntmp-rec?-573 syntmp-e-574 syntmp-r-575 syntmp-w-576 syntmp-s-577 syntmp-k-578) ((lambda (syntmp-tmp-579) ((lambda (syntmp-tmp-580) (if syntmp-tmp-580 (apply (lambda (syntmp-_-581 syntmp-id-582 syntmp-val-583 syntmp-e1-584 syntmp-e2-585) (let ((syntmp-ids-586 syntmp-id-582)) (if (not (syntmp-valid-bound-ids?-140 syntmp-ids-586)) (syntax-error syntmp-e-574 "duplicate bound keyword in") (let ((syntmp-labels-588 (syntmp-gen-labels-121 syntmp-ids-586))) (let ((syntmp-new-w-589 (syntmp-make-binding-wrap-132 syntmp-ids-586 syntmp-labels-588 syntmp-w-576))) (syntmp-k-578 (cons syntmp-e1-584 syntmp-e2-585) (syntmp-extend-env-109 syntmp-labels-588 (let ((syntmp-w-591 (if syntmp-rec?-573 syntmp-new-w-589 syntmp-w-576)) (syntmp-trans-r-592 (syntmp-macros-only-env-111 syntmp-r-575))) (map (lambda (syntmp-x-593) (cons (quote macro) (syntmp-eval-local-transformer-158 (syntmp-chi-151 syntmp-x-593 syntmp-trans-r-592 syntmp-w-591)))) syntmp-val-583)) syntmp-r-575) syntmp-new-w-589 syntmp-s-577)))))) syntmp-tmp-580) ((lambda (syntmp-_-595) (syntax-error (syntmp-source-wrap-144 syntmp-e-574 syntmp-w-576 syntmp-s-577))) syntmp-tmp-579))) (syntax-dispatch syntmp-tmp-579 (quote (any #(each (any any)) any . each-any))))) syntmp-e-574))) (syntmp-chi-lambda-clause-156 (lambda (syntmp-e-596 syntmp-c-597 syntmp-r-598 syntmp-w-599 syntmp-k-600) ((lambda (syntmp-tmp-601) ((lambda (syntmp-tmp-602) (if syntmp-tmp-602 (apply (lambda (syntmp-id-603 syntmp-e1-604 syntmp-e2-605) (let ((syntmp-ids-606 syntmp-id-603)) (if (not (syntmp-valid-bound-ids?-140 syntmp-ids-606)) (syntax-error syntmp-e-596 "invalid parameter list in") (let ((syntmp-labels-608 (syntmp-gen-labels-121 syntmp-ids-606)) (syntmp-new-vars-609 (map syntmp-gen-var-163 syntmp-ids-606))) (syntmp-k-600 syntmp-new-vars-609 (syntmp-chi-body-155 (cons syntmp-e1-604 syntmp-e2-605) syntmp-e-596 (syntmp-extend-var-env-110 syntmp-labels-608 syntmp-new-vars-609 syntmp-r-598) (syntmp-make-binding-wrap-132 syntmp-ids-606 syntmp-labels-608 syntmp-w-599))))))) syntmp-tmp-602) ((lambda (syntmp-tmp-611) (if syntmp-tmp-611 (apply (lambda (syntmp-ids-612 syntmp-e1-613 syntmp-e2-614) (let ((syntmp-old-ids-615 (syntmp-lambda-var-list-164 syntmp-ids-612))) (if (not (syntmp-valid-bound-ids?-140 syntmp-old-ids-615)) (syntax-error syntmp-e-596 "invalid parameter list in") (let ((syntmp-labels-616 (syntmp-gen-labels-121 syntmp-old-ids-615)) (syntmp-new-vars-617 (map syntmp-gen-var-163 syntmp-old-ids-615))) (syntmp-k-600 (let syntmp-f-618 ((syntmp-ls1-619 (cdr syntmp-new-vars-617)) (syntmp-ls2-620 (car syntmp-new-vars-617))) (if (null? syntmp-ls1-619) syntmp-ls2-620 (syntmp-f-618 (cdr syntmp-ls1-619) (cons (car syntmp-ls1-619) syntmp-ls2-620)))) (syntmp-chi-body-155 (cons syntmp-e1-613 syntmp-e2-614) syntmp-e-596 (syntmp-extend-var-env-110 syntmp-labels-616 syntmp-new-vars-617 syntmp-r-598) (syntmp-make-binding-wrap-132 syntmp-old-ids-615 syntmp-labels-616 syntmp-w-599))))))) syntmp-tmp-611) ((lambda (syntmp-_-622) (syntax-error syntmp-e-596)) syntmp-tmp-601))) (syntax-dispatch syntmp-tmp-601 (quote (any any . each-any)))))) (syntax-dispatch syntmp-tmp-601 (quote (each-any any . each-any))))) syntmp-c-597))) (syntmp-chi-body-155 (lambda (syntmp-body-623 syntmp-outer-form-624 syntmp-r-625 syntmp-w-626) (let ((syntmp-r-627 (cons (quote ("placeholder" placeholder)) syntmp-r-625))) (let ((syntmp-ribcage-628 (syntmp-make-ribcage-122 (quote ()) (quote ()) (quote ())))) (let ((syntmp-w-629 (syntmp-make-wrap-117 (syntmp-wrap-marks-118 syntmp-w-626) (cons syntmp-ribcage-628 (syntmp-wrap-subst-119 syntmp-w-626))))) (let syntmp-parse-630 ((syntmp-body-631 (map (lambda (syntmp-x-637) (cons syntmp-r-627 (syntmp-wrap-143 syntmp-x-637 syntmp-w-629))) syntmp-body-623)) (syntmp-ids-632 (quote ())) (syntmp-labels-633 (quote ())) (syntmp-vars-634 (quote ())) (syntmp-vals-635 (quote ())) (syntmp-bindings-636 (quote ()))) (if (null? syntmp-body-631) (syntax-error syntmp-outer-form-624 "no expressions in body") (let ((syntmp-e-638 (cdar syntmp-body-631)) (syntmp-er-639 (caar syntmp-body-631))) (call-with-values (lambda () (syntmp-syntax-type-149 syntmp-e-638 syntmp-er-639 (quote (())) #f syntmp-ribcage-628)) (lambda (syntmp-type-640 syntmp-value-641 syntmp-e-642 syntmp-w-643 syntmp-s-644) (let ((syntmp-t-645 syntmp-type-640)) (if (memv syntmp-t-645 (quote (define-form))) (let ((syntmp-id-646 (syntmp-wrap-143 syntmp-value-641 syntmp-w-643)) (syntmp-label-647 (syntmp-gen-label-120))) (let ((syntmp-var-648 (syntmp-gen-var-163 syntmp-id-646))) (begin (syntmp-extend-ribcage!-131 syntmp-ribcage-628 syntmp-id-646 syntmp-label-647) (syntmp-parse-630 (cdr syntmp-body-631) (cons syntmp-id-646 syntmp-ids-632) (cons syntmp-label-647 syntmp-labels-633) (cons syntmp-var-648 syntmp-vars-634) (cons (cons syntmp-er-639 (syntmp-wrap-143 syntmp-e-642 syntmp-w-643)) syntmp-vals-635) (cons (cons (quote lexical) syntmp-var-648) syntmp-bindings-636))))) (if (memv syntmp-t-645 (quote (define-syntax-form))) (let ((syntmp-id-649 (syntmp-wrap-143 syntmp-value-641 syntmp-w-643)) (syntmp-label-650 (syntmp-gen-label-120))) (begin (syntmp-extend-ribcage!-131 syntmp-ribcage-628 syntmp-id-649 syntmp-label-650) (syntmp-parse-630 (cdr syntmp-body-631) (cons syntmp-id-649 syntmp-ids-632) (cons syntmp-label-650 syntmp-labels-633) syntmp-vars-634 syntmp-vals-635 (cons (cons (quote macro) (cons syntmp-er-639 (syntmp-wrap-143 syntmp-e-642 syntmp-w-643))) syntmp-bindings-636)))) (if (memv syntmp-t-645 (quote (begin-form))) ((lambda (syntmp-tmp-651) ((lambda (syntmp-tmp-652) (if syntmp-tmp-652 (apply (lambda (syntmp-_-653 syntmp-e1-654) (syntmp-parse-630 (let syntmp-f-655 ((syntmp-forms-656 syntmp-e1-654)) (if (null? syntmp-forms-656) (cdr syntmp-body-631) (cons (cons syntmp-er-639 (syntmp-wrap-143 (car syntmp-forms-656) syntmp-w-643)) (syntmp-f-655 (cdr syntmp-forms-656))))) syntmp-ids-632 syntmp-labels-633 syntmp-vars-634 syntmp-vals-635 syntmp-bindings-636)) syntmp-tmp-652) (syntax-error syntmp-tmp-651))) (syntax-dispatch syntmp-tmp-651 (quote (any . each-any))))) syntmp-e-642) (if (memv syntmp-t-645 (quote (local-syntax-form))) (syntmp-chi-local-syntax-157 syntmp-value-641 syntmp-e-642 syntmp-er-639 syntmp-w-643 syntmp-s-644 (lambda (syntmp-forms-658 syntmp-er-659 syntmp-w-660 syntmp-s-661) (syntmp-parse-630 (let syntmp-f-662 ((syntmp-forms-663 syntmp-forms-658)) (if (null? syntmp-forms-663) (cdr syntmp-body-631) (cons (cons syntmp-er-659 (syntmp-wrap-143 (car syntmp-forms-663) syntmp-w-660)) (syntmp-f-662 (cdr syntmp-forms-663))))) syntmp-ids-632 syntmp-labels-633 syntmp-vars-634 syntmp-vals-635 syntmp-bindings-636))) (if (null? syntmp-ids-632) (syntmp-build-sequence-96 #f (map (lambda (syntmp-x-664) (syntmp-chi-151 (cdr syntmp-x-664) (car syntmp-x-664) (quote (())))) (cons (cons syntmp-er-639 (syntmp-source-wrap-144 syntmp-e-642 syntmp-w-643 syntmp-s-644)) (cdr syntmp-body-631)))) (begin (if (not (syntmp-valid-bound-ids?-140 syntmp-ids-632)) (syntax-error syntmp-outer-form-624 "invalid or duplicate identifier in definition")) (let syntmp-loop-665 ((syntmp-bs-666 syntmp-bindings-636) (syntmp-er-cache-667 #f) (syntmp-r-cache-668 #f)) (if (not (null? syntmp-bs-666)) (let ((syntmp-b-669 (car syntmp-bs-666))) (if (eq? (car syntmp-b-669) (quote macro)) (let ((syntmp-er-670 (cadr syntmp-b-669))) (let ((syntmp-r-cache-671 (if (eq? syntmp-er-670 syntmp-er-cache-667) syntmp-r-cache-668 (syntmp-macros-only-env-111 syntmp-er-670)))) (begin (set-cdr! syntmp-b-669 (syntmp-eval-local-transformer-158 (syntmp-chi-151 (cddr syntmp-b-669) syntmp-r-cache-671 (quote (()))))) (syntmp-loop-665 (cdr syntmp-bs-666) syntmp-er-670 syntmp-r-cache-671)))) (syntmp-loop-665 (cdr syntmp-bs-666) syntmp-er-cache-667 syntmp-r-cache-668))))) (set-cdr! syntmp-r-627 (syntmp-extend-env-109 syntmp-labels-633 syntmp-bindings-636 (cdr syntmp-r-627))) (syntmp-build-letrec-99 #f syntmp-vars-634 (map (lambda (syntmp-x-672) (syntmp-chi-151 (cdr syntmp-x-672) (car syntmp-x-672) (quote (())))) syntmp-vals-635) (syntmp-build-sequence-96 #f (map (lambda (syntmp-x-673) (syntmp-chi-151 (cdr syntmp-x-673) (car syntmp-x-673) (quote (())))) (cons (cons syntmp-er-639 (syntmp-source-wrap-144 syntmp-e-642 syntmp-w-643 syntmp-s-644)) (cdr syntmp-body-631)))))))))))))))))))))) (syntmp-chi-macro-154 (lambda (syntmp-p-674 syntmp-e-675 syntmp-r-676 syntmp-w-677 syntmp-rib-678) (letrec ((syntmp-rebuild-macro-output-679 (lambda (syntmp-x-680 syntmp-m-681) (cond ((pair? syntmp-x-680) (cons (syntmp-rebuild-macro-output-679 (car syntmp-x-680) syntmp-m-681) (syntmp-rebuild-macro-output-679 (cdr syntmp-x-680) syntmp-m-681))) ((syntmp-syntax-object?-101 syntmp-x-680) (let ((syntmp-w-682 (syntmp-syntax-object-wrap-103 syntmp-x-680))) (let ((syntmp-ms-683 (syntmp-wrap-marks-118 syntmp-w-682)) (syntmp-s-684 (syntmp-wrap-subst-119 syntmp-w-682))) (syntmp-make-syntax-object-100 (syntmp-syntax-object-expression-102 syntmp-x-680) (if (and (pair? syntmp-ms-683) (eq? (car syntmp-ms-683) #f)) (syntmp-make-wrap-117 (cdr syntmp-ms-683) (if syntmp-rib-678 (cons syntmp-rib-678 (cdr syntmp-s-684)) (cdr syntmp-s-684))) (syntmp-make-wrap-117 (cons syntmp-m-681 syntmp-ms-683) (if syntmp-rib-678 (cons syntmp-rib-678 (cons (quote shift) syntmp-s-684)) (cons (quote shift) syntmp-s-684)))))))) ((vector? syntmp-x-680) (let ((syntmp-n-685 (vector-length syntmp-x-680))) (let ((syntmp-v-686 (make-vector syntmp-n-685))) (let syntmp-doloop-687 ((syntmp-i-688 0)) (if (syntmp-fx=-87 syntmp-i-688 syntmp-n-685) syntmp-v-686 (begin (vector-set! syntmp-v-686 syntmp-i-688 (syntmp-rebuild-macro-output-679 (vector-ref syntmp-x-680 syntmp-i-688) syntmp-m-681)) (syntmp-doloop-687 (syntmp-fx+-85 syntmp-i-688 1)))))))) ((symbol? syntmp-x-680) (syntax-error syntmp-x-680 "encountered raw symbol in macro output")) (else syntmp-x-680))))) (syntmp-rebuild-macro-output-679 (syntmp-p-674 (syntmp-wrap-143 syntmp-e-675 (syntmp-anti-mark-130 syntmp-w-677))) (string #\m))))) (syntmp-chi-application-153 (lambda (syntmp-x-689 syntmp-e-690 syntmp-r-691 syntmp-w-692 syntmp-s-693) ((lambda (syntmp-tmp-694) ((lambda (syntmp-tmp-695) (if syntmp-tmp-695 (apply (lambda (syntmp-e0-696 syntmp-e1-697) (cons syntmp-x-689 (map (lambda (syntmp-e-698) (syntmp-chi-151 syntmp-e-698 syntmp-r-691 syntmp-w-692)) syntmp-e1-697))) syntmp-tmp-695) (syntax-error syntmp-tmp-694))) (syntax-dispatch syntmp-tmp-694 (quote (any . each-any))))) syntmp-e-690))) (syntmp-chi-expr-152 (lambda (syntmp-type-700 syntmp-value-701 syntmp-e-702 syntmp-r-703 syntmp-w-704 syntmp-s-705) (let ((syntmp-t-706 syntmp-type-700)) (if (memv syntmp-t-706 (quote (lexical))) syntmp-value-701 (if (memv syntmp-t-706 (quote (core external-macro))) (syntmp-value-701 syntmp-e-702 syntmp-r-703 syntmp-w-704 syntmp-s-705) (if (memv syntmp-t-706 (quote (lexical-call))) (syntmp-chi-application-153 syntmp-value-701 syntmp-e-702 syntmp-r-703 syntmp-w-704 syntmp-s-705) (if (memv syntmp-t-706 (quote (global-call))) (syntmp-chi-application-153 syntmp-value-701 syntmp-e-702 syntmp-r-703 syntmp-w-704 syntmp-s-705) (if (memv syntmp-t-706 (quote (constant))) (syntmp-build-data-95 syntmp-s-705 (syntmp-strip-162 (syntmp-source-wrap-144 syntmp-e-702 syntmp-w-704 syntmp-s-705) (quote (())))) (if (memv syntmp-t-706 (quote (global))) syntmp-value-701 (if (memv syntmp-t-706 (quote (call))) (syntmp-chi-application-153 (syntmp-chi-151 (car syntmp-e-702) syntmp-r-703 syntmp-w-704) syntmp-e-702 syntmp-r-703 syntmp-w-704 syntmp-s-705) (if (memv syntmp-t-706 (quote (begin-form))) ((lambda (syntmp-tmp-707) ((lambda (syntmp-tmp-708) (if syntmp-tmp-708 (apply (lambda (syntmp-_-709 syntmp-e1-710 syntmp-e2-711) (syntmp-chi-sequence-145 (cons syntmp-e1-710 syntmp-e2-711) syntmp-r-703 syntmp-w-704 syntmp-s-705)) syntmp-tmp-708) (syntax-error syntmp-tmp-707))) (syntax-dispatch syntmp-tmp-707 (quote (any any . each-any))))) syntmp-e-702) (if (memv syntmp-t-706 (quote (local-syntax-form))) (syntmp-chi-local-syntax-157 syntmp-value-701 syntmp-e-702 syntmp-r-703 syntmp-w-704 syntmp-s-705 syntmp-chi-sequence-145) (if (memv syntmp-t-706 (quote (eval-when-form))) ((lambda (syntmp-tmp-713) ((lambda (syntmp-tmp-714) (if syntmp-tmp-714 (apply (lambda (syntmp-_-715 syntmp-x-716 syntmp-e1-717 syntmp-e2-718) (let ((syntmp-when-list-719 (syntmp-chi-when-list-148 syntmp-e-702 syntmp-x-716 syntmp-w-704))) (if (memq (quote eval) syntmp-when-list-719) (syntmp-chi-sequence-145 (cons syntmp-e1-717 syntmp-e2-718) syntmp-r-703 syntmp-w-704 syntmp-s-705) (syntmp-chi-void-159)))) syntmp-tmp-714) (syntax-error syntmp-tmp-713))) (syntax-dispatch syntmp-tmp-713 (quote (any each-any any . each-any))))) syntmp-e-702) (if (memv syntmp-t-706 (quote (define-form define-syntax-form))) (syntax-error (syntmp-wrap-143 syntmp-value-701 syntmp-w-704) "invalid context for definition of") (if (memv syntmp-t-706 (quote (syntax))) (syntax-error (syntmp-source-wrap-144 syntmp-e-702 syntmp-w-704 syntmp-s-705) "reference to pattern variable outside syntax form") (if (memv syntmp-t-706 (quote (displaced-lexical))) (syntax-error (syntmp-source-wrap-144 syntmp-e-702 syntmp-w-704 syntmp-s-705) "reference to identifier outside its scope") (syntax-error (syntmp-source-wrap-144 syntmp-e-702 syntmp-w-704 syntmp-s-705)))))))))))))))))) (syntmp-chi-151 (lambda (syntmp-e-722 syntmp-r-723 syntmp-w-724) (call-with-values (lambda () (syntmp-syntax-type-149 syntmp-e-722 syntmp-r-723 syntmp-w-724 #f #f)) (lambda (syntmp-type-725 syntmp-value-726 syntmp-e-727 syntmp-w-728 syntmp-s-729) (syntmp-chi-expr-152 syntmp-type-725 syntmp-value-726 syntmp-e-727 syntmp-r-723 syntmp-w-728 syntmp-s-729))))) (syntmp-chi-top-150 (lambda (syntmp-e-730 syntmp-r-731 syntmp-w-732 syntmp-m-733 syntmp-esew-734) (call-with-values (lambda () (syntmp-syntax-type-149 syntmp-e-730 syntmp-r-731 syntmp-w-732 #f #f)) (lambda (syntmp-type-747 syntmp-value-748 syntmp-e-749 syntmp-w-750 syntmp-s-751) (let ((syntmp-t-752 syntmp-type-747)) (if (memv syntmp-t-752 (quote (begin-form))) ((lambda (syntmp-tmp-753) ((lambda (syntmp-tmp-754) (if syntmp-tmp-754 (apply (lambda (syntmp-_-755) (syntmp-chi-void-159)) syntmp-tmp-754) ((lambda (syntmp-tmp-756) (if syntmp-tmp-756 (apply (lambda (syntmp-_-757 syntmp-e1-758 syntmp-e2-759) (syntmp-chi-top-sequence-146 (cons syntmp-e1-758 syntmp-e2-759) syntmp-r-731 syntmp-w-750 syntmp-s-751 syntmp-m-733 syntmp-esew-734)) syntmp-tmp-756) (syntax-error syntmp-tmp-753))) (syntax-dispatch syntmp-tmp-753 (quote (any any . each-any)))))) (syntax-dispatch syntmp-tmp-753 (quote (any))))) syntmp-e-749) (if (memv syntmp-t-752 (quote (local-syntax-form))) (syntmp-chi-local-syntax-157 syntmp-value-748 syntmp-e-749 syntmp-r-731 syntmp-w-750 syntmp-s-751 (lambda (syntmp-body-761 syntmp-r-762 syntmp-w-763 syntmp-s-764) (syntmp-chi-top-sequence-146 syntmp-body-761 syntmp-r-762 syntmp-w-763 syntmp-s-764 syntmp-m-733 syntmp-esew-734))) (if (memv syntmp-t-752 (quote (eval-when-form))) ((lambda (syntmp-tmp-765) ((lambda (syntmp-tmp-766) (if syntmp-tmp-766 (apply (lambda (syntmp-_-767 syntmp-x-768 syntmp-e1-769 syntmp-e2-770) (let ((syntmp-when-list-771 (syntmp-chi-when-list-148 syntmp-e-749 syntmp-x-768 syntmp-w-750)) (syntmp-body-772 (cons syntmp-e1-769 syntmp-e2-770))) (cond ((eq? syntmp-m-733 (quote e)) (if (memq (quote eval) syntmp-when-list-771) (syntmp-chi-top-sequence-146 syntmp-body-772 syntmp-r-731 syntmp-w-750 syntmp-s-751 (quote e) (quote (eval))) (syntmp-chi-void-159))) ((memq (quote load) syntmp-when-list-771) (if (or (memq (quote compile) syntmp-when-list-771) (and (eq? syntmp-m-733 (quote c&e)) (memq (quote eval) syntmp-when-list-771))) (syntmp-chi-top-sequence-146 syntmp-body-772 syntmp-r-731 syntmp-w-750 syntmp-s-751 (quote c&e) (quote (compile load))) (if (memq syntmp-m-733 (quote (c c&e))) (syntmp-chi-top-sequence-146 syntmp-body-772 syntmp-r-731 syntmp-w-750 syntmp-s-751 (quote c) (quote (load))) (syntmp-chi-void-159)))) ((or (memq (quote compile) syntmp-when-list-771) (and (eq? syntmp-m-733 (quote c&e)) (memq (quote eval) syntmp-when-list-771))) (syntmp-top-level-eval-hook-90 (syntmp-chi-top-sequence-146 syntmp-body-772 syntmp-r-731 syntmp-w-750 syntmp-s-751 (quote e) (quote (eval)))) (syntmp-chi-void-159)) (else (syntmp-chi-void-159))))) syntmp-tmp-766) (syntax-error syntmp-tmp-765))) (syntax-dispatch syntmp-tmp-765 (quote (any each-any any . each-any))))) syntmp-e-749) (if (memv syntmp-t-752 (quote (define-syntax-form))) (let ((syntmp-n-775 (syntmp-id-var-name-137 syntmp-value-748 syntmp-w-750)) (syntmp-r-776 (syntmp-macros-only-env-111 syntmp-r-731))) (let ((syntmp-t-777 syntmp-m-733)) (if (memv syntmp-t-777 (quote (c))) (if (memq (quote compile) syntmp-esew-734) (let ((syntmp-e-778 (syntmp-chi-install-global-147 syntmp-n-775 (syntmp-chi-151 syntmp-e-749 syntmp-r-776 syntmp-w-750)))) (begin (syntmp-top-level-eval-hook-90 syntmp-e-778) (if (memq (quote load) syntmp-esew-734) syntmp-e-778 (syntmp-chi-void-159)))) (if (memq (quote load) syntmp-esew-734) (syntmp-chi-install-global-147 syntmp-n-775 (syntmp-chi-151 syntmp-e-749 syntmp-r-776 syntmp-w-750)) (syntmp-chi-void-159))) (if (memv syntmp-t-777 (quote (c&e))) (let ((syntmp-e-779 (syntmp-chi-install-global-147 syntmp-n-775 (syntmp-chi-151 syntmp-e-749 syntmp-r-776 syntmp-w-750)))) (begin (syntmp-top-level-eval-hook-90 syntmp-e-779) syntmp-e-779)) (begin (if (memq (quote eval) syntmp-esew-734) (syntmp-top-level-eval-hook-90 (syntmp-chi-install-global-147 syntmp-n-775 (syntmp-chi-151 syntmp-e-749 syntmp-r-776 syntmp-w-750)))) (syntmp-chi-void-159)))))) (if (memv syntmp-t-752 (quote (define-form))) (let ((syntmp-n-780 (syntmp-id-var-name-137 syntmp-value-748 syntmp-w-750))) (let ((syntmp-type-781 (syntmp-binding-type-107 (syntmp-lookup-112 syntmp-n-780 syntmp-r-731)))) (let ((syntmp-t-782 syntmp-type-781)) (if (memv syntmp-t-782 (quote (global))) (let ((syntmp-x-783 (list (quote define) syntmp-n-780 (syntmp-chi-151 syntmp-e-749 syntmp-r-731 syntmp-w-750)))) (begin (if (eq? syntmp-m-733 (quote c&e)) (syntmp-top-level-eval-hook-90 syntmp-x-783)) syntmp-x-783)) (if (memv syntmp-t-782 (quote (displaced-lexical))) (syntax-error (syntmp-wrap-143 syntmp-value-748 syntmp-w-750) "identifier out of context") (if (eq? syntmp-type-781 (quote external-macro)) (let ((syntmp-x-784 (list (quote define) syntmp-n-780 (syntmp-chi-151 syntmp-e-749 syntmp-r-731 syntmp-w-750)))) (begin (if (eq? syntmp-m-733 (quote c&e)) (syntmp-top-level-eval-hook-90 syntmp-x-784)) syntmp-x-784)) (syntax-error (syntmp-wrap-143 syntmp-value-748 syntmp-w-750) "cannot define keyword at top level"))))))) (let ((syntmp-x-785 (syntmp-chi-expr-152 syntmp-type-747 syntmp-value-748 syntmp-e-749 syntmp-r-731 syntmp-w-750 syntmp-s-751))) (begin (if (eq? syntmp-m-733 (quote c&e)) (syntmp-top-level-eval-hook-90 syntmp-x-785)) syntmp-x-785)))))))))))) (syntmp-syntax-type-149 (lambda (syntmp-e-786 syntmp-r-787 syntmp-w-788 syntmp-s-789 syntmp-rib-790) (cond ((symbol? syntmp-e-786) (let ((syntmp-n-791 (syntmp-id-var-name-137 syntmp-e-786 syntmp-w-788))) (let ((syntmp-b-792 (syntmp-lookup-112 syntmp-n-791 syntmp-r-787))) (let ((syntmp-type-793 (syntmp-binding-type-107 syntmp-b-792))) (let ((syntmp-t-794 syntmp-type-793)) (if (memv syntmp-t-794 (quote (lexical))) (values syntmp-type-793 (syntmp-binding-value-108 syntmp-b-792) syntmp-e-786 syntmp-w-788 syntmp-s-789) (if (memv syntmp-t-794 (quote (global))) (values syntmp-type-793 syntmp-n-791 syntmp-e-786 syntmp-w-788 syntmp-s-789) (if (memv syntmp-t-794 (quote (macro))) (syntmp-syntax-type-149 (syntmp-chi-macro-154 (syntmp-binding-value-108 syntmp-b-792) syntmp-e-786 syntmp-r-787 syntmp-w-788 syntmp-rib-790) syntmp-r-787 (quote (())) syntmp-s-789 syntmp-rib-790) (values syntmp-type-793 (syntmp-binding-value-108 syntmp-b-792) syntmp-e-786 syntmp-w-788 syntmp-s-789))))))))) ((pair? syntmp-e-786) (let ((syntmp-first-795 (car syntmp-e-786))) (if (syntmp-id?-115 syntmp-first-795) (let ((syntmp-n-796 (syntmp-id-var-name-137 syntmp-first-795 syntmp-w-788))) (let ((syntmp-b-797 (syntmp-lookup-112 syntmp-n-796 syntmp-r-787))) (let ((syntmp-type-798 (syntmp-binding-type-107 syntmp-b-797))) (let ((syntmp-t-799 syntmp-type-798)) (if (memv syntmp-t-799 (quote (lexical))) (values (quote lexical-call) (syntmp-binding-value-108 syntmp-b-797) syntmp-e-786 syntmp-w-788 syntmp-s-789) (if (memv syntmp-t-799 (quote (global))) (values (quote global-call) syntmp-n-796 syntmp-e-786 syntmp-w-788 syntmp-s-789) (if (memv syntmp-t-799 (quote (macro))) (syntmp-syntax-type-149 (syntmp-chi-macro-154 (syntmp-binding-value-108 syntmp-b-797) syntmp-e-786 syntmp-r-787 syntmp-w-788 syntmp-rib-790) syntmp-r-787 (quote (())) syntmp-s-789 syntmp-rib-790) (if (memv syntmp-t-799 (quote (core external-macro))) (values syntmp-type-798 (syntmp-binding-value-108 syntmp-b-797) syntmp-e-786 syntmp-w-788 syntmp-s-789) (if (memv syntmp-t-799 (quote (local-syntax))) (values (quote local-syntax-form) (syntmp-binding-value-108 syntmp-b-797) syntmp-e-786 syntmp-w-788 syntmp-s-789) (if (memv syntmp-t-799 (quote (begin))) (values (quote begin-form) #f syntmp-e-786 syntmp-w-788 syntmp-s-789) (if (memv syntmp-t-799 (quote (eval-when))) (values (quote eval-when-form) #f syntmp-e-786 syntmp-w-788 syntmp-s-789) (if (memv syntmp-t-799 (quote (define))) ((lambda (syntmp-tmp-800) ((lambda (syntmp-tmp-801) (if (if syntmp-tmp-801 (apply (lambda (syntmp-_-802 syntmp-name-803 syntmp-val-804) (syntmp-id?-115 syntmp-name-803)) syntmp-tmp-801) #f) (apply (lambda (syntmp-_-805 syntmp-name-806 syntmp-val-807) (values (quote define-form) syntmp-name-806 syntmp-val-807 syntmp-w-788 syntmp-s-789)) syntmp-tmp-801) ((lambda (syntmp-tmp-808) (if (if syntmp-tmp-808 (apply (lambda (syntmp-_-809 syntmp-name-810 syntmp-args-811 syntmp-e1-812 syntmp-e2-813) (and (syntmp-id?-115 syntmp-name-810) (syntmp-valid-bound-ids?-140 (syntmp-lambda-var-list-164 syntmp-args-811)))) syntmp-tmp-808) #f) (apply (lambda (syntmp-_-814 syntmp-name-815 syntmp-args-816 syntmp-e1-817 syntmp-e2-818) (values (quote define-form) (syntmp-wrap-143 syntmp-name-815 syntmp-w-788) (cons (quote #(syntax-object lambda ((top) #(ribcage #(_ name args e1 e2) #((top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(t) #(("m" top)) #("i")) #(ribcage () () ()) #(ribcage () () ()) #(ribcage () () ()) #(ribcage #(type) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(b) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(n) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(first) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(e r w s rib) #((top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i")) #(ribcage (lambda-var-list gen-var strip strip-annotation ellipsis? chi-void eval-local-transformer chi-local-syntax chi-lambda-clause chi-body chi-macro chi-application chi-expr chi chi-top syntax-type chi-when-list chi-install-global chi-top-sequence chi-sequence source-wrap wrap bound-id-member? distinct-bound-ids? valid-bound-ids? bound-id=? free-id=? id-var-name same-marks? join-marks join-wraps smart-append make-binding-wrap extend-ribcage! make-empty-ribcage new-mark anti-mark the-anti-mark top-marked? top-wrap empty-wrap set-ribcage-labels! set-ribcage-marks! set-ribcage-symnames! ribcage-labels ribcage-marks ribcage-symnames ribcage? make-ribcage gen-labels gen-label make-rename rename-marks rename-new rename-old subst-rename? wrap-subst wrap-marks make-wrap id-sym-name&marks id-sym-name id? nonsymbol-id? global-extend lookup macros-only-env extend-var-env extend-env null-env binding-value binding-type make-binding arg-check source-annotation no-source unannotate set-syntax-object-wrap! set-syntax-object-expression! syntax-object-wrap syntax-object-expression syntax-object? make-syntax-object build-lexical-var build-letrec build-named-let build-let build-sequence build-data build-primref build-lambda build-global-definition build-global-assignment build-global-reference build-lexical-assignment build-lexical-reference build-conditional build-application get-global-definition-hook put-global-definition-hook gensym-hook error-hook local-eval-hook top-level-eval-hook annotation? fx< fx= fx- fx+ noexpand) ((top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top)) ("i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i")) #(ribcage (define-structure) ((top)) ("i"))))) (syntmp-wrap-143 (cons syntmp-args-816 (cons syntmp-e1-817 syntmp-e2-818)) syntmp-w-788)) (quote (())) syntmp-s-789)) syntmp-tmp-808) ((lambda (syntmp-tmp-820) (if (if syntmp-tmp-820 (apply (lambda (syntmp-_-821 syntmp-name-822) (syntmp-id?-115 syntmp-name-822)) syntmp-tmp-820) #f) (apply (lambda (syntmp-_-823 syntmp-name-824) (values (quote define-form) (syntmp-wrap-143 syntmp-name-824 syntmp-w-788) (quote (#(syntax-object void ((top) #(ribcage #(_ name) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage #(t) #(("m" top)) #("i")) #(ribcage () () ()) #(ribcage () () ()) #(ribcage () () ()) #(ribcage #(type) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(b) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(n) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(first) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(e r w s rib) #((top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i")) #(ribcage (lambda-var-list gen-var strip strip-annotation ellipsis? chi-void eval-local-transformer chi-local-syntax chi-lambda-clause chi-body chi-macro chi-application chi-expr chi chi-top syntax-type chi-when-list chi-install-global chi-top-sequence chi-sequence source-wrap wrap bound-id-member? distinct-bound-ids? valid-bound-ids? bound-id=? free-id=? id-var-name same-marks? join-marks join-wraps smart-append make-binding-wrap extend-ribcage! make-empty-ribcage new-mark anti-mark the-anti-mark top-marked? top-wrap empty-wrap set-ribcage-labels! set-ribcage-marks! set-ribcage-symnames! ribcage-labels ribcage-marks ribcage-symnames ribcage? make-ribcage gen-labels gen-label make-rename rename-marks rename-new rename-old subst-rename? wrap-subst wrap-marks make-wrap id-sym-name&marks id-sym-name id? nonsymbol-id? global-extend lookup macros-only-env extend-var-env extend-env null-env binding-value binding-type make-binding arg-check source-annotation no-source unannotate set-syntax-object-wrap! set-syntax-object-expression! syntax-object-wrap syntax-object-expression syntax-object? make-syntax-object build-lexical-var build-letrec build-named-let build-let build-sequence build-data build-primref build-lambda build-global-definition build-global-assignment build-global-reference build-lexical-assignment build-lexical-reference build-conditional build-application get-global-definition-hook put-global-definition-hook gensym-hook error-hook local-eval-hook top-level-eval-hook annotation? fx< fx= fx- fx+ noexpand) ((top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top)) ("i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i")) #(ribcage (define-structure) ((top)) ("i")))))) (quote (())) syntmp-s-789)) syntmp-tmp-820) (syntax-error syntmp-tmp-800))) (syntax-dispatch syntmp-tmp-800 (quote (any any)))))) (syntax-dispatch syntmp-tmp-800 (quote (any (any . any) any . each-any)))))) (syntax-dispatch syntmp-tmp-800 (quote (any any any))))) syntmp-e-786) (if (memv syntmp-t-799 (quote (define-syntax))) ((lambda (syntmp-tmp-825) ((lambda (syntmp-tmp-826) (if (if syntmp-tmp-826 (apply (lambda (syntmp-_-827 syntmp-name-828 syntmp-val-829) (syntmp-id?-115 syntmp-name-828)) syntmp-tmp-826) #f) (apply (lambda (syntmp-_-830 syntmp-name-831 syntmp-val-832) (values (quote define-syntax-form) syntmp-name-831 syntmp-val-832 syntmp-w-788 syntmp-s-789)) syntmp-tmp-826) (syntax-error syntmp-tmp-825))) (syntax-dispatch syntmp-tmp-825 (quote (any any any))))) syntmp-e-786) (values (quote call) #f syntmp-e-786 syntmp-w-788 syntmp-s-789)))))))))))))) (values (quote call) #f syntmp-e-786 syntmp-w-788 syntmp-s-789)))) ((syntmp-syntax-object?-101 syntmp-e-786) (syntmp-syntax-type-149 (syntmp-syntax-object-expression-102 syntmp-e-786) syntmp-r-787 (syntmp-join-wraps-134 syntmp-w-788 (syntmp-syntax-object-wrap-103 syntmp-e-786)) #f syntmp-rib-790)) ((syntmp-annotation?-89 syntmp-e-786) (syntmp-syntax-type-149 (annotation-expression syntmp-e-786) syntmp-r-787 syntmp-w-788 (annotation-source syntmp-e-786) syntmp-rib-790)) ((self-evaluating? syntmp-e-786) (values (quote constant) #f syntmp-e-786 syntmp-w-788 syntmp-s-789)) (else (values (quote other) #f syntmp-e-786 syntmp-w-788 syntmp-s-789))))) (syntmp-chi-when-list-148 (lambda (syntmp-e-833 syntmp-when-list-834 syntmp-w-835) (let syntmp-f-836 ((syntmp-when-list-837 syntmp-when-list-834) (syntmp-situations-838 (quote ()))) (if (null? syntmp-when-list-837) syntmp-situations-838 (syntmp-f-836 (cdr syntmp-when-list-837) (cons (let ((syntmp-x-839 (car syntmp-when-list-837))) (cond ((syntmp-free-id=?-138 syntmp-x-839 (quote #(syntax-object compile ((top) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(f when-list situations) #((top) (top) (top)) #("i" "i" "i")) #(ribcage () () ()) #(ribcage #(e when-list w) #((top) (top) (top)) #("i" "i" "i")) #(ribcage (lambda-var-list gen-var strip strip-annotation ellipsis? chi-void eval-local-transformer chi-local-syntax chi-lambda-clause chi-body chi-macro chi-application chi-expr chi chi-top syntax-type chi-when-list chi-install-global chi-top-sequence chi-sequence source-wrap wrap bound-id-member? distinct-bound-ids? valid-bound-ids? bound-id=? free-id=? id-var-name same-marks? join-marks join-wraps smart-append make-binding-wrap extend-ribcage! make-empty-ribcage new-mark anti-mark the-anti-mark top-marked? top-wrap empty-wrap set-ribcage-labels! set-ribcage-marks! set-ribcage-symnames! ribcage-labels ribcage-marks ribcage-symnames ribcage? make-ribcage gen-labels gen-label make-rename rename-marks rename-new rename-old subst-rename? wrap-subst wrap-marks make-wrap id-sym-name&marks id-sym-name id? nonsymbol-id? global-extend lookup macros-only-env extend-var-env extend-env null-env binding-value binding-type make-binding arg-check source-annotation no-source unannotate set-syntax-object-wrap! set-syntax-object-expression! syntax-object-wrap syntax-object-expression syntax-object? make-syntax-object build-lexical-var build-letrec build-named-let build-let build-sequence build-data build-primref build-lambda build-global-definition build-global-assignment build-global-reference build-lexical-assignment build-lexical-reference build-conditional build-application get-global-definition-hook put-global-definition-hook gensym-hook error-hook local-eval-hook top-level-eval-hook annotation? fx< fx= fx- fx+ noexpand) ((top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top)) ("i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i")) #(ribcage (define-structure) ((top)) ("i")))))) (quote compile)) ((syntmp-free-id=?-138 syntmp-x-839 (quote #(syntax-object load ((top) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(f when-list situations) #((top) (top) (top)) #("i" "i" "i")) #(ribcage () () ()) #(ribcage #(e when-list w) #((top) (top) (top)) #("i" "i" "i")) #(ribcage (lambda-var-list gen-var strip strip-annotation ellipsis? chi-void eval-local-transformer chi-local-syntax chi-lambda-clause chi-body chi-macro chi-application chi-expr chi chi-top syntax-type chi-when-list chi-install-global chi-top-sequence chi-sequence source-wrap wrap bound-id-member? distinct-bound-ids? valid-bound-ids? bound-id=? free-id=? id-var-name same-marks? join-marks join-wraps smart-append make-binding-wrap extend-ribcage! make-empty-ribcage new-mark anti-mark the-anti-mark top-marked? top-wrap empty-wrap set-ribcage-labels! set-ribcage-marks! set-ribcage-symnames! ribcage-labels ribcage-marks ribcage-symnames ribcage? make-ribcage gen-labels gen-label make-rename rename-marks rename-new rename-old subst-rename? wrap-subst wrap-marks make-wrap id-sym-name&marks id-sym-name id? nonsymbol-id? global-extend lookup macros-only-env extend-var-env extend-env null-env binding-value binding-type make-binding arg-check source-annotation no-source unannotate set-syntax-object-wrap! set-syntax-object-expression! syntax-object-wrap syntax-object-expression syntax-object? make-syntax-object build-lexical-var build-letrec build-named-let build-let build-sequence build-data build-primref build-lambda build-global-definition build-global-assignment build-global-reference build-lexical-assignment build-lexical-reference build-conditional build-application get-global-definition-hook put-global-definition-hook gensym-hook error-hook local-eval-hook top-level-eval-hook annotation? fx< fx= fx- fx+ noexpand) ((top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top)) ("i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i")) #(ribcage (define-structure) ((top)) ("i")))))) (quote load)) ((syntmp-free-id=?-138 syntmp-x-839 (quote #(syntax-object eval ((top) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(f when-list situations) #((top) (top) (top)) #("i" "i" "i")) #(ribcage () () ()) #(ribcage #(e when-list w) #((top) (top) (top)) #("i" "i" "i")) #(ribcage (lambda-var-list gen-var strip strip-annotation ellipsis? chi-void eval-local-transformer chi-local-syntax chi-lambda-clause chi-body chi-macro chi-application chi-expr chi chi-top syntax-type chi-when-list chi-install-global chi-top-sequence chi-sequence source-wrap wrap bound-id-member? distinct-bound-ids? valid-bound-ids? bound-id=? free-id=? id-var-name same-marks? join-marks join-wraps smart-append make-binding-wrap extend-ribcage! make-empty-ribcage new-mark anti-mark the-anti-mark top-marked? top-wrap empty-wrap set-ribcage-labels! set-ribcage-marks! set-ribcage-symnames! ribcage-labels ribcage-marks ribcage-symnames ribcage? make-ribcage gen-labels gen-label make-rename rename-marks rename-new rename-old subst-rename? wrap-subst wrap-marks make-wrap id-sym-name&marks id-sym-name id? nonsymbol-id? global-extend lookup macros-only-env extend-var-env extend-env null-env binding-value binding-type make-binding arg-check source-annotation no-source unannotate set-syntax-object-wrap! set-syntax-object-expression! syntax-object-wrap syntax-object-expression syntax-object? make-syntax-object build-lexical-var build-letrec build-named-let build-let build-sequence build-data build-primref build-lambda build-global-definition build-global-assignment build-global-reference build-lexical-assignment build-lexical-reference build-conditional build-application get-global-definition-hook put-global-definition-hook gensym-hook error-hook local-eval-hook top-level-eval-hook annotation? fx< fx= fx- fx+ noexpand) ((top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top)) ("i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i")) #(ribcage (define-structure) ((top)) ("i")))))) (quote eval)) (else (syntax-error (syntmp-wrap-143 syntmp-x-839 syntmp-w-835) "invalid eval-when situation")))) syntmp-situations-838)))))) (syntmp-chi-install-global-147 (lambda (syntmp-name-840 syntmp-e-841) (list (quote install-global-transformer) (syntmp-build-data-95 #f syntmp-name-840) syntmp-e-841))) (syntmp-chi-top-sequence-146 (lambda (syntmp-body-842 syntmp-r-843 syntmp-w-844 syntmp-s-845 syntmp-m-846 syntmp-esew-847) (syntmp-build-sequence-96 syntmp-s-845 (let syntmp-dobody-848 ((syntmp-body-849 syntmp-body-842) (syntmp-r-850 syntmp-r-843) (syntmp-w-851 syntmp-w-844) (syntmp-m-852 syntmp-m-846) (syntmp-esew-853 syntmp-esew-847)) (if (null? syntmp-body-849) (quote ()) (let ((syntmp-first-854 (syntmp-chi-top-150 (car syntmp-body-849) syntmp-r-850 syntmp-w-851 syntmp-m-852 syntmp-esew-853))) (cons syntmp-first-854 (syntmp-dobody-848 (cdr syntmp-body-849) syntmp-r-850 syntmp-w-851 syntmp-m-852 syntmp-esew-853)))))))) (syntmp-chi-sequence-145 (lambda (syntmp-body-855 syntmp-r-856 syntmp-w-857 syntmp-s-858) (syntmp-build-sequence-96 syntmp-s-858 (let syntmp-dobody-859 ((syntmp-body-860 syntmp-body-855) (syntmp-r-861 syntmp-r-856) (syntmp-w-862 syntmp-w-857)) (if (null? syntmp-body-860) (quote ()) (let ((syntmp-first-863 (syntmp-chi-151 (car syntmp-body-860) syntmp-r-861 syntmp-w-862))) (cons syntmp-first-863 (syntmp-dobody-859 (cdr syntmp-body-860) syntmp-r-861 syntmp-w-862)))))))) (syntmp-source-wrap-144 (lambda (syntmp-x-864 syntmp-w-865 syntmp-s-866) (syntmp-wrap-143 (if syntmp-s-866 (make-annotation syntmp-x-864 syntmp-s-866 #f) syntmp-x-864) syntmp-w-865))) (syntmp-wrap-143 (lambda (syntmp-x-867 syntmp-w-868) (cond ((and (null? (syntmp-wrap-marks-118 syntmp-w-868)) (null? (syntmp-wrap-subst-119 syntmp-w-868))) syntmp-x-867) ((syntmp-syntax-object?-101 syntmp-x-867) (syntmp-make-syntax-object-100 (syntmp-syntax-object-expression-102 syntmp-x-867) (syntmp-join-wraps-134 syntmp-w-868 (syntmp-syntax-object-wrap-103 syntmp-x-867)))) ((null? syntmp-x-867) syntmp-x-867) (else (syntmp-make-syntax-object-100 syntmp-x-867 syntmp-w-868))))) (syntmp-bound-id-member?-142 (lambda (syntmp-x-869 syntmp-list-870) (and (not (null? syntmp-list-870)) (or (syntmp-bound-id=?-139 syntmp-x-869 (car syntmp-list-870)) (syntmp-bound-id-member?-142 syntmp-x-869 (cdr syntmp-list-870)))))) (syntmp-distinct-bound-ids?-141 (lambda (syntmp-ids-871) (let syntmp-distinct?-872 ((syntmp-ids-873 syntmp-ids-871)) (or (null? syntmp-ids-873) (and (not (syntmp-bound-id-member?-142 (car syntmp-ids-873) (cdr syntmp-ids-873))) (syntmp-distinct?-872 (cdr syntmp-ids-873))))))) (syntmp-valid-bound-ids?-140 (lambda (syntmp-ids-874) (and (let syntmp-all-ids?-875 ((syntmp-ids-876 syntmp-ids-874)) (or (null? syntmp-ids-876) (and (syntmp-id?-115 (car syntmp-ids-876)) (syntmp-all-ids?-875 (cdr syntmp-ids-876))))) (syntmp-distinct-bound-ids?-141 syntmp-ids-874)))) (syntmp-bound-id=?-139 (lambda (syntmp-i-877 syntmp-j-878) (if (and (syntmp-syntax-object?-101 syntmp-i-877) (syntmp-syntax-object?-101 syntmp-j-878)) (and (eq? (let ((syntmp-e-879 (syntmp-syntax-object-expression-102 syntmp-i-877))) (if (syntmp-annotation?-89 syntmp-e-879) (annotation-expression syntmp-e-879) syntmp-e-879)) (let ((syntmp-e-880 (syntmp-syntax-object-expression-102 syntmp-j-878))) (if (syntmp-annotation?-89 syntmp-e-880) (annotation-expression syntmp-e-880) syntmp-e-880))) (syntmp-same-marks?-136 (syntmp-wrap-marks-118 (syntmp-syntax-object-wrap-103 syntmp-i-877)) (syntmp-wrap-marks-118 (syntmp-syntax-object-wrap-103 syntmp-j-878)))) (eq? (let ((syntmp-e-881 syntmp-i-877)) (if (syntmp-annotation?-89 syntmp-e-881) (annotation-expression syntmp-e-881) syntmp-e-881)) (let ((syntmp-e-882 syntmp-j-878)) (if (syntmp-annotation?-89 syntmp-e-882) (annotation-expression syntmp-e-882) syntmp-e-882)))))) (syntmp-free-id=?-138 (lambda (syntmp-i-883 syntmp-j-884) (and (eq? (let ((syntmp-x-885 syntmp-i-883)) (let ((syntmp-e-886 (if (syntmp-syntax-object?-101 syntmp-x-885) (syntmp-syntax-object-expression-102 syntmp-x-885) syntmp-x-885))) (if (syntmp-annotation?-89 syntmp-e-886) (annotation-expression syntmp-e-886) syntmp-e-886))) (let ((syntmp-x-887 syntmp-j-884)) (let ((syntmp-e-888 (if (syntmp-syntax-object?-101 syntmp-x-887) (syntmp-syntax-object-expression-102 syntmp-x-887) syntmp-x-887))) (if (syntmp-annotation?-89 syntmp-e-888) (annotation-expression syntmp-e-888) syntmp-e-888)))) (eq? (syntmp-id-var-name-137 syntmp-i-883 (quote (()))) (syntmp-id-var-name-137 syntmp-j-884 (quote (()))))))) (syntmp-id-var-name-137 (lambda (syntmp-id-889 syntmp-w-890) (letrec ((syntmp-search-vector-rib-893 (lambda (syntmp-sym-904 syntmp-subst-905 syntmp-marks-906 syntmp-symnames-907 syntmp-ribcage-908) (let ((syntmp-n-909 (vector-length syntmp-symnames-907))) (let syntmp-f-910 ((syntmp-i-911 0)) (cond ((syntmp-fx=-87 syntmp-i-911 syntmp-n-909) (syntmp-search-891 syntmp-sym-904 (cdr syntmp-subst-905) syntmp-marks-906)) ((and (eq? (vector-ref syntmp-symnames-907 syntmp-i-911) syntmp-sym-904) (syntmp-same-marks?-136 syntmp-marks-906 (vector-ref (syntmp-ribcage-marks-125 syntmp-ribcage-908) syntmp-i-911))) (values (vector-ref (syntmp-ribcage-labels-126 syntmp-ribcage-908) syntmp-i-911) syntmp-marks-906)) (else (syntmp-f-910 (syntmp-fx+-85 syntmp-i-911 1)))))))) (syntmp-search-list-rib-892 (lambda (syntmp-sym-912 syntmp-subst-913 syntmp-marks-914 syntmp-symnames-915 syntmp-ribcage-916) (let syntmp-f-917 ((syntmp-symnames-918 syntmp-symnames-915) (syntmp-i-919 0)) (cond ((null? syntmp-symnames-918) (syntmp-search-891 syntmp-sym-912 (cdr syntmp-subst-913) syntmp-marks-914)) ((and (eq? (car syntmp-symnames-918) syntmp-sym-912) (syntmp-same-marks?-136 syntmp-marks-914 (list-ref (syntmp-ribcage-marks-125 syntmp-ribcage-916) syntmp-i-919))) (values (list-ref (syntmp-ribcage-labels-126 syntmp-ribcage-916) syntmp-i-919) syntmp-marks-914)) (else (syntmp-f-917 (cdr syntmp-symnames-918) (syntmp-fx+-85 syntmp-i-919 1))))))) (syntmp-search-891 (lambda (syntmp-sym-920 syntmp-subst-921 syntmp-marks-922) (if (null? syntmp-subst-921) (values #f syntmp-marks-922) (let ((syntmp-fst-923 (car syntmp-subst-921))) (if (eq? syntmp-fst-923 (quote shift)) (syntmp-search-891 syntmp-sym-920 (cdr syntmp-subst-921) (cdr syntmp-marks-922)) (let ((syntmp-symnames-924 (syntmp-ribcage-symnames-124 syntmp-fst-923))) (if (vector? syntmp-symnames-924) (syntmp-search-vector-rib-893 syntmp-sym-920 syntmp-subst-921 syntmp-marks-922 syntmp-symnames-924 syntmp-fst-923) (syntmp-search-list-rib-892 syntmp-sym-920 syntmp-subst-921 syntmp-marks-922 syntmp-symnames-924 syntmp-fst-923))))))))) (cond ((symbol? syntmp-id-889) (or (call-with-values (lambda () (syntmp-search-891 syntmp-id-889 (syntmp-wrap-subst-119 syntmp-w-890) (syntmp-wrap-marks-118 syntmp-w-890))) (lambda (syntmp-x-926 . syntmp-ignore-925) syntmp-x-926)) syntmp-id-889)) ((syntmp-syntax-object?-101 syntmp-id-889) (let ((syntmp-id-927 (let ((syntmp-e-929 (syntmp-syntax-object-expression-102 syntmp-id-889))) (if (syntmp-annotation?-89 syntmp-e-929) (annotation-expression syntmp-e-929) syntmp-e-929))) (syntmp-w1-928 (syntmp-syntax-object-wrap-103 syntmp-id-889))) (let ((syntmp-marks-930 (syntmp-join-marks-135 (syntmp-wrap-marks-118 syntmp-w-890) (syntmp-wrap-marks-118 syntmp-w1-928)))) (call-with-values (lambda () (syntmp-search-891 syntmp-id-927 (syntmp-wrap-subst-119 syntmp-w-890) syntmp-marks-930)) (lambda (syntmp-new-id-931 syntmp-marks-932) (or syntmp-new-id-931 (call-with-values (lambda () (syntmp-search-891 syntmp-id-927 (syntmp-wrap-subst-119 syntmp-w1-928) syntmp-marks-932)) (lambda (syntmp-x-934 . syntmp-ignore-933) syntmp-x-934)) syntmp-id-927)))))) ((syntmp-annotation?-89 syntmp-id-889) (let ((syntmp-id-935 (let ((syntmp-e-936 syntmp-id-889)) (if (syntmp-annotation?-89 syntmp-e-936) (annotation-expression syntmp-e-936) syntmp-e-936)))) (or (call-with-values (lambda () (syntmp-search-891 syntmp-id-935 (syntmp-wrap-subst-119 syntmp-w-890) (syntmp-wrap-marks-118 syntmp-w-890))) (lambda (syntmp-x-938 . syntmp-ignore-937) syntmp-x-938)) syntmp-id-935))) (else (syntmp-error-hook-92 (quote id-var-name) "invalid id" syntmp-id-889)))))) (syntmp-same-marks?-136 (lambda (syntmp-x-939 syntmp-y-940) (or (eq? syntmp-x-939 syntmp-y-940) (and (not (null? syntmp-x-939)) (not (null? syntmp-y-940)) (eq? (car syntmp-x-939) (car syntmp-y-940)) (syntmp-same-marks?-136 (cdr syntmp-x-939) (cdr syntmp-y-940)))))) (syntmp-join-marks-135 (lambda (syntmp-m1-941 syntmp-m2-942) (syntmp-smart-append-133 syntmp-m1-941 syntmp-m2-942))) (syntmp-join-wraps-134 (lambda (syntmp-w1-943 syntmp-w2-944) (let ((syntmp-m1-945 (syntmp-wrap-marks-118 syntmp-w1-943)) (syntmp-s1-946 (syntmp-wrap-subst-119 syntmp-w1-943))) (if (null? syntmp-m1-945) (if (null? syntmp-s1-946) syntmp-w2-944 (syntmp-make-wrap-117 (syntmp-wrap-marks-118 syntmp-w2-944) (syntmp-smart-append-133 syntmp-s1-946 (syntmp-wrap-subst-119 syntmp-w2-944)))) (syntmp-make-wrap-117 (syntmp-smart-append-133 syntmp-m1-945 (syntmp-wrap-marks-118 syntmp-w2-944)) (syntmp-smart-append-133 syntmp-s1-946 (syntmp-wrap-subst-119 syntmp-w2-944))))))) (syntmp-smart-append-133 (lambda (syntmp-m1-947 syntmp-m2-948) (if (null? syntmp-m2-948) syntmp-m1-947 (append syntmp-m1-947 syntmp-m2-948)))) (syntmp-make-binding-wrap-132 (lambda (syntmp-ids-949 syntmp-labels-950 syntmp-w-951) (if (null? syntmp-ids-949) syntmp-w-951 (syntmp-make-wrap-117 (syntmp-wrap-marks-118 syntmp-w-951) (cons (let ((syntmp-labelvec-952 (list->vector syntmp-labels-950))) (let ((syntmp-n-953 (vector-length syntmp-labelvec-952))) (let ((syntmp-symnamevec-954 (make-vector syntmp-n-953)) (syntmp-marksvec-955 (make-vector syntmp-n-953))) (begin (let syntmp-f-956 ((syntmp-ids-957 syntmp-ids-949) (syntmp-i-958 0)) (if (not (null? syntmp-ids-957)) (call-with-values (lambda () (syntmp-id-sym-name&marks-116 (car syntmp-ids-957) syntmp-w-951)) (lambda (syntmp-symname-959 syntmp-marks-960) (begin (vector-set! syntmp-symnamevec-954 syntmp-i-958 syntmp-symname-959) (vector-set! syntmp-marksvec-955 syntmp-i-958 syntmp-marks-960) (syntmp-f-956 (cdr syntmp-ids-957) (syntmp-fx+-85 syntmp-i-958 1))))))) (syntmp-make-ribcage-122 syntmp-symnamevec-954 syntmp-marksvec-955 syntmp-labelvec-952))))) (syntmp-wrap-subst-119 syntmp-w-951)))))) (syntmp-extend-ribcage!-131 (lambda (syntmp-ribcage-961 syntmp-id-962 syntmp-label-963) (begin (syntmp-set-ribcage-symnames!-127 syntmp-ribcage-961 (cons (let ((syntmp-e-964 (syntmp-syntax-object-expression-102 syntmp-id-962))) (if (syntmp-annotation?-89 syntmp-e-964) (annotation-expression syntmp-e-964) syntmp-e-964)) (syntmp-ribcage-symnames-124 syntmp-ribcage-961))) (syntmp-set-ribcage-marks!-128 syntmp-ribcage-961 (cons (syntmp-wrap-marks-118 (syntmp-syntax-object-wrap-103 syntmp-id-962)) (syntmp-ribcage-marks-125 syntmp-ribcage-961))) (syntmp-set-ribcage-labels!-129 syntmp-ribcage-961 (cons syntmp-label-963 (syntmp-ribcage-labels-126 syntmp-ribcage-961)))))) (syntmp-anti-mark-130 (lambda (syntmp-w-965) (syntmp-make-wrap-117 (cons #f (syntmp-wrap-marks-118 syntmp-w-965)) (cons (quote shift) (syntmp-wrap-subst-119 syntmp-w-965))))) (syntmp-set-ribcage-labels!-129 (lambda (syntmp-x-966 syntmp-update-967) (vector-set! syntmp-x-966 3 syntmp-update-967))) (syntmp-set-ribcage-marks!-128 (lambda (syntmp-x-968 syntmp-update-969) (vector-set! syntmp-x-968 2 syntmp-update-969))) (syntmp-set-ribcage-symnames!-127 (lambda (syntmp-x-970 syntmp-update-971) (vector-set! syntmp-x-970 1 syntmp-update-971))) (syntmp-ribcage-labels-126 (lambda (syntmp-x-972) (vector-ref syntmp-x-972 3))) (syntmp-ribcage-marks-125 (lambda (syntmp-x-973) (vector-ref syntmp-x-973 2))) (syntmp-ribcage-symnames-124 (lambda (syntmp-x-974) (vector-ref syntmp-x-974 1))) (syntmp-ribcage?-123 (lambda (syntmp-x-975) (and (vector? syntmp-x-975) (= (vector-length syntmp-x-975) 4) (eq? (vector-ref syntmp-x-975 0) (quote ribcage))))) (syntmp-make-ribcage-122 (lambda (syntmp-symnames-976 syntmp-marks-977 syntmp-labels-978) (vector (quote ribcage) syntmp-symnames-976 syntmp-marks-977 syntmp-labels-978))) (syntmp-gen-labels-121 (lambda (syntmp-ls-979) (if (null? syntmp-ls-979) (quote ()) (cons (syntmp-gen-label-120) (syntmp-gen-labels-121 (cdr syntmp-ls-979)))))) (syntmp-gen-label-120 (lambda () (string #\i))) (syntmp-wrap-subst-119 cdr) (syntmp-wrap-marks-118 car) (syntmp-make-wrap-117 cons) (syntmp-id-sym-name&marks-116 (lambda (syntmp-x-980 syntmp-w-981) (if (syntmp-syntax-object?-101 syntmp-x-980) (values (let ((syntmp-e-982 (syntmp-syntax-object-expression-102 syntmp-x-980))) (if (syntmp-annotation?-89 syntmp-e-982) (annotation-expression syntmp-e-982) syntmp-e-982)) (syntmp-join-marks-135 (syntmp-wrap-marks-118 syntmp-w-981) (syntmp-wrap-marks-118 (syntmp-syntax-object-wrap-103 syntmp-x-980)))) (values (let ((syntmp-e-983 syntmp-x-980)) (if (syntmp-annotation?-89 syntmp-e-983) (annotation-expression syntmp-e-983) syntmp-e-983)) (syntmp-wrap-marks-118 syntmp-w-981))))) (syntmp-id?-115 (lambda (syntmp-x-984) (cond ((symbol? syntmp-x-984) #t) ((syntmp-syntax-object?-101 syntmp-x-984) (symbol? (let ((syntmp-e-985 (syntmp-syntax-object-expression-102 syntmp-x-984))) (if (syntmp-annotation?-89 syntmp-e-985) (annotation-expression syntmp-e-985) syntmp-e-985)))) ((syntmp-annotation?-89 syntmp-x-984) (symbol? (annotation-expression syntmp-x-984))) (else #f)))) (syntmp-nonsymbol-id?-114 (lambda (syntmp-x-986) (and (syntmp-syntax-object?-101 syntmp-x-986) (symbol? (let ((syntmp-e-987 (syntmp-syntax-object-expression-102 syntmp-x-986))) (if (syntmp-annotation?-89 syntmp-e-987) (annotation-expression syntmp-e-987) syntmp-e-987)))))) (syntmp-global-extend-113 (lambda (syntmp-type-988 syntmp-sym-989 syntmp-val-990) (syntmp-put-global-definition-hook-93 syntmp-sym-989 (cons syntmp-type-988 syntmp-val-990)))) (syntmp-lookup-112 (lambda (syntmp-x-991 syntmp-r-992) (cond ((assq syntmp-x-991 syntmp-r-992) => cdr) ((symbol? syntmp-x-991) (or (syntmp-get-global-definition-hook-94 syntmp-x-991) (quote (global)))) (else (quote (displaced-lexical)))))) (syntmp-macros-only-env-111 (lambda (syntmp-r-993) (if (null? syntmp-r-993) (quote ()) (let ((syntmp-a-994 (car syntmp-r-993))) (if (eq? (cadr syntmp-a-994) (quote macro)) (cons syntmp-a-994 (syntmp-macros-only-env-111 (cdr syntmp-r-993))) (syntmp-macros-only-env-111 (cdr syntmp-r-993))))))) (syntmp-extend-var-env-110 (lambda (syntmp-labels-995 syntmp-vars-996 syntmp-r-997) (if (null? syntmp-labels-995) syntmp-r-997 (syntmp-extend-var-env-110 (cdr syntmp-labels-995) (cdr syntmp-vars-996) (cons (cons (car syntmp-labels-995) (cons (quote lexical) (car syntmp-vars-996))) syntmp-r-997))))) (syntmp-extend-env-109 (lambda (syntmp-labels-998 syntmp-bindings-999 syntmp-r-1000) (if (null? syntmp-labels-998) syntmp-r-1000 (syntmp-extend-env-109 (cdr syntmp-labels-998) (cdr syntmp-bindings-999) (cons (cons (car syntmp-labels-998) (car syntmp-bindings-999)) syntmp-r-1000))))) (syntmp-binding-value-108 cdr) (syntmp-binding-type-107 car) (syntmp-source-annotation-106 (lambda (syntmp-x-1001) (cond ((syntmp-annotation?-89 syntmp-x-1001) (annotation-source syntmp-x-1001)) ((syntmp-syntax-object?-101 syntmp-x-1001) (syntmp-source-annotation-106 (syntmp-syntax-object-expression-102 syntmp-x-1001))) (else #f)))) (syntmp-set-syntax-object-wrap!-105 (lambda (syntmp-x-1002 syntmp-update-1003) (vector-set! syntmp-x-1002 2 syntmp-update-1003))) (syntmp-set-syntax-object-expression!-104 (lambda (syntmp-x-1004 syntmp-update-1005) (vector-set! syntmp-x-1004 1 syntmp-update-1005))) (syntmp-syntax-object-wrap-103 (lambda (syntmp-x-1006) (vector-ref syntmp-x-1006 2))) (syntmp-syntax-object-expression-102 (lambda (syntmp-x-1007) (vector-ref syntmp-x-1007 1))) (syntmp-syntax-object?-101 (lambda (syntmp-x-1008) (and (vector? syntmp-x-1008) (= (vector-length syntmp-x-1008) 3) (eq? (vector-ref syntmp-x-1008 0) (quote syntax-object))))) (syntmp-make-syntax-object-100 (lambda (syntmp-expression-1009 syntmp-wrap-1010) (vector (quote syntax-object) syntmp-expression-1009 syntmp-wrap-1010))) (syntmp-build-letrec-99 (lambda (syntmp-src-1011 syntmp-vars-1012 syntmp-val-exps-1013 syntmp-body-exp-1014) (if (null? syntmp-vars-1012) syntmp-body-exp-1014 (list (quote letrec) (map list syntmp-vars-1012 syntmp-val-exps-1013) syntmp-body-exp-1014)))) (syntmp-build-named-let-98 (lambda (syntmp-src-1015 syntmp-vars-1016 syntmp-val-exps-1017 syntmp-body-exp-1018) (if (null? syntmp-vars-1016) syntmp-body-exp-1018 (list (quote let) (car syntmp-vars-1016) (map list (cdr syntmp-vars-1016) syntmp-val-exps-1017) syntmp-body-exp-1018)))) (syntmp-build-let-97 (lambda (syntmp-src-1019 syntmp-vars-1020 syntmp-val-exps-1021 syntmp-body-exp-1022) (if (null? syntmp-vars-1020) syntmp-body-exp-1022 (list (quote let) (map list syntmp-vars-1020 syntmp-val-exps-1021) syntmp-body-exp-1022)))) (syntmp-build-sequence-96 (lambda (syntmp-src-1023 syntmp-exps-1024) (if (null? (cdr syntmp-exps-1024)) (car syntmp-exps-1024) (cons (quote begin) syntmp-exps-1024)))) (syntmp-build-data-95 (lambda (syntmp-src-1025 syntmp-exp-1026) (if (and (self-evaluating? syntmp-exp-1026) (not (vector? syntmp-exp-1026))) syntmp-exp-1026 (list (quote quote) syntmp-exp-1026)))) (syntmp-get-global-definition-hook-94 (lambda (syntmp-symbol-1027) (getprop syntmp-symbol-1027 (quote *sc-expander*)))) (syntmp-put-global-definition-hook-93 (lambda (syntmp-symbol-1028 syntmp-binding-1029) (putprop syntmp-symbol-1028 (quote *sc-expander*) syntmp-binding-1029))) (syntmp-error-hook-92 (lambda (syntmp-who-1030 syntmp-why-1031 syntmp-what-1032) (error syntmp-who-1030 "~a ~s" syntmp-why-1031 syntmp-what-1032))) (syntmp-local-eval-hook-91 (lambda (syntmp-x-1033) (eval (list syntmp-noexpand-84 syntmp-x-1033) (interaction-environment)))) (syntmp-top-level-eval-hook-90 (lambda (syntmp-x-1034) (eval (list syntmp-noexpand-84 syntmp-x-1034) (interaction-environment)))) (syntmp-annotation?-89 (lambda (syntmp-x-1035) #f)) (syntmp-fx<-88 <) (syntmp-fx=-87 =) (syntmp-fx--86 -) (syntmp-fx+-85 +) (syntmp-noexpand-84 "noexpand")) (begin (syntmp-global-extend-113 (quote local-syntax) (quote letrec-syntax) #t) (syntmp-global-extend-113 (quote local-syntax) (quote let-syntax) #f) (syntmp-global-extend-113 (quote core) (quote fluid-let-syntax) (lambda (syntmp-e-1036 syntmp-r-1037 syntmp-w-1038 syntmp-s-1039) ((lambda (syntmp-tmp-1040) ((lambda (syntmp-tmp-1041) (if (if syntmp-tmp-1041 (apply (lambda (syntmp-_-1042 syntmp-var-1043 syntmp-val-1044 syntmp-e1-1045 syntmp-e2-1046) (syntmp-valid-bound-ids?-140 syntmp-var-1043)) syntmp-tmp-1041) #f) (apply (lambda (syntmp-_-1048 syntmp-var-1049 syntmp-val-1050 syntmp-e1-1051 syntmp-e2-1052) (let ((syntmp-names-1053 (map (lambda (syntmp-x-1054) (syntmp-id-var-name-137 syntmp-x-1054 syntmp-w-1038)) syntmp-var-1049))) (begin (for-each (lambda (syntmp-id-1056 syntmp-n-1057) (let ((syntmp-t-1058 (syntmp-binding-type-107 (syntmp-lookup-112 syntmp-n-1057 syntmp-r-1037)))) (if (memv syntmp-t-1058 (quote (displaced-lexical))) (syntax-error (syntmp-source-wrap-144 syntmp-id-1056 syntmp-w-1038 syntmp-s-1039) "identifier out of context")))) syntmp-var-1049 syntmp-names-1053) (syntmp-chi-body-155 (cons syntmp-e1-1051 syntmp-e2-1052) (syntmp-source-wrap-144 syntmp-e-1036 syntmp-w-1038 syntmp-s-1039) (syntmp-extend-env-109 syntmp-names-1053 (let ((syntmp-trans-r-1061 (syntmp-macros-only-env-111 syntmp-r-1037))) (map (lambda (syntmp-x-1062) (cons (quote macro) (syntmp-eval-local-transformer-158 (syntmp-chi-151 syntmp-x-1062 syntmp-trans-r-1061 syntmp-w-1038)))) syntmp-val-1050)) syntmp-r-1037) syntmp-w-1038)))) syntmp-tmp-1041) ((lambda (syntmp-_-1064) (syntax-error (syntmp-source-wrap-144 syntmp-e-1036 syntmp-w-1038 syntmp-s-1039))) syntmp-tmp-1040))) (syntax-dispatch syntmp-tmp-1040 (quote (any #(each (any any)) any . each-any))))) syntmp-e-1036))) (syntmp-global-extend-113 (quote core) (quote quote) (lambda (syntmp-e-1065 syntmp-r-1066 syntmp-w-1067 syntmp-s-1068) ((lambda (syntmp-tmp-1069) ((lambda (syntmp-tmp-1070) (if syntmp-tmp-1070 (apply (lambda (syntmp-_-1071 syntmp-e-1072) (syntmp-build-data-95 syntmp-s-1068 (syntmp-strip-162 syntmp-e-1072 syntmp-w-1067))) syntmp-tmp-1070) ((lambda (syntmp-_-1073) (syntax-error (syntmp-source-wrap-144 syntmp-e-1065 syntmp-w-1067 syntmp-s-1068))) syntmp-tmp-1069))) (syntax-dispatch syntmp-tmp-1069 (quote (any any))))) syntmp-e-1065))) (syntmp-global-extend-113 (quote core) (quote syntax) (letrec ((syntmp-regen-1081 (lambda (syntmp-x-1082) (let ((syntmp-t-1083 (car syntmp-x-1082))) (if (memv syntmp-t-1083 (quote (ref))) (cadr syntmp-x-1082) (if (memv syntmp-t-1083 (quote (primitive))) (cadr syntmp-x-1082) (if (memv syntmp-t-1083 (quote (quote))) (syntmp-build-data-95 #f (cadr syntmp-x-1082)) (if (memv syntmp-t-1083 (quote (lambda))) (list (quote lambda) (cadr syntmp-x-1082) (syntmp-regen-1081 (caddr syntmp-x-1082))) (if (memv syntmp-t-1083 (quote (map))) (let ((syntmp-ls-1084 (map syntmp-regen-1081 (cdr syntmp-x-1082)))) (cons (if (syntmp-fx=-87 (length syntmp-ls-1084) 2) (quote map) (quote map)) syntmp-ls-1084)) (cons (car syntmp-x-1082) (map syntmp-regen-1081 (cdr syntmp-x-1082))))))))))) (syntmp-gen-vector-1080 (lambda (syntmp-x-1085) (cond ((eq? (car syntmp-x-1085) (quote list)) (cons (quote vector) (cdr syntmp-x-1085))) ((eq? (car syntmp-x-1085) (quote quote)) (list (quote quote) (list->vector (cadr syntmp-x-1085)))) (else (list (quote list->vector) syntmp-x-1085))))) (syntmp-gen-append-1079 (lambda (syntmp-x-1086 syntmp-y-1087) (if (equal? syntmp-y-1087 (quote (quote ()))) syntmp-x-1086 (list (quote append) syntmp-x-1086 syntmp-y-1087)))) (syntmp-gen-cons-1078 (lambda (syntmp-x-1088 syntmp-y-1089) (let ((syntmp-t-1090 (car syntmp-y-1089))) (if (memv syntmp-t-1090 (quote (quote))) (if (eq? (car syntmp-x-1088) (quote quote)) (list (quote quote) (cons (cadr syntmp-x-1088) (cadr syntmp-y-1089))) (if (eq? (cadr syntmp-y-1089) (quote ())) (list (quote list) syntmp-x-1088) (list (quote cons) syntmp-x-1088 syntmp-y-1089))) (if (memv syntmp-t-1090 (quote (list))) (cons (quote list) (cons syntmp-x-1088 (cdr syntmp-y-1089))) (list (quote cons) syntmp-x-1088 syntmp-y-1089)))))) (syntmp-gen-map-1077 (lambda (syntmp-e-1091 syntmp-map-env-1092) (let ((syntmp-formals-1093 (map cdr syntmp-map-env-1092)) (syntmp-actuals-1094 (map (lambda (syntmp-x-1095) (list (quote ref) (car syntmp-x-1095))) syntmp-map-env-1092))) (cond ((eq? (car syntmp-e-1091) (quote ref)) (car syntmp-actuals-1094)) ((andmap (lambda (syntmp-x-1096) (and (eq? (car syntmp-x-1096) (quote ref)) (memq (cadr syntmp-x-1096) syntmp-formals-1093))) (cdr syntmp-e-1091)) (cons (quote map) (cons (list (quote primitive) (car syntmp-e-1091)) (map (let ((syntmp-r-1097 (map cons syntmp-formals-1093 syntmp-actuals-1094))) (lambda (syntmp-x-1098) (cdr (assq (cadr syntmp-x-1098) syntmp-r-1097)))) (cdr syntmp-e-1091))))) (else (cons (quote map) (cons (list (quote lambda) syntmp-formals-1093 syntmp-e-1091) syntmp-actuals-1094))))))) (syntmp-gen-mappend-1076 (lambda (syntmp-e-1099 syntmp-map-env-1100) (list (quote apply) (quote (primitive append)) (syntmp-gen-map-1077 syntmp-e-1099 syntmp-map-env-1100)))) (syntmp-gen-ref-1075 (lambda (syntmp-src-1101 syntmp-var-1102 syntmp-level-1103 syntmp-maps-1104) (if (syntmp-fx=-87 syntmp-level-1103 0) (values syntmp-var-1102 syntmp-maps-1104) (if (null? syntmp-maps-1104) (syntax-error syntmp-src-1101 "missing ellipsis in syntax form") (call-with-values (lambda () (syntmp-gen-ref-1075 syntmp-src-1101 syntmp-var-1102 (syntmp-fx--86 syntmp-level-1103 1) (cdr syntmp-maps-1104))) (lambda (syntmp-outer-var-1105 syntmp-outer-maps-1106) (let ((syntmp-b-1107 (assq syntmp-outer-var-1105 (car syntmp-maps-1104)))) (if syntmp-b-1107 (values (cdr syntmp-b-1107) syntmp-maps-1104) (let ((syntmp-inner-var-1108 (syntmp-gen-var-163 (quote tmp)))) (values syntmp-inner-var-1108 (cons (cons (cons syntmp-outer-var-1105 syntmp-inner-var-1108) (car syntmp-maps-1104)) syntmp-outer-maps-1106))))))))))) (syntmp-gen-syntax-1074 (lambda (syntmp-src-1109 syntmp-e-1110 syntmp-r-1111 syntmp-maps-1112 syntmp-ellipsis?-1113) (if (syntmp-id?-115 syntmp-e-1110) (let ((syntmp-label-1114 (syntmp-id-var-name-137 syntmp-e-1110 (quote (()))))) (let ((syntmp-b-1115 (syntmp-lookup-112 syntmp-label-1114 syntmp-r-1111))) (if (eq? (syntmp-binding-type-107 syntmp-b-1115) (quote syntax)) (call-with-values (lambda () (let ((syntmp-var.lev-1116 (syntmp-binding-value-108 syntmp-b-1115))) (syntmp-gen-ref-1075 syntmp-src-1109 (car syntmp-var.lev-1116) (cdr syntmp-var.lev-1116) syntmp-maps-1112))) (lambda (syntmp-var-1117 syntmp-maps-1118) (values (list (quote ref) syntmp-var-1117) syntmp-maps-1118))) (if (syntmp-ellipsis?-1113 syntmp-e-1110) (syntax-error syntmp-src-1109 "misplaced ellipsis in syntax form") (values (list (quote quote) syntmp-e-1110) syntmp-maps-1112))))) ((lambda (syntmp-tmp-1119) ((lambda (syntmp-tmp-1120) (if (if syntmp-tmp-1120 (apply (lambda (syntmp-dots-1121 syntmp-e-1122) (syntmp-ellipsis?-1113 syntmp-dots-1121)) syntmp-tmp-1120) #f) (apply (lambda (syntmp-dots-1123 syntmp-e-1124) (syntmp-gen-syntax-1074 syntmp-src-1109 syntmp-e-1124 syntmp-r-1111 syntmp-maps-1112 (lambda (syntmp-x-1125) #f))) syntmp-tmp-1120) ((lambda (syntmp-tmp-1126) (if (if syntmp-tmp-1126 (apply (lambda (syntmp-x-1127 syntmp-dots-1128 syntmp-y-1129) (syntmp-ellipsis?-1113 syntmp-dots-1128)) syntmp-tmp-1126) #f) (apply (lambda (syntmp-x-1130 syntmp-dots-1131 syntmp-y-1132) (let syntmp-f-1133 ((syntmp-y-1134 syntmp-y-1132) (syntmp-k-1135 (lambda (syntmp-maps-1136) (call-with-values (lambda () (syntmp-gen-syntax-1074 syntmp-src-1109 syntmp-x-1130 syntmp-r-1111 (cons (quote ()) syntmp-maps-1136) syntmp-ellipsis?-1113)) (lambda (syntmp-x-1137 syntmp-maps-1138) (if (null? (car syntmp-maps-1138)) (syntax-error syntmp-src-1109 "extra ellipsis in syntax form") (values (syntmp-gen-map-1077 syntmp-x-1137 (car syntmp-maps-1138)) (cdr syntmp-maps-1138)))))))) ((lambda (syntmp-tmp-1139) ((lambda (syntmp-tmp-1140) (if (if syntmp-tmp-1140 (apply (lambda (syntmp-dots-1141 syntmp-y-1142) (syntmp-ellipsis?-1113 syntmp-dots-1141)) syntmp-tmp-1140) #f) (apply (lambda (syntmp-dots-1143 syntmp-y-1144) (syntmp-f-1133 syntmp-y-1144 (lambda (syntmp-maps-1145) (call-with-values (lambda () (syntmp-k-1135 (cons (quote ()) syntmp-maps-1145))) (lambda (syntmp-x-1146 syntmp-maps-1147) (if (null? (car syntmp-maps-1147)) (syntax-error syntmp-src-1109 "extra ellipsis in syntax form") (values (syntmp-gen-mappend-1076 syntmp-x-1146 (car syntmp-maps-1147)) (cdr syntmp-maps-1147)))))))) syntmp-tmp-1140) ((lambda (syntmp-_-1148) (call-with-values (lambda () (syntmp-gen-syntax-1074 syntmp-src-1109 syntmp-y-1134 syntmp-r-1111 syntmp-maps-1112 syntmp-ellipsis?-1113)) (lambda (syntmp-y-1149 syntmp-maps-1150) (call-with-values (lambda () (syntmp-k-1135 syntmp-maps-1150)) (lambda (syntmp-x-1151 syntmp-maps-1152) (values (syntmp-gen-append-1079 syntmp-x-1151 syntmp-y-1149) syntmp-maps-1152)))))) syntmp-tmp-1139))) (syntax-dispatch syntmp-tmp-1139 (quote (any . any))))) syntmp-y-1134))) syntmp-tmp-1126) ((lambda (syntmp-tmp-1153) (if syntmp-tmp-1153 (apply (lambda (syntmp-x-1154 syntmp-y-1155) (call-with-values (lambda () (syntmp-gen-syntax-1074 syntmp-src-1109 syntmp-x-1154 syntmp-r-1111 syntmp-maps-1112 syntmp-ellipsis?-1113)) (lambda (syntmp-x-1156 syntmp-maps-1157) (call-with-values (lambda () (syntmp-gen-syntax-1074 syntmp-src-1109 syntmp-y-1155 syntmp-r-1111 syntmp-maps-1157 syntmp-ellipsis?-1113)) (lambda (syntmp-y-1158 syntmp-maps-1159) (values (syntmp-gen-cons-1078 syntmp-x-1156 syntmp-y-1158) syntmp-maps-1159)))))) syntmp-tmp-1153) ((lambda (syntmp-tmp-1160) (if syntmp-tmp-1160 (apply (lambda (syntmp-e1-1161 syntmp-e2-1162) (call-with-values (lambda () (syntmp-gen-syntax-1074 syntmp-src-1109 (cons syntmp-e1-1161 syntmp-e2-1162) syntmp-r-1111 syntmp-maps-1112 syntmp-ellipsis?-1113)) (lambda (syntmp-e-1164 syntmp-maps-1165) (values (syntmp-gen-vector-1080 syntmp-e-1164) syntmp-maps-1165)))) syntmp-tmp-1160) ((lambda (syntmp-_-1166) (values (list (quote quote) syntmp-e-1110) syntmp-maps-1112)) syntmp-tmp-1119))) (syntax-dispatch syntmp-tmp-1119 (quote #(vector (any . each-any))))))) (syntax-dispatch syntmp-tmp-1119 (quote (any . any)))))) (syntax-dispatch syntmp-tmp-1119 (quote (any any . any)))))) (syntax-dispatch syntmp-tmp-1119 (quote (any any))))) syntmp-e-1110))))) (lambda (syntmp-e-1167 syntmp-r-1168 syntmp-w-1169 syntmp-s-1170) (let ((syntmp-e-1171 (syntmp-source-wrap-144 syntmp-e-1167 syntmp-w-1169 syntmp-s-1170))) ((lambda (syntmp-tmp-1172) ((lambda (syntmp-tmp-1173) (if syntmp-tmp-1173 (apply (lambda (syntmp-_-1174 syntmp-x-1175) (call-with-values (lambda () (syntmp-gen-syntax-1074 syntmp-e-1171 syntmp-x-1175 syntmp-r-1168 (quote ()) syntmp-ellipsis?-160)) (lambda (syntmp-e-1176 syntmp-maps-1177) (syntmp-regen-1081 syntmp-e-1176)))) syntmp-tmp-1173) ((lambda (syntmp-_-1178) (syntax-error syntmp-e-1171)) syntmp-tmp-1172))) (syntax-dispatch syntmp-tmp-1172 (quote (any any))))) syntmp-e-1171))))) (syntmp-global-extend-113 (quote core) (quote lambda) (lambda (syntmp-e-1179 syntmp-r-1180 syntmp-w-1181 syntmp-s-1182) ((lambda (syntmp-tmp-1183) ((lambda (syntmp-tmp-1184) (if syntmp-tmp-1184 (apply (lambda (syntmp-_-1185 syntmp-c-1186) (syntmp-chi-lambda-clause-156 (syntmp-source-wrap-144 syntmp-e-1179 syntmp-w-1181 syntmp-s-1182) syntmp-c-1186 syntmp-r-1180 syntmp-w-1181 (lambda (syntmp-vars-1187 syntmp-body-1188) (list (quote lambda) syntmp-vars-1187 syntmp-body-1188)))) syntmp-tmp-1184) (syntax-error syntmp-tmp-1183))) (syntax-dispatch syntmp-tmp-1183 (quote (any . any))))) syntmp-e-1179))) (syntmp-global-extend-113 (quote core) (quote let) (letrec ((syntmp-chi-let-1189 (lambda (syntmp-e-1190 syntmp-r-1191 syntmp-w-1192 syntmp-s-1193 syntmp-constructor-1194 syntmp-ids-1195 syntmp-vals-1196 syntmp-exps-1197) (if (not (syntmp-valid-bound-ids?-140 syntmp-ids-1195)) (syntax-error syntmp-e-1190 "duplicate bound variable in") (let ((syntmp-labels-1198 (syntmp-gen-labels-121 syntmp-ids-1195)) (syntmp-new-vars-1199 (map syntmp-gen-var-163 syntmp-ids-1195))) (let ((syntmp-nw-1200 (syntmp-make-binding-wrap-132 syntmp-ids-1195 syntmp-labels-1198 syntmp-w-1192)) (syntmp-nr-1201 (syntmp-extend-var-env-110 syntmp-labels-1198 syntmp-new-vars-1199 syntmp-r-1191))) (syntmp-constructor-1194 syntmp-s-1193 syntmp-new-vars-1199 (map (lambda (syntmp-x-1202) (syntmp-chi-151 syntmp-x-1202 syntmp-r-1191 syntmp-w-1192)) syntmp-vals-1196) (syntmp-chi-body-155 syntmp-exps-1197 (syntmp-source-wrap-144 syntmp-e-1190 syntmp-nw-1200 syntmp-s-1193) syntmp-nr-1201 syntmp-nw-1200)))))))) (lambda (syntmp-e-1203 syntmp-r-1204 syntmp-w-1205 syntmp-s-1206) ((lambda (syntmp-tmp-1207) ((lambda (syntmp-tmp-1208) (if syntmp-tmp-1208 (apply (lambda (syntmp-_-1209 syntmp-id-1210 syntmp-val-1211 syntmp-e1-1212 syntmp-e2-1213) (syntmp-chi-let-1189 syntmp-e-1203 syntmp-r-1204 syntmp-w-1205 syntmp-s-1206 syntmp-build-let-97 syntmp-id-1210 syntmp-val-1211 (cons syntmp-e1-1212 syntmp-e2-1213))) syntmp-tmp-1208) ((lambda (syntmp-tmp-1217) (if (if syntmp-tmp-1217 (apply (lambda (syntmp-_-1218 syntmp-f-1219 syntmp-id-1220 syntmp-val-1221 syntmp-e1-1222 syntmp-e2-1223) (syntmp-id?-115 syntmp-f-1219)) syntmp-tmp-1217) #f) (apply (lambda (syntmp-_-1224 syntmp-f-1225 syntmp-id-1226 syntmp-val-1227 syntmp-e1-1228 syntmp-e2-1229) (syntmp-chi-let-1189 syntmp-e-1203 syntmp-r-1204 syntmp-w-1205 syntmp-s-1206 syntmp-build-named-let-98 (cons syntmp-f-1225 syntmp-id-1226) syntmp-val-1227 (cons syntmp-e1-1228 syntmp-e2-1229))) syntmp-tmp-1217) ((lambda (syntmp-_-1233) (syntax-error (syntmp-source-wrap-144 syntmp-e-1203 syntmp-w-1205 syntmp-s-1206))) syntmp-tmp-1207))) (syntax-dispatch syntmp-tmp-1207 (quote (any any #(each (any any)) any . each-any)))))) (syntax-dispatch syntmp-tmp-1207 (quote (any #(each (any any)) any . each-any))))) syntmp-e-1203)))) (syntmp-global-extend-113 (quote core) (quote letrec) (lambda (syntmp-e-1234 syntmp-r-1235 syntmp-w-1236 syntmp-s-1237) ((lambda (syntmp-tmp-1238) ((lambda (syntmp-tmp-1239) (if syntmp-tmp-1239 (apply (lambda (syntmp-_-1240 syntmp-id-1241 syntmp-val-1242 syntmp-e1-1243 syntmp-e2-1244) (let ((syntmp-ids-1245 syntmp-id-1241)) (if (not (syntmp-valid-bound-ids?-140 syntmp-ids-1245)) (syntax-error syntmp-e-1234 "duplicate bound variable in") (let ((syntmp-labels-1247 (syntmp-gen-labels-121 syntmp-ids-1245)) (syntmp-new-vars-1248 (map syntmp-gen-var-163 syntmp-ids-1245))) (let ((syntmp-w-1249 (syntmp-make-binding-wrap-132 syntmp-ids-1245 syntmp-labels-1247 syntmp-w-1236)) (syntmp-r-1250 (syntmp-extend-var-env-110 syntmp-labels-1247 syntmp-new-vars-1248 syntmp-r-1235))) (syntmp-build-letrec-99 syntmp-s-1237 syntmp-new-vars-1248 (map (lambda (syntmp-x-1251) (syntmp-chi-151 syntmp-x-1251 syntmp-r-1250 syntmp-w-1249)) syntmp-val-1242) (syntmp-chi-body-155 (cons syntmp-e1-1243 syntmp-e2-1244) (syntmp-source-wrap-144 syntmp-e-1234 syntmp-w-1249 syntmp-s-1237) syntmp-r-1250 syntmp-w-1249))))))) syntmp-tmp-1239) ((lambda (syntmp-_-1254) (syntax-error (syntmp-source-wrap-144 syntmp-e-1234 syntmp-w-1236 syntmp-s-1237))) syntmp-tmp-1238))) (syntax-dispatch syntmp-tmp-1238 (quote (any #(each (any any)) any . each-any))))) syntmp-e-1234))) (syntmp-global-extend-113 (quote core) (quote set!) (lambda (syntmp-e-1255 syntmp-r-1256 syntmp-w-1257 syntmp-s-1258) ((lambda (syntmp-tmp-1259) ((lambda (syntmp-tmp-1260) (if (if syntmp-tmp-1260 (apply (lambda (syntmp-_-1261 syntmp-id-1262 syntmp-val-1263) (syntmp-id?-115 syntmp-id-1262)) syntmp-tmp-1260) #f) (apply (lambda (syntmp-_-1264 syntmp-id-1265 syntmp-val-1266) (let ((syntmp-val-1267 (syntmp-chi-151 syntmp-val-1266 syntmp-r-1256 syntmp-w-1257)) (syntmp-n-1268 (syntmp-id-var-name-137 syntmp-id-1265 syntmp-w-1257))) (let ((syntmp-b-1269 (syntmp-lookup-112 syntmp-n-1268 syntmp-r-1256))) (let ((syntmp-t-1270 (syntmp-binding-type-107 syntmp-b-1269))) (if (memv syntmp-t-1270 (quote (lexical))) (list (quote set!) (syntmp-binding-value-108 syntmp-b-1269) syntmp-val-1267) (if (memv syntmp-t-1270 (quote (global))) (list (quote set!) syntmp-n-1268 syntmp-val-1267) (if (memv syntmp-t-1270 (quote (displaced-lexical))) (syntax-error (syntmp-wrap-143 syntmp-id-1265 syntmp-w-1257) "identifier out of context") (syntax-error (syntmp-source-wrap-144 syntmp-e-1255 syntmp-w-1257 syntmp-s-1258))))))))) syntmp-tmp-1260) ((lambda (syntmp-tmp-1271) (if syntmp-tmp-1271 (apply (lambda (syntmp-_-1272 syntmp-getter-1273 syntmp-arg-1274 syntmp-val-1275) (cons (syntmp-chi-151 (list (quote #(syntax-object setter ((top) #(ribcage #(_ getter arg val) #((top) (top) (top) (top)) #("i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(e r w s) #((top) (top) (top) (top)) #("i" "i" "i" "i")) #(ribcage (lambda-var-list gen-var strip strip-annotation ellipsis? chi-void eval-local-transformer chi-local-syntax chi-lambda-clause chi-body chi-macro chi-application chi-expr chi chi-top syntax-type chi-when-list chi-install-global chi-top-sequence chi-sequence source-wrap wrap bound-id-member? distinct-bound-ids? valid-bound-ids? bound-id=? free-id=? id-var-name same-marks? join-marks join-wraps smart-append make-binding-wrap extend-ribcage! make-empty-ribcage new-mark anti-mark the-anti-mark top-marked? top-wrap empty-wrap set-ribcage-labels! set-ribcage-marks! set-ribcage-symnames! ribcage-labels ribcage-marks ribcage-symnames ribcage? make-ribcage gen-labels gen-label make-rename rename-marks rename-new rename-old subst-rename? wrap-subst wrap-marks make-wrap id-sym-name&marks id-sym-name id? nonsymbol-id? global-extend lookup macros-only-env extend-var-env extend-env null-env binding-value binding-type make-binding arg-check source-annotation no-source unannotate set-syntax-object-wrap! set-syntax-object-expression! syntax-object-wrap syntax-object-expression syntax-object? make-syntax-object build-lexical-var build-letrec build-named-let build-let build-sequence build-data build-primref build-lambda build-global-definition build-global-assignment build-global-reference build-lexical-assignment build-lexical-reference build-conditional build-application get-global-definition-hook put-global-definition-hook gensym-hook error-hook local-eval-hook top-level-eval-hook annotation? fx< fx= fx- fx+ noexpand) ((top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top)) ("i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i")) #(ribcage (define-structure) ((top)) ("i"))))) syntmp-getter-1273) syntmp-r-1256 syntmp-w-1257) (map (lambda (syntmp-e-1276) (syntmp-chi-151 syntmp-e-1276 syntmp-r-1256 syntmp-w-1257)) (append syntmp-arg-1274 (list syntmp-val-1275))))) syntmp-tmp-1271) ((lambda (syntmp-_-1278) (syntax-error (syntmp-source-wrap-144 syntmp-e-1255 syntmp-w-1257 syntmp-s-1258))) syntmp-tmp-1259))) (syntax-dispatch syntmp-tmp-1259 (quote (any (any . each-any) any)))))) (syntax-dispatch syntmp-tmp-1259 (quote (any any any))))) syntmp-e-1255))) (syntmp-global-extend-113 (quote begin) (quote begin) (quote ())) (syntmp-global-extend-113 (quote define) (quote define) (quote ())) (syntmp-global-extend-113 (quote define-syntax) (quote define-syntax) (quote ())) (syntmp-global-extend-113 (quote eval-when) (quote eval-when) (quote ())) (syntmp-global-extend-113 (quote core) (quote syntax-case) (letrec ((syntmp-gen-syntax-case-1282 (lambda (syntmp-x-1283 syntmp-keys-1284 syntmp-clauses-1285 syntmp-r-1286) (if (null? syntmp-clauses-1285) (list (quote syntax-error) syntmp-x-1283) ((lambda (syntmp-tmp-1287) ((lambda (syntmp-tmp-1288) (if syntmp-tmp-1288 (apply (lambda (syntmp-pat-1289 syntmp-exp-1290) (if (and (syntmp-id?-115 syntmp-pat-1289) (andmap (lambda (syntmp-x-1291) (not (syntmp-free-id=?-138 syntmp-pat-1289 syntmp-x-1291))) (cons (quote #(syntax-object ... ((top) #(ribcage #(pat exp) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage #(x keys clauses r) #((top) (top) (top) (top)) #("i" "i" "i" "i")) #(ribcage (gen-syntax-case gen-clause build-dispatch-call convert-pattern) ((top) (top) (top) (top)) ("i" "i" "i" "i")) #(ribcage (lambda-var-list gen-var strip strip-annotation ellipsis? chi-void eval-local-transformer chi-local-syntax chi-lambda-clause chi-body chi-macro chi-application chi-expr chi chi-top syntax-type chi-when-list chi-install-global chi-top-sequence chi-sequence source-wrap wrap bound-id-member? distinct-bound-ids? valid-bound-ids? bound-id=? free-id=? id-var-name same-marks? join-marks join-wraps smart-append make-binding-wrap extend-ribcage! make-empty-ribcage new-mark anti-mark the-anti-mark top-marked? top-wrap empty-wrap set-ribcage-labels! set-ribcage-marks! set-ribcage-symnames! ribcage-labels ribcage-marks ribcage-symnames ribcage? make-ribcage gen-labels gen-label make-rename rename-marks rename-new rename-old subst-rename? wrap-subst wrap-marks make-wrap id-sym-name&marks id-sym-name id? nonsymbol-id? global-extend lookup macros-only-env extend-var-env extend-env null-env binding-value binding-type make-binding arg-check source-annotation no-source unannotate set-syntax-object-wrap! set-syntax-object-expression! syntax-object-wrap syntax-object-expression syntax-object? make-syntax-object build-lexical-var build-letrec build-named-let build-let build-sequence build-data build-primref build-lambda build-global-definition build-global-assignment build-global-reference build-lexical-assignment build-lexical-reference build-conditional build-application get-global-definition-hook put-global-definition-hook gensym-hook error-hook local-eval-hook top-level-eval-hook annotation? fx< fx= fx- fx+ noexpand) ((top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top) (top)) ("i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i" "i")) #(ribcage (define-structure) ((top)) ("i"))))) syntmp-keys-1284))) (let ((syntmp-labels-1292 (list (syntmp-gen-label-120))) (syntmp-var-1293 (syntmp-gen-var-163 syntmp-pat-1289))) (list (list (quote lambda) (list syntmp-var-1293) (syntmp-chi-151 syntmp-exp-1290 (syntmp-extend-env-109 syntmp-labels-1292 (list (cons (quote syntax) (cons syntmp-var-1293 0))) syntmp-r-1286) (syntmp-make-binding-wrap-132 (list syntmp-pat-1289) syntmp-labels-1292 (quote (()))))) syntmp-x-1283)) (syntmp-gen-clause-1281 syntmp-x-1283 syntmp-keys-1284 (cdr syntmp-clauses-1285) syntmp-r-1286 syntmp-pat-1289 #t syntmp-exp-1290))) syntmp-tmp-1288) ((lambda (syntmp-tmp-1294) (if syntmp-tmp-1294 (apply (lambda (syntmp-pat-1295 syntmp-fender-1296 syntmp-exp-1297) (syntmp-gen-clause-1281 syntmp-x-1283 syntmp-keys-1284 (cdr syntmp-clauses-1285) syntmp-r-1286 syntmp-pat-1295 syntmp-fender-1296 syntmp-exp-1297)) syntmp-tmp-1294) ((lambda (syntmp-_-1298) (syntax-error (car syntmp-clauses-1285) "invalid syntax-case clause")) syntmp-tmp-1287))) (syntax-dispatch syntmp-tmp-1287 (quote (any any any)))))) (syntax-dispatch syntmp-tmp-1287 (quote (any any))))) (car syntmp-clauses-1285))))) (syntmp-gen-clause-1281 (lambda (syntmp-x-1299 syntmp-keys-1300 syntmp-clauses-1301 syntmp-r-1302 syntmp-pat-1303 syntmp-fender-1304 syntmp-exp-1305) (call-with-values (lambda () (syntmp-convert-pattern-1279 syntmp-pat-1303 syntmp-keys-1300)) (lambda (syntmp-p-1306 syntmp-pvars-1307) (cond ((not (syntmp-distinct-bound-ids?-141 (map car syntmp-pvars-1307))) (syntax-error syntmp-pat-1303 "duplicate pattern variable in syntax-case pattern")) ((not (andmap (lambda (syntmp-x-1308) (not (syntmp-ellipsis?-160 (car syntmp-x-1308)))) syntmp-pvars-1307)) (syntax-error syntmp-pat-1303 "misplaced ellipsis in syntax-case pattern")) (else (let ((syntmp-y-1309 (syntmp-gen-var-163 (quote tmp)))) (list (list (quote lambda) (list syntmp-y-1309) (let ((syntmp-y-1310 syntmp-y-1309)) (list (quote if) ((lambda (syntmp-tmp-1311) ((lambda (syntmp-tmp-1312) (if syntmp-tmp-1312 (apply (lambda () syntmp-y-1310) syntmp-tmp-1312) ((lambda (syntmp-_-1313) (list (quote if) syntmp-y-1310 (syntmp-build-dispatch-call-1280 syntmp-pvars-1307 syntmp-fender-1304 syntmp-y-1310 syntmp-r-1302) (syntmp-build-data-95 #f #f))) syntmp-tmp-1311))) (syntax-dispatch syntmp-tmp-1311 (quote #(atom #t))))) syntmp-fender-1304) (syntmp-build-dispatch-call-1280 syntmp-pvars-1307 syntmp-exp-1305 syntmp-y-1310 syntmp-r-1302) (syntmp-gen-syntax-case-1282 syntmp-x-1299 syntmp-keys-1300 syntmp-clauses-1301 syntmp-r-1302)))) (if (eq? syntmp-p-1306 (quote any)) (list (quote list) syntmp-x-1299) (list (quote syntax-dispatch) syntmp-x-1299 (syntmp-build-data-95 #f syntmp-p-1306))))))))))) (syntmp-build-dispatch-call-1280 (lambda (syntmp-pvars-1314 syntmp-exp-1315 syntmp-y-1316 syntmp-r-1317) (let ((syntmp-ids-1318 (map car syntmp-pvars-1314)) (syntmp-levels-1319 (map cdr syntmp-pvars-1314))) (let ((syntmp-labels-1320 (syntmp-gen-labels-121 syntmp-ids-1318)) (syntmp-new-vars-1321 (map syntmp-gen-var-163 syntmp-ids-1318))) (list (quote apply) (list (quote lambda) syntmp-new-vars-1321 (syntmp-chi-151 syntmp-exp-1315 (syntmp-extend-env-109 syntmp-labels-1320 (map (lambda (syntmp-var-1322 syntmp-level-1323) (cons (quote syntax) (cons syntmp-var-1322 syntmp-level-1323))) syntmp-new-vars-1321 (map cdr syntmp-pvars-1314)) syntmp-r-1317) (syntmp-make-binding-wrap-132 syntmp-ids-1318 syntmp-labels-1320 (quote (()))))) syntmp-y-1316))))) (syntmp-convert-pattern-1279 (lambda (syntmp-pattern-1324 syntmp-keys-1325) (let syntmp-cvt-1326 ((syntmp-p-1327 syntmp-pattern-1324) (syntmp-n-1328 0) (syntmp-ids-1329 (quote ()))) (if (syntmp-id?-115 syntmp-p-1327) (if (syntmp-bound-id-member?-142 syntmp-p-1327 syntmp-keys-1325) (values (vector (quote free-id) syntmp-p-1327) syntmp-ids-1329) (values (quote any) (cons (cons syntmp-p-1327 syntmp-n-1328) syntmp-ids-1329))) ((lambda (syntmp-tmp-1330) ((lambda (syntmp-tmp-1331) (if (if syntmp-tmp-1331 (apply (lambda (syntmp-x-1332 syntmp-dots-1333) (syntmp-ellipsis?-160 syntmp-dots-1333)) syntmp-tmp-1331) #f) (apply (lambda (syntmp-x-1334 syntmp-dots-1335) (call-with-values (lambda () (syntmp-cvt-1326 syntmp-x-1334 (syntmp-fx+-85 syntmp-n-1328 1) syntmp-ids-1329)) (lambda (syntmp-p-1336 syntmp-ids-1337) (values (if (eq? syntmp-p-1336 (quote any)) (quote each-any) (vector (quote each) syntmp-p-1336)) syntmp-ids-1337)))) syntmp-tmp-1331) ((lambda (syntmp-tmp-1338) (if syntmp-tmp-1338 (apply (lambda (syntmp-x-1339 syntmp-y-1340) (call-with-values (lambda () (syntmp-cvt-1326 syntmp-y-1340 syntmp-n-1328 syntmp-ids-1329)) (lambda (syntmp-y-1341 syntmp-ids-1342) (call-with-values (lambda () (syntmp-cvt-1326 syntmp-x-1339 syntmp-n-1328 syntmp-ids-1342)) (lambda (syntmp-x-1343 syntmp-ids-1344) (values (cons syntmp-x-1343 syntmp-y-1341) syntmp-ids-1344)))))) syntmp-tmp-1338) ((lambda (syntmp-tmp-1345) (if syntmp-tmp-1345 (apply (lambda () (values (quote ()) syntmp-ids-1329)) syntmp-tmp-1345) ((lambda (syntmp-tmp-1346) (if syntmp-tmp-1346 (apply (lambda (syntmp-x-1347) (call-with-values (lambda () (syntmp-cvt-1326 syntmp-x-1347 syntmp-n-1328 syntmp-ids-1329)) (lambda (syntmp-p-1349 syntmp-ids-1350) (values (vector (quote vector) syntmp-p-1349) syntmp-ids-1350)))) syntmp-tmp-1346) ((lambda (syntmp-x-1351) (values (vector (quote atom) (syntmp-strip-162 syntmp-p-1327 (quote (())))) syntmp-ids-1329)) syntmp-tmp-1330))) (syntax-dispatch syntmp-tmp-1330 (quote #(vector each-any)))))) (syntax-dispatch syntmp-tmp-1330 (quote ()))))) (syntax-dispatch syntmp-tmp-1330 (quote (any . any)))))) (syntax-dispatch syntmp-tmp-1330 (quote (any any))))) syntmp-p-1327)))))) (lambda (syntmp-e-1352 syntmp-r-1353 syntmp-w-1354 syntmp-s-1355) (let ((syntmp-e-1356 (syntmp-source-wrap-144 syntmp-e-1352 syntmp-w-1354 syntmp-s-1355))) ((lambda (syntmp-tmp-1357) ((lambda (syntmp-tmp-1358) (if syntmp-tmp-1358 (apply (lambda (syntmp-_-1359 syntmp-val-1360 syntmp-key-1361 syntmp-m-1362) (if (andmap (lambda (syntmp-x-1363) (and (syntmp-id?-115 syntmp-x-1363) (not (syntmp-ellipsis?-160 syntmp-x-1363)))) syntmp-key-1361) (let ((syntmp-x-1365 (syntmp-gen-var-163 (quote tmp)))) (list (list (quote lambda) (list syntmp-x-1365) (syntmp-gen-syntax-case-1282 syntmp-x-1365 syntmp-key-1361 syntmp-m-1362 syntmp-r-1353)) (syntmp-chi-151 syntmp-val-1360 syntmp-r-1353 (quote (()))))) (syntax-error syntmp-e-1356 "invalid literals list in"))) syntmp-tmp-1358) (syntax-error syntmp-tmp-1357))) (syntax-dispatch syntmp-tmp-1357 (quote (any any each-any . each-any))))) syntmp-e-1356))))) (set! sc-expand (let ((syntmp-m-1368 (quote e)) (syntmp-esew-1369 (quote (eval)))) (lambda (syntmp-x-1370) (if (and (pair? syntmp-x-1370) (equal? (car syntmp-x-1370) syntmp-noexpand-84)) (cadr syntmp-x-1370) (syntmp-chi-top-150 syntmp-x-1370 (quote ()) (quote ((top))) syntmp-m-1368 syntmp-esew-1369))))) (set! sc-expand3 (let ((syntmp-m-1371 (quote e)) (syntmp-esew-1372 (quote (eval)))) (lambda (syntmp-x-1374 . syntmp-rest-1373) (if (and (pair? syntmp-x-1374) (equal? (car syntmp-x-1374) syntmp-noexpand-84)) (cadr syntmp-x-1374) (syntmp-chi-top-150 syntmp-x-1374 (quote ()) (quote ((top))) (if (null? syntmp-rest-1373) syntmp-m-1371 (car syntmp-rest-1373)) (if (or (null? syntmp-rest-1373) (null? (cdr syntmp-rest-1373))) syntmp-esew-1372 (cadr syntmp-rest-1373))))))) (set! identifier? (lambda (syntmp-x-1375) (syntmp-nonsymbol-id?-114 syntmp-x-1375))) (set! datum->syntax-object (lambda (syntmp-id-1376 syntmp-datum-1377) (syntmp-make-syntax-object-100 syntmp-datum-1377 (syntmp-syntax-object-wrap-103 syntmp-id-1376)))) (set! syntax-object->datum (lambda (syntmp-x-1378) (syntmp-strip-162 syntmp-x-1378 (quote (()))))) (set! generate-temporaries (lambda (syntmp-ls-1379) (begin (let ((syntmp-x-1380 syntmp-ls-1379)) (if (not (list? syntmp-x-1380)) (syntmp-error-hook-92 (quote generate-temporaries) "invalid argument" syntmp-x-1380))) (map (lambda (syntmp-x-1381) (syntmp-wrap-143 (gensym) (quote ((top))))) syntmp-ls-1379)))) (set! free-identifier=? (lambda (syntmp-x-1382 syntmp-y-1383) (begin (let ((syntmp-x-1384 syntmp-x-1382)) (if (not (syntmp-nonsymbol-id?-114 syntmp-x-1384)) (syntmp-error-hook-92 (quote free-identifier=?) "invalid argument" syntmp-x-1384))) (let ((syntmp-x-1385 syntmp-y-1383)) (if (not (syntmp-nonsymbol-id?-114 syntmp-x-1385)) (syntmp-error-hook-92 (quote free-identifier=?) "invalid argument" syntmp-x-1385))) (syntmp-free-id=?-138 syntmp-x-1382 syntmp-y-1383)))) (set! bound-identifier=? (lambda (syntmp-x-1386 syntmp-y-1387) (begin (let ((syntmp-x-1388 syntmp-x-1386)) (if (not (syntmp-nonsymbol-id?-114 syntmp-x-1388)) (syntmp-error-hook-92 (quote bound-identifier=?) "invalid argument" syntmp-x-1388))) (let ((syntmp-x-1389 syntmp-y-1387)) (if (not (syntmp-nonsymbol-id?-114 syntmp-x-1389)) (syntmp-error-hook-92 (quote bound-identifier=?) "invalid argument" syntmp-x-1389))) (syntmp-bound-id=?-139 syntmp-x-1386 syntmp-y-1387)))) (set! syntax-error (lambda (syntmp-object-1391 . syntmp-messages-1390) (begin (for-each (lambda (syntmp-x-1392) (let ((syntmp-x-1393 syntmp-x-1392)) (if (not (string? syntmp-x-1393)) (syntmp-error-hook-92 (quote syntax-error) "invalid argument" syntmp-x-1393)))) syntmp-messages-1390) (let ((syntmp-message-1394 (if (null? syntmp-messages-1390) "invalid syntax" (apply string-append syntmp-messages-1390)))) (syntmp-error-hook-92 #f syntmp-message-1394 (syntmp-strip-162 syntmp-object-1391 (quote (())))))))) (set! install-global-transformer (lambda (syntmp-sym-1395 syntmp-v-1396) (begin (let ((syntmp-x-1397 syntmp-sym-1395)) (if (not (symbol? syntmp-x-1397)) (syntmp-error-hook-92 (quote define-syntax) "invalid argument" syntmp-x-1397))) (let ((syntmp-x-1398 syntmp-v-1396)) (if (not (procedure? syntmp-x-1398)) (syntmp-error-hook-92 (quote define-syntax) "invalid argument" syntmp-x-1398))) (syntmp-global-extend-113 (quote macro) syntmp-sym-1395 syntmp-v-1396)))) (letrec ((syntmp-match-1403 (lambda (syntmp-e-1404 syntmp-p-1405 syntmp-w-1406 syntmp-r-1407) (cond ((not syntmp-r-1407) #f) ((eq? syntmp-p-1405 (quote any)) (cons (syntmp-wrap-143 syntmp-e-1404 syntmp-w-1406) syntmp-r-1407)) ((syntmp-syntax-object?-101 syntmp-e-1404) (syntmp-match*-1402 (let ((syntmp-e-1408 (syntmp-syntax-object-expression-102 syntmp-e-1404))) (if (syntmp-annotation?-89 syntmp-e-1408) (annotation-expression syntmp-e-1408) syntmp-e-1408)) syntmp-p-1405 (syntmp-join-wraps-134 syntmp-w-1406 (syntmp-syntax-object-wrap-103 syntmp-e-1404)) syntmp-r-1407)) (else (syntmp-match*-1402 (let ((syntmp-e-1409 syntmp-e-1404)) (if (syntmp-annotation?-89 syntmp-e-1409) (annotation-expression syntmp-e-1409) syntmp-e-1409)) syntmp-p-1405 syntmp-w-1406 syntmp-r-1407))))) (syntmp-match*-1402 (lambda (syntmp-e-1410 syntmp-p-1411 syntmp-w-1412 syntmp-r-1413) (cond ((null? syntmp-p-1411) (and (null? syntmp-e-1410) syntmp-r-1413)) ((pair? syntmp-p-1411) (and (pair? syntmp-e-1410) (syntmp-match-1403 (car syntmp-e-1410) (car syntmp-p-1411) syntmp-w-1412 (syntmp-match-1403 (cdr syntmp-e-1410) (cdr syntmp-p-1411) syntmp-w-1412 syntmp-r-1413)))) ((eq? syntmp-p-1411 (quote each-any)) (let ((syntmp-l-1414 (syntmp-match-each-any-1400 syntmp-e-1410 syntmp-w-1412))) (and syntmp-l-1414 (cons syntmp-l-1414 syntmp-r-1413)))) (else (let ((syntmp-t-1415 (vector-ref syntmp-p-1411 0))) (if (memv syntmp-t-1415 (quote (each))) (if (null? syntmp-e-1410) (syntmp-match-empty-1401 (vector-ref syntmp-p-1411 1) syntmp-r-1413) (let ((syntmp-l-1416 (syntmp-match-each-1399 syntmp-e-1410 (vector-ref syntmp-p-1411 1) syntmp-w-1412))) (and syntmp-l-1416 (let syntmp-collect-1417 ((syntmp-l-1418 syntmp-l-1416)) (if (null? (car syntmp-l-1418)) syntmp-r-1413 (cons (map car syntmp-l-1418) (syntmp-collect-1417 (map cdr syntmp-l-1418)))))))) (if (memv syntmp-t-1415 (quote (free-id))) (and (syntmp-id?-115 syntmp-e-1410) (syntmp-free-id=?-138 (syntmp-wrap-143 syntmp-e-1410 syntmp-w-1412) (vector-ref syntmp-p-1411 1)) syntmp-r-1413) (if (memv syntmp-t-1415 (quote (atom))) (and (equal? (vector-ref syntmp-p-1411 1) (syntmp-strip-162 syntmp-e-1410 syntmp-w-1412)) syntmp-r-1413) (if (memv syntmp-t-1415 (quote (vector))) (and (vector? syntmp-e-1410) (syntmp-match-1403 (vector->list syntmp-e-1410) (vector-ref syntmp-p-1411 1) syntmp-w-1412 syntmp-r-1413))))))))))) (syntmp-match-empty-1401 (lambda (syntmp-p-1419 syntmp-r-1420) (cond ((null? syntmp-p-1419) syntmp-r-1420) ((eq? syntmp-p-1419 (quote any)) (cons (quote ()) syntmp-r-1420)) ((pair? syntmp-p-1419) (syntmp-match-empty-1401 (car syntmp-p-1419) (syntmp-match-empty-1401 (cdr syntmp-p-1419) syntmp-r-1420))) ((eq? syntmp-p-1419 (quote each-any)) (cons (quote ()) syntmp-r-1420)) (else (let ((syntmp-t-1421 (vector-ref syntmp-p-1419 0))) (if (memv syntmp-t-1421 (quote (each))) (syntmp-match-empty-1401 (vector-ref syntmp-p-1419 1) syntmp-r-1420) (if (memv syntmp-t-1421 (quote (free-id atom))) syntmp-r-1420 (if (memv syntmp-t-1421 (quote (vector))) (syntmp-match-empty-1401 (vector-ref syntmp-p-1419 1) syntmp-r-1420))))))))) (syntmp-match-each-any-1400 (lambda (syntmp-e-1422 syntmp-w-1423) (cond ((syntmp-annotation?-89 syntmp-e-1422) (syntmp-match-each-any-1400 (annotation-expression syntmp-e-1422) syntmp-w-1423)) ((pair? syntmp-e-1422) (let ((syntmp-l-1424 (syntmp-match-each-any-1400 (cdr syntmp-e-1422) syntmp-w-1423))) (and syntmp-l-1424 (cons (syntmp-wrap-143 (car syntmp-e-1422) syntmp-w-1423) syntmp-l-1424)))) ((null? syntmp-e-1422) (quote ())) ((syntmp-syntax-object?-101 syntmp-e-1422) (syntmp-match-each-any-1400 (syntmp-syntax-object-expression-102 syntmp-e-1422) (syntmp-join-wraps-134 syntmp-w-1423 (syntmp-syntax-object-wrap-103 syntmp-e-1422)))) (else #f)))) (syntmp-match-each-1399 (lambda (syntmp-e-1425 syntmp-p-1426 syntmp-w-1427) (cond ((syntmp-annotation?-89 syntmp-e-1425) (syntmp-match-each-1399 (annotation-expression syntmp-e-1425) syntmp-p-1426 syntmp-w-1427)) ((pair? syntmp-e-1425) (let ((syntmp-first-1428 (syntmp-match-1403 (car syntmp-e-1425) syntmp-p-1426 syntmp-w-1427 (quote ())))) (and syntmp-first-1428 (let ((syntmp-rest-1429 (syntmp-match-each-1399 (cdr syntmp-e-1425) syntmp-p-1426 syntmp-w-1427))) (and syntmp-rest-1429 (cons syntmp-first-1428 syntmp-rest-1429)))))) ((null? syntmp-e-1425) (quote ())) ((syntmp-syntax-object?-101 syntmp-e-1425) (syntmp-match-each-1399 (syntmp-syntax-object-expression-102 syntmp-e-1425) syntmp-p-1426 (syntmp-join-wraps-134 syntmp-w-1427 (syntmp-syntax-object-wrap-103 syntmp-e-1425)))) (else #f))))) (begin (set! syntax-dispatch (lambda (syntmp-e-1430 syntmp-p-1431) (cond ((eq? syntmp-p-1431 (quote any)) (list syntmp-e-1430)) ((syntmp-syntax-object?-101 syntmp-e-1430) (syntmp-match*-1402 (let ((syntmp-e-1432 (syntmp-syntax-object-expression-102 syntmp-e-1430))) (if (syntmp-annotation?-89 syntmp-e-1432) (annotation-expression syntmp-e-1432) syntmp-e-1432)) syntmp-p-1431 (syntmp-syntax-object-wrap-103 syntmp-e-1430) (quote ()))) (else (syntmp-match*-1402 (let ((syntmp-e-1433 syntmp-e-1430)) (if (syntmp-annotation?-89 syntmp-e-1433) (annotation-expression syntmp-e-1433) syntmp-e-1433)) syntmp-p-1431 (quote (())) (quote ())))))) (set! sc-chi syntmp-chi-151))))) +(install-global-transformer (quote with-syntax) (lambda (syntmp-x-1434) ((lambda (syntmp-tmp-1435) ((lambda (syntmp-tmp-1436) (if syntmp-tmp-1436 (apply (lambda (syntmp-_-1437 syntmp-e1-1438 syntmp-e2-1439) (cons (quote #(syntax-object begin ((top) #(ribcage #(_ e1 e2) #((top) (top) (top)) #("i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (cons syntmp-e1-1438 syntmp-e2-1439))) syntmp-tmp-1436) ((lambda (syntmp-tmp-1441) (if syntmp-tmp-1441 (apply (lambda (syntmp-_-1442 syntmp-out-1443 syntmp-in-1444 syntmp-e1-1445 syntmp-e2-1446) (list (quote #(syntax-object syntax-case ((top) #(ribcage #(_ out in e1 e2) #((top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) syntmp-in-1444 (quote ()) (list syntmp-out-1443 (cons (quote #(syntax-object begin ((top) #(ribcage #(_ out in e1 e2) #((top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (cons syntmp-e1-1445 syntmp-e2-1446))))) syntmp-tmp-1441) ((lambda (syntmp-tmp-1448) (if syntmp-tmp-1448 (apply (lambda (syntmp-_-1449 syntmp-out-1450 syntmp-in-1451 syntmp-e1-1452 syntmp-e2-1453) (list (quote #(syntax-object syntax-case ((top) #(ribcage #(_ out in e1 e2) #((top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (cons (quote #(syntax-object list ((top) #(ribcage #(_ out in e1 e2) #((top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) syntmp-in-1451) (quote ()) (list syntmp-out-1450 (cons (quote #(syntax-object begin ((top) #(ribcage #(_ out in e1 e2) #((top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (cons syntmp-e1-1452 syntmp-e2-1453))))) syntmp-tmp-1448) (syntax-error syntmp-tmp-1435))) (syntax-dispatch syntmp-tmp-1435 (quote (any #(each (any any)) any . each-any)))))) (syntax-dispatch syntmp-tmp-1435 (quote (any ((any any)) any . each-any)))))) (syntax-dispatch syntmp-tmp-1435 (quote (any () any . each-any))))) syntmp-x-1434))) +(install-global-transformer (quote syntax-rules) (lambda (syntmp-x-1475) ((lambda (syntmp-tmp-1476) ((lambda (syntmp-tmp-1477) (if syntmp-tmp-1477 (apply (lambda (syntmp-_-1478 syntmp-k-1479 syntmp-keyword-1480 syntmp-pattern-1481 syntmp-template-1482) (list (quote #(syntax-object lambda ((top) #(ribcage #(_ k keyword pattern template) #((top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (quote (#(syntax-object x ((top) #(ribcage #(_ k keyword pattern template) #((top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i")))))) (cons (quote #(syntax-object syntax-case ((top) #(ribcage #(_ k keyword pattern template) #((top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (cons (quote #(syntax-object x ((top) #(ribcage #(_ k keyword pattern template) #((top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (cons syntmp-k-1479 (map (lambda (syntmp-tmp-1485 syntmp-tmp-1484) (list (cons (quote #(syntax-object dummy ((top) #(ribcage #(_ k keyword pattern template) #((top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) syntmp-tmp-1484) (list (quote #(syntax-object syntax ((top) #(ribcage #(_ k keyword pattern template) #((top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) syntmp-tmp-1485))) syntmp-template-1482 syntmp-pattern-1481)))))) syntmp-tmp-1477) (syntax-error syntmp-tmp-1476))) (syntax-dispatch syntmp-tmp-1476 (quote (any each-any . #(each ((any . any) any))))))) syntmp-x-1475))) +(install-global-transformer (quote let*) (lambda (syntmp-x-1496) ((lambda (syntmp-tmp-1497) ((lambda (syntmp-tmp-1498) (if (if syntmp-tmp-1498 (apply (lambda (syntmp-let*-1499 syntmp-x-1500 syntmp-v-1501 syntmp-e1-1502 syntmp-e2-1503) (andmap identifier? syntmp-x-1500)) syntmp-tmp-1498) #f) (apply (lambda (syntmp-let*-1505 syntmp-x-1506 syntmp-v-1507 syntmp-e1-1508 syntmp-e2-1509) (let syntmp-f-1510 ((syntmp-bindings-1511 (map list syntmp-x-1506 syntmp-v-1507))) (if (null? syntmp-bindings-1511) (cons (quote #(syntax-object let ((top) #(ribcage () () ()) #(ribcage #(f bindings) #((top) (top)) #("i" "i")) #(ribcage #(let* x v e1 e2) #((top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (cons (quote ()) (cons syntmp-e1-1508 syntmp-e2-1509))) ((lambda (syntmp-tmp-1515) ((lambda (syntmp-tmp-1516) (if syntmp-tmp-1516 (apply (lambda (syntmp-body-1517 syntmp-binding-1518) (list (quote #(syntax-object let ((top) #(ribcage #(body binding) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage #(f bindings) #((top) (top)) #("i" "i")) #(ribcage #(let* x v e1 e2) #((top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (list syntmp-binding-1518) syntmp-body-1517)) syntmp-tmp-1516) (syntax-error syntmp-tmp-1515))) (syntax-dispatch syntmp-tmp-1515 (quote (any any))))) (list (syntmp-f-1510 (cdr syntmp-bindings-1511)) (car syntmp-bindings-1511)))))) syntmp-tmp-1498) (syntax-error syntmp-tmp-1497))) (syntax-dispatch syntmp-tmp-1497 (quote (any #(each (any any)) any . each-any))))) syntmp-x-1496))) +(install-global-transformer (quote do) (lambda (syntmp-orig-x-1538) ((lambda (syntmp-tmp-1539) ((lambda (syntmp-tmp-1540) (if syntmp-tmp-1540 (apply (lambda (syntmp-_-1541 syntmp-var-1542 syntmp-init-1543 syntmp-step-1544 syntmp-e0-1545 syntmp-e1-1546 syntmp-c-1547) ((lambda (syntmp-tmp-1548) ((lambda (syntmp-tmp-1549) (if syntmp-tmp-1549 (apply (lambda (syntmp-step-1550) ((lambda (syntmp-tmp-1551) ((lambda (syntmp-tmp-1552) (if syntmp-tmp-1552 (apply (lambda () (list (quote #(syntax-object let ((top) #(ribcage #(step) #((top)) #("i")) #(ribcage #(_ var init step e0 e1 c) #((top) (top) (top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(orig-x) #((top)) #("i"))))) (quote #(syntax-object doloop ((top) #(ribcage #(step) #((top)) #("i")) #(ribcage #(_ var init step e0 e1 c) #((top) (top) (top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(orig-x) #((top)) #("i"))))) (map list syntmp-var-1542 syntmp-init-1543) (list (quote #(syntax-object if ((top) #(ribcage #(step) #((top)) #("i")) #(ribcage #(_ var init step e0 e1 c) #((top) (top) (top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(orig-x) #((top)) #("i"))))) (list (quote #(syntax-object not ((top) #(ribcage #(step) #((top)) #("i")) #(ribcage #(_ var init step e0 e1 c) #((top) (top) (top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(orig-x) #((top)) #("i"))))) syntmp-e0-1545) (cons (quote #(syntax-object begin ((top) #(ribcage #(step) #((top)) #("i")) #(ribcage #(_ var init step e0 e1 c) #((top) (top) (top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(orig-x) #((top)) #("i"))))) (append syntmp-c-1547 (list (cons (quote #(syntax-object doloop ((top) #(ribcage #(step) #((top)) #("i")) #(ribcage #(_ var init step e0 e1 c) #((top) (top) (top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(orig-x) #((top)) #("i"))))) syntmp-step-1550))))))) syntmp-tmp-1552) ((lambda (syntmp-tmp-1557) (if syntmp-tmp-1557 (apply (lambda (syntmp-e1-1558 syntmp-e2-1559) (list (quote #(syntax-object let ((top) #(ribcage #(e1 e2) #((top) (top)) #("i" "i")) #(ribcage #(step) #((top)) #("i")) #(ribcage #(_ var init step e0 e1 c) #((top) (top) (top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(orig-x) #((top)) #("i"))))) (quote #(syntax-object doloop ((top) #(ribcage #(e1 e2) #((top) (top)) #("i" "i")) #(ribcage #(step) #((top)) #("i")) #(ribcage #(_ var init step e0 e1 c) #((top) (top) (top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(orig-x) #((top)) #("i"))))) (map list syntmp-var-1542 syntmp-init-1543) (list (quote #(syntax-object if ((top) #(ribcage #(e1 e2) #((top) (top)) #("i" "i")) #(ribcage #(step) #((top)) #("i")) #(ribcage #(_ var init step e0 e1 c) #((top) (top) (top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(orig-x) #((top)) #("i"))))) syntmp-e0-1545 (cons (quote #(syntax-object begin ((top) #(ribcage #(e1 e2) #((top) (top)) #("i" "i")) #(ribcage #(step) #((top)) #("i")) #(ribcage #(_ var init step e0 e1 c) #((top) (top) (top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(orig-x) #((top)) #("i"))))) (cons syntmp-e1-1558 syntmp-e2-1559)) (cons (quote #(syntax-object begin ((top) #(ribcage #(e1 e2) #((top) (top)) #("i" "i")) #(ribcage #(step) #((top)) #("i")) #(ribcage #(_ var init step e0 e1 c) #((top) (top) (top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(orig-x) #((top)) #("i"))))) (append syntmp-c-1547 (list (cons (quote #(syntax-object doloop ((top) #(ribcage #(e1 e2) #((top) (top)) #("i" "i")) #(ribcage #(step) #((top)) #("i")) #(ribcage #(_ var init step e0 e1 c) #((top) (top) (top) (top) (top) (top) (top)) #("i" "i" "i" "i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(orig-x) #((top)) #("i"))))) syntmp-step-1550))))))) syntmp-tmp-1557) (syntax-error syntmp-tmp-1551))) (syntax-dispatch syntmp-tmp-1551 (quote (any . each-any)))))) (syntax-dispatch syntmp-tmp-1551 (quote ())))) syntmp-e1-1546)) syntmp-tmp-1549) (syntax-error syntmp-tmp-1548))) (syntax-dispatch syntmp-tmp-1548 (quote each-any)))) (map (lambda (syntmp-v-1566 syntmp-s-1567) ((lambda (syntmp-tmp-1568) ((lambda (syntmp-tmp-1569) (if syntmp-tmp-1569 (apply (lambda () syntmp-v-1566) syntmp-tmp-1569) ((lambda (syntmp-tmp-1570) (if syntmp-tmp-1570 (apply (lambda (syntmp-e-1571) syntmp-e-1571) syntmp-tmp-1570) ((lambda (syntmp-_-1572) (syntax-error syntmp-orig-x-1538)) syntmp-tmp-1568))) (syntax-dispatch syntmp-tmp-1568 (quote (any)))))) (syntax-dispatch syntmp-tmp-1568 (quote ())))) syntmp-s-1567)) syntmp-var-1542 syntmp-step-1544))) syntmp-tmp-1540) (syntax-error syntmp-tmp-1539))) (syntax-dispatch syntmp-tmp-1539 (quote (any #(each (any any . any)) (any . each-any) . each-any))))) syntmp-orig-x-1538))) +(install-global-transformer (quote quasiquote) (letrec ((syntmp-quasicons-1600 (lambda (syntmp-x-1604 syntmp-y-1605) ((lambda (syntmp-tmp-1606) ((lambda (syntmp-tmp-1607) (if syntmp-tmp-1607 (apply (lambda (syntmp-x-1608 syntmp-y-1609) ((lambda (syntmp-tmp-1610) ((lambda (syntmp-tmp-1611) (if syntmp-tmp-1611 (apply (lambda (syntmp-dy-1612) ((lambda (syntmp-tmp-1613) ((lambda (syntmp-tmp-1614) (if syntmp-tmp-1614 (apply (lambda (syntmp-dx-1615) (list (quote #(syntax-object quote ((top) #(ribcage #(dx) #((top)) #("i")) #(ribcage #(dy) #((top)) #("i")) #(ribcage #(x y) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage () () ()) #(ribcage #(x y) #((top) (top)) #("i" "i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i"))))) (cons syntmp-dx-1615 syntmp-dy-1612))) syntmp-tmp-1614) ((lambda (syntmp-_-1616) (if (null? syntmp-dy-1612) (list (quote #(syntax-object list ((top) #(ribcage #(_) #((top)) #("i")) #(ribcage #(dy) #((top)) #("i")) #(ribcage #(x y) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage () () ()) #(ribcage #(x y) #((top) (top)) #("i" "i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i"))))) syntmp-x-1608) (list (quote #(syntax-object cons ((top) #(ribcage #(_) #((top)) #("i")) #(ribcage #(dy) #((top)) #("i")) #(ribcage #(x y) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage () () ()) #(ribcage #(x y) #((top) (top)) #("i" "i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i"))))) syntmp-x-1608 syntmp-y-1609))) syntmp-tmp-1613))) (syntax-dispatch syntmp-tmp-1613 (quote (#(free-id #(syntax-object quote ((top) #(ribcage #(dy) #((top)) #("i")) #(ribcage #(x y) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage () () ()) #(ribcage #(x y) #((top) (top)) #("i" "i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i"))))) any))))) syntmp-x-1608)) syntmp-tmp-1611) ((lambda (syntmp-tmp-1617) (if syntmp-tmp-1617 (apply (lambda (syntmp-stuff-1618) (cons (quote #(syntax-object list ((top) #(ribcage #(stuff) #((top)) #("i")) #(ribcage #(x y) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage () () ()) #(ribcage #(x y) #((top) (top)) #("i" "i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i"))))) (cons syntmp-x-1608 syntmp-stuff-1618))) syntmp-tmp-1617) ((lambda (syntmp-else-1619) (list (quote #(syntax-object cons ((top) #(ribcage #(else) #((top)) #("i")) #(ribcage #(x y) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage () () ()) #(ribcage #(x y) #((top) (top)) #("i" "i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i"))))) syntmp-x-1608 syntmp-y-1609)) syntmp-tmp-1610))) (syntax-dispatch syntmp-tmp-1610 (quote (#(free-id #(syntax-object list ((top) #(ribcage #(x y) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage () () ()) #(ribcage #(x y) #((top) (top)) #("i" "i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i"))))) . any)))))) (syntax-dispatch syntmp-tmp-1610 (quote (#(free-id #(syntax-object quote ((top) #(ribcage #(x y) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage () () ()) #(ribcage #(x y) #((top) (top)) #("i" "i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i"))))) any))))) syntmp-y-1609)) syntmp-tmp-1607) (syntax-error syntmp-tmp-1606))) (syntax-dispatch syntmp-tmp-1606 (quote (any any))))) (list syntmp-x-1604 syntmp-y-1605)))) (syntmp-quasiappend-1601 (lambda (syntmp-x-1620 syntmp-y-1621) ((lambda (syntmp-tmp-1622) ((lambda (syntmp-tmp-1623) (if syntmp-tmp-1623 (apply (lambda (syntmp-x-1624 syntmp-y-1625) ((lambda (syntmp-tmp-1626) ((lambda (syntmp-tmp-1627) (if syntmp-tmp-1627 (apply (lambda () syntmp-x-1624) syntmp-tmp-1627) ((lambda (syntmp-_-1628) (list (quote #(syntax-object append ((top) #(ribcage #(_) #((top)) #("i")) #(ribcage #(x y) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage () () ()) #(ribcage #(x y) #((top) (top)) #("i" "i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i"))))) syntmp-x-1624 syntmp-y-1625)) syntmp-tmp-1626))) (syntax-dispatch syntmp-tmp-1626 (quote (#(free-id #(syntax-object quote ((top) #(ribcage #(x y) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage () () ()) #(ribcage #(x y) #((top) (top)) #("i" "i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i"))))) ()))))) syntmp-y-1625)) syntmp-tmp-1623) (syntax-error syntmp-tmp-1622))) (syntax-dispatch syntmp-tmp-1622 (quote (any any))))) (list syntmp-x-1620 syntmp-y-1621)))) (syntmp-quasivector-1602 (lambda (syntmp-x-1629) ((lambda (syntmp-tmp-1630) ((lambda (syntmp-x-1631) ((lambda (syntmp-tmp-1632) ((lambda (syntmp-tmp-1633) (if syntmp-tmp-1633 (apply (lambda (syntmp-x-1634) (list (quote #(syntax-object quote ((top) #(ribcage #(x) #((top)) #("i")) #(ribcage #(x) #((top)) #("i")) #(ribcage () () ()) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i"))))) (list->vector syntmp-x-1634))) syntmp-tmp-1633) ((lambda (syntmp-tmp-1636) (if syntmp-tmp-1636 (apply (lambda (syntmp-x-1637) (cons (quote #(syntax-object vector ((top) #(ribcage #(x) #((top)) #("i")) #(ribcage #(x) #((top)) #("i")) #(ribcage () () ()) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i"))))) syntmp-x-1637)) syntmp-tmp-1636) ((lambda (syntmp-_-1639) (list (quote #(syntax-object list->vector ((top) #(ribcage #(_) #((top)) #("i")) #(ribcage #(x) #((top)) #("i")) #(ribcage () () ()) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i"))))) syntmp-x-1631)) syntmp-tmp-1632))) (syntax-dispatch syntmp-tmp-1632 (quote (#(free-id #(syntax-object list ((top) #(ribcage #(x) #((top)) #("i")) #(ribcage () () ()) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i"))))) . each-any)))))) (syntax-dispatch syntmp-tmp-1632 (quote (#(free-id #(syntax-object quote ((top) #(ribcage #(x) #((top)) #("i")) #(ribcage () () ()) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i"))))) each-any))))) syntmp-x-1631)) syntmp-tmp-1630)) syntmp-x-1629))) (syntmp-quasi-1603 (lambda (syntmp-p-1640 syntmp-lev-1641) ((lambda (syntmp-tmp-1642) ((lambda (syntmp-tmp-1643) (if syntmp-tmp-1643 (apply (lambda (syntmp-p-1644) (if (= syntmp-lev-1641 0) syntmp-p-1644 (syntmp-quasicons-1600 (quote (#(syntax-object quote ((top) #(ribcage #(p) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(p lev) #((top) (top)) #("i" "i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i")))) #(syntax-object unquote ((top) #(ribcage #(p) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(p lev) #((top) (top)) #("i" "i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i")))))) (syntmp-quasi-1603 (list syntmp-p-1644) (- syntmp-lev-1641 1))))) syntmp-tmp-1643) ((lambda (syntmp-tmp-1645) (if syntmp-tmp-1645 (apply (lambda (syntmp-p-1646 syntmp-q-1647) (if (= syntmp-lev-1641 0) (syntmp-quasiappend-1601 syntmp-p-1646 (syntmp-quasi-1603 syntmp-q-1647 syntmp-lev-1641)) (syntmp-quasicons-1600 (syntmp-quasicons-1600 (quote (#(syntax-object quote ((top) #(ribcage #(p q) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage #(p lev) #((top) (top)) #("i" "i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i")))) #(syntax-object unquote-splicing ((top) #(ribcage #(p q) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage #(p lev) #((top) (top)) #("i" "i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i")))))) (syntmp-quasi-1603 (list syntmp-p-1646) (- syntmp-lev-1641 1))) (syntmp-quasi-1603 syntmp-q-1647 syntmp-lev-1641)))) syntmp-tmp-1645) ((lambda (syntmp-tmp-1648) (if syntmp-tmp-1648 (apply (lambda (syntmp-p-1649) (syntmp-quasicons-1600 (quote (#(syntax-object quote ((top) #(ribcage #(p) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(p lev) #((top) (top)) #("i" "i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i")))) #(syntax-object quasiquote ((top) #(ribcage #(p) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(p lev) #((top) (top)) #("i" "i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i")))))) (syntmp-quasi-1603 (list syntmp-p-1649) (+ syntmp-lev-1641 1)))) syntmp-tmp-1648) ((lambda (syntmp-tmp-1650) (if syntmp-tmp-1650 (apply (lambda (syntmp-p-1651 syntmp-q-1652) (syntmp-quasicons-1600 (syntmp-quasi-1603 syntmp-p-1651 syntmp-lev-1641) (syntmp-quasi-1603 syntmp-q-1652 syntmp-lev-1641))) syntmp-tmp-1650) ((lambda (syntmp-tmp-1653) (if syntmp-tmp-1653 (apply (lambda (syntmp-x-1654) (syntmp-quasivector-1602 (syntmp-quasi-1603 syntmp-x-1654 syntmp-lev-1641))) syntmp-tmp-1653) ((lambda (syntmp-p-1656) (list (quote #(syntax-object quote ((top) #(ribcage #(p) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(p lev) #((top) (top)) #("i" "i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i"))))) syntmp-p-1656)) syntmp-tmp-1642))) (syntax-dispatch syntmp-tmp-1642 (quote #(vector each-any)))))) (syntax-dispatch syntmp-tmp-1642 (quote (any . any)))))) (syntax-dispatch syntmp-tmp-1642 (quote (#(free-id #(syntax-object quasiquote ((top) #(ribcage () () ()) #(ribcage #(p lev) #((top) (top)) #("i" "i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i"))))) any)))))) (syntax-dispatch syntmp-tmp-1642 (quote ((#(free-id #(syntax-object unquote-splicing ((top) #(ribcage () () ()) #(ribcage #(p lev) #((top) (top)) #("i" "i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i"))))) any) . any)))))) (syntax-dispatch syntmp-tmp-1642 (quote (#(free-id #(syntax-object unquote ((top) #(ribcage () () ()) #(ribcage #(p lev) #((top) (top)) #("i" "i")) #(ribcage #(quasicons quasiappend quasivector quasi) #((top) (top) (top) (top)) #("i" "i" "i" "i"))))) any))))) syntmp-p-1640)))) (lambda (syntmp-x-1657) ((lambda (syntmp-tmp-1658) ((lambda (syntmp-tmp-1659) (if syntmp-tmp-1659 (apply (lambda (syntmp-_-1660 syntmp-e-1661) (syntmp-quasi-1603 syntmp-e-1661 0)) syntmp-tmp-1659) (syntax-error syntmp-tmp-1658))) (syntax-dispatch syntmp-tmp-1658 (quote (any any))))) syntmp-x-1657)))) +(install-global-transformer (quote include) (lambda (syntmp-x-1721) (letrec ((syntmp-read-file-1722 (lambda (syntmp-fn-1723 syntmp-k-1724) (let ((syntmp-p-1725 (open-input-file syntmp-fn-1723))) (let syntmp-f-1726 ((syntmp-x-1727 (read syntmp-p-1725))) (if (eof-object? syntmp-x-1727) (begin (close-input-port syntmp-p-1725) (quote ())) (cons (datum->syntax-object syntmp-k-1724 syntmp-x-1727) (syntmp-f-1726 (read syntmp-p-1725))))))))) ((lambda (syntmp-tmp-1728) ((lambda (syntmp-tmp-1729) (if syntmp-tmp-1729 (apply (lambda (syntmp-k-1730 syntmp-filename-1731) (let ((syntmp-fn-1732 (syntax-object->datum syntmp-filename-1731))) ((lambda (syntmp-tmp-1733) ((lambda (syntmp-tmp-1734) (if syntmp-tmp-1734 (apply (lambda (syntmp-exp-1735) (cons (quote #(syntax-object begin ((top) #(ribcage #(exp) #((top)) #("i")) #(ribcage () () ()) #(ribcage () () ()) #(ribcage #(fn) #((top)) #("i")) #(ribcage #(k filename) #((top) (top)) #("i" "i")) #(ribcage (read-file) ((top)) ("i")) #(ribcage #(x) #((top)) #("i"))))) syntmp-exp-1735)) syntmp-tmp-1734) (syntax-error syntmp-tmp-1733))) (syntax-dispatch syntmp-tmp-1733 (quote each-any)))) (syntmp-read-file-1722 syntmp-fn-1732 syntmp-k-1730)))) syntmp-tmp-1729) (syntax-error syntmp-tmp-1728))) (syntax-dispatch syntmp-tmp-1728 (quote (any any))))) syntmp-x-1721)))) +(install-global-transformer (quote unquote) (lambda (syntmp-x-1752) ((lambda (syntmp-tmp-1753) ((lambda (syntmp-tmp-1754) (if syntmp-tmp-1754 (apply (lambda (syntmp-_-1755 syntmp-e-1756) (error (quote unquote) "expression ,~s not valid outside of quasiquote" (syntax-object->datum syntmp-e-1756))) syntmp-tmp-1754) (syntax-error syntmp-tmp-1753))) (syntax-dispatch syntmp-tmp-1753 (quote (any any))))) syntmp-x-1752))) +(install-global-transformer (quote unquote-splicing) (lambda (syntmp-x-1762) ((lambda (syntmp-tmp-1763) ((lambda (syntmp-tmp-1764) (if syntmp-tmp-1764 (apply (lambda (syntmp-_-1765 syntmp-e-1766) (error (quote unquote-splicing) "expression ,@~s not valid outside of quasiquote" (syntax-object->datum syntmp-e-1766))) syntmp-tmp-1764) (syntax-error syntmp-tmp-1763))) (syntax-dispatch syntmp-tmp-1763 (quote (any any))))) syntmp-x-1762))) +(install-global-transformer (quote case) (lambda (syntmp-x-1772) ((lambda (syntmp-tmp-1773) ((lambda (syntmp-tmp-1774) (if syntmp-tmp-1774 (apply (lambda (syntmp-_-1775 syntmp-e-1776 syntmp-m1-1777 syntmp-m2-1778) ((lambda (syntmp-tmp-1779) ((lambda (syntmp-body-1780) (list (quote #(syntax-object let ((top) #(ribcage #(body) #((top)) #("i")) #(ribcage #(_ e m1 m2) #((top) (top) (top) (top)) #("i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (list (list (quote #(syntax-object t ((top) #(ribcage #(body) #((top)) #("i")) #(ribcage #(_ e m1 m2) #((top) (top) (top) (top)) #("i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) syntmp-e-1776)) syntmp-body-1780)) syntmp-tmp-1779)) (let syntmp-f-1781 ((syntmp-clause-1782 syntmp-m1-1777) (syntmp-clauses-1783 syntmp-m2-1778)) (if (null? syntmp-clauses-1783) ((lambda (syntmp-tmp-1785) ((lambda (syntmp-tmp-1786) (if syntmp-tmp-1786 (apply (lambda (syntmp-e1-1787 syntmp-e2-1788) (cons (quote #(syntax-object begin ((top) #(ribcage #(e1 e2) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage #(f clause clauses) #((top) (top) (top)) #("i" "i" "i")) #(ribcage #(_ e m1 m2) #((top) (top) (top) (top)) #("i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (cons syntmp-e1-1787 syntmp-e2-1788))) syntmp-tmp-1786) ((lambda (syntmp-tmp-1790) (if syntmp-tmp-1790 (apply (lambda (syntmp-k-1791 syntmp-e1-1792 syntmp-e2-1793) (list (quote #(syntax-object if ((top) #(ribcage #(k e1 e2) #((top) (top) (top)) #("i" "i" "i")) #(ribcage () () ()) #(ribcage #(f clause clauses) #((top) (top) (top)) #("i" "i" "i")) #(ribcage #(_ e m1 m2) #((top) (top) (top) (top)) #("i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (list (quote #(syntax-object memv ((top) #(ribcage #(k e1 e2) #((top) (top) (top)) #("i" "i" "i")) #(ribcage () () ()) #(ribcage #(f clause clauses) #((top) (top) (top)) #("i" "i" "i")) #(ribcage #(_ e m1 m2) #((top) (top) (top) (top)) #("i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (quote #(syntax-object t ((top) #(ribcage #(k e1 e2) #((top) (top) (top)) #("i" "i" "i")) #(ribcage () () ()) #(ribcage #(f clause clauses) #((top) (top) (top)) #("i" "i" "i")) #(ribcage #(_ e m1 m2) #((top) (top) (top) (top)) #("i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (list (quote #(syntax-object quote ((top) #(ribcage #(k e1 e2) #((top) (top) (top)) #("i" "i" "i")) #(ribcage () () ()) #(ribcage #(f clause clauses) #((top) (top) (top)) #("i" "i" "i")) #(ribcage #(_ e m1 m2) #((top) (top) (top) (top)) #("i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) syntmp-k-1791)) (cons (quote #(syntax-object begin ((top) #(ribcage #(k e1 e2) #((top) (top) (top)) #("i" "i" "i")) #(ribcage () () ()) #(ribcage #(f clause clauses) #((top) (top) (top)) #("i" "i" "i")) #(ribcage #(_ e m1 m2) #((top) (top) (top) (top)) #("i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (cons syntmp-e1-1792 syntmp-e2-1793)))) syntmp-tmp-1790) ((lambda (syntmp-_-1796) (syntax-error syntmp-x-1772)) syntmp-tmp-1785))) (syntax-dispatch syntmp-tmp-1785 (quote (each-any any . each-any)))))) (syntax-dispatch syntmp-tmp-1785 (quote (#(free-id #(syntax-object else ((top) #(ribcage () () ()) #(ribcage #(f clause clauses) #((top) (top) (top)) #("i" "i" "i")) #(ribcage #(_ e m1 m2) #((top) (top) (top) (top)) #("i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) any . each-any))))) syntmp-clause-1782) ((lambda (syntmp-tmp-1797) ((lambda (syntmp-rest-1798) ((lambda (syntmp-tmp-1799) ((lambda (syntmp-tmp-1800) (if syntmp-tmp-1800 (apply (lambda (syntmp-k-1801 syntmp-e1-1802 syntmp-e2-1803) (list (quote #(syntax-object if ((top) #(ribcage #(k e1 e2) #((top) (top) (top)) #("i" "i" "i")) #(ribcage #(rest) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(f clause clauses) #((top) (top) (top)) #("i" "i" "i")) #(ribcage #(_ e m1 m2) #((top) (top) (top) (top)) #("i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (list (quote #(syntax-object memv ((top) #(ribcage #(k e1 e2) #((top) (top) (top)) #("i" "i" "i")) #(ribcage #(rest) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(f clause clauses) #((top) (top) (top)) #("i" "i" "i")) #(ribcage #(_ e m1 m2) #((top) (top) (top) (top)) #("i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (quote #(syntax-object t ((top) #(ribcage #(k e1 e2) #((top) (top) (top)) #("i" "i" "i")) #(ribcage #(rest) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(f clause clauses) #((top) (top) (top)) #("i" "i" "i")) #(ribcage #(_ e m1 m2) #((top) (top) (top) (top)) #("i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (list (quote #(syntax-object quote ((top) #(ribcage #(k e1 e2) #((top) (top) (top)) #("i" "i" "i")) #(ribcage #(rest) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(f clause clauses) #((top) (top) (top)) #("i" "i" "i")) #(ribcage #(_ e m1 m2) #((top) (top) (top) (top)) #("i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) syntmp-k-1801)) (cons (quote #(syntax-object begin ((top) #(ribcage #(k e1 e2) #((top) (top) (top)) #("i" "i" "i")) #(ribcage #(rest) #((top)) #("i")) #(ribcage () () ()) #(ribcage #(f clause clauses) #((top) (top) (top)) #("i" "i" "i")) #(ribcage #(_ e m1 m2) #((top) (top) (top) (top)) #("i" "i" "i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (cons syntmp-e1-1802 syntmp-e2-1803)) syntmp-rest-1798)) syntmp-tmp-1800) ((lambda (syntmp-_-1806) (syntax-error syntmp-x-1772)) syntmp-tmp-1799))) (syntax-dispatch syntmp-tmp-1799 (quote (each-any any . each-any))))) syntmp-clause-1782)) syntmp-tmp-1797)) (syntmp-f-1781 (car syntmp-clauses-1783) (cdr syntmp-clauses-1783))))))) syntmp-tmp-1774) (syntax-error syntmp-tmp-1773))) (syntax-dispatch syntmp-tmp-1773 (quote (any any any . each-any))))) syntmp-x-1772))) +(install-global-transformer (quote identifier-syntax) (lambda (syntmp-x-1836) ((lambda (syntmp-tmp-1837) ((lambda (syntmp-tmp-1838) (if syntmp-tmp-1838 (apply (lambda (syntmp-_-1839 syntmp-e-1840) (list (quote #(syntax-object lambda ((top) #(ribcage #(_ e) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (quote (#(syntax-object x ((top) #(ribcage #(_ e) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i")))))) (list (quote #(syntax-object syntax-case ((top) #(ribcage #(_ e) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (quote #(syntax-object x ((top) #(ribcage #(_ e) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (quote ()) (list (quote #(syntax-object id ((top) #(ribcage #(_ e) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (quote (#(syntax-object identifier? ((top) #(ribcage #(_ e) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i")))) (#(syntax-object syntax ((top) #(ribcage #(_ e) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i")))) #(syntax-object id ((top) #(ribcage #(_ e) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))))) (list (quote #(syntax-object syntax ((top) #(ribcage #(_ e) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) syntmp-e-1840)) (list (cons syntmp-_-1839 (quote (#(syntax-object x ((top) #(ribcage #(_ e) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i")))) #(syntax-object ... ((top) #(ribcage #(_ e) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))))) (list (quote #(syntax-object syntax ((top) #(ribcage #(_ e) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i"))))) (cons syntmp-e-1840 (quote (#(syntax-object x ((top) #(ribcage #(_ e) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i")))) #(syntax-object ... ((top) #(ribcage #(_ e) #((top) (top)) #("i" "i")) #(ribcage () () ()) #(ribcage #(x) #((top)) #("i")))))))))))) syntmp-tmp-1838) (syntax-error syntmp-tmp-1837))) (syntax-dispatch syntmp-tmp-1837 (quote (any any))))) syntmp-x-1836))) diff --git a/node-addon-lilypond/output/share/guile/1.8/ice-9/psyntax.ss b/node-addon-lilypond/output/share/guile/1.8/ice-9/psyntax.ss new file mode 100755 index 0000000000000000000000000000000000000000..22e409d3e27a4485f93a16571c4751f24bac327c --- /dev/null +++ b/node-addon-lilypond/output/share/guile/1.8/ice-9/psyntax.ss @@ -0,0 +1,2212 @@ +;;;; -*-scheme-*- +;;;; +;;;; Copyright (C) 2001, 2003, 2006 Free Software Foundation, Inc. +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 2.1 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; + + +;;; Portable implementation of syntax-case +;;; Extracted from Chez Scheme Version 5.9f +;;; Authors: R. Kent Dybvig, Oscar Waddell, Bob Hieb, Carl Bruggeman + +;;; Modified by Mikael Djurfeldt according +;;; to the ChangeLog distributed in the same directory as this file: +;;; 1997-08-19, 1997-09-03, 1997-09-10, 2000-08-13, 2000-08-24, +;;; 2000-09-12, 2001-03-08 + +;;; Copyright (c) 1992-1997 Cadence Research Systems +;;; Permission to copy this software, in whole or in part, to use this +;;; software for any lawful purpose, and to redistribute this software +;;; is granted subject to the restriction that all copies made of this +;;; software must include this copyright notice in full. This software +;;; is provided AS IS, with NO WARRANTY, EITHER EXPRESS OR IMPLIED, +;;; INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY +;;; OR FITNESS FOR ANY PARTICULAR PURPOSE. IN NO EVENT SHALL THE +;;; AUTHORS BE LIABLE FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES OF ANY +;;; NATURE WHATSOEVER. + +;;; Before attempting to port this code to a new implementation of +;;; Scheme, please read the notes below carefully. + + +;;; This file defines the syntax-case expander, sc-expand, and a set +;;; of associated syntactic forms and procedures. Of these, the +;;; following are documented in The Scheme Programming Language, +;;; Second Edition (R. Kent Dybvig, Prentice Hall, 1996). Most are +;;; also documented in the R4RS and draft R5RS. +;;; +;;; bound-identifier=? +;;; datum->syntax-object +;;; define-syntax +;;; fluid-let-syntax +;;; free-identifier=? +;;; generate-temporaries +;;; identifier? +;;; identifier-syntax +;;; let-syntax +;;; letrec-syntax +;;; syntax +;;; syntax-case +;;; syntax-object->datum +;;; syntax-rules +;;; with-syntax +;;; +;;; All standard Scheme syntactic forms are supported by the expander +;;; or syntactic abstractions defined in this file. Only the R4RS +;;; delay is omitted, since its expansion is implementation-dependent. + +;;; The remaining exports are listed below: +;;; +;;; (sc-expand datum) +;;; if datum represents a valid expression, sc-expand returns an +;;; expanded version of datum in a core language that includes no +;;; syntactic abstractions. The core language includes begin, +;;; define, if, lambda, letrec, quote, and set!. +;;; (eval-when situations expr ...) +;;; conditionally evaluates expr ... at compile-time or run-time +;;; depending upon situations (see the Chez Scheme System Manual, +;;; Revision 3, for a complete description) +;;; (syntax-error object message) +;;; used to report errors found during expansion +;;; (install-global-transformer symbol value) +;;; used by expanded code to install top-level syntactic abstractions +;;; (syntax-dispatch e p) +;;; used by expanded code to handle syntax-case matching + +;;; The following nonstandard procedures must be provided by the +;;; implementation for this code to run. +;;; +;;; (void) +;;; returns the implementation's cannonical "unspecified value". This +;;; usually works: (define void (lambda () (if #f #f))). +;;; +;;; (andmap proc list1 list2 ...) +;;; returns true if proc returns true when applied to each element of list1 +;;; along with the corresponding elements of list2 .... +;;; The following definition works but does no error checking: +;;; +;;; (define andmap +;;; (lambda (f first . rest) +;;; (or (null? first) +;;; (if (null? rest) +;;; (let andmap ((first first)) +;;; (let ((x (car first)) (first (cdr first))) +;;; (if (null? first) +;;; (f x) +;;; (and (f x) (andmap first))))) +;;; (let andmap ((first first) (rest rest)) +;;; (let ((x (car first)) +;;; (xr (map car rest)) +;;; (first (cdr first)) +;;; (rest (map cdr rest))) +;;; (if (null? first) +;;; (apply f (cons x xr)) +;;; (and (apply f (cons x xr)) (andmap first rest))))))))) +;;; +;;; The following nonstandard procedures must also be provided by the +;;; implementation for this code to run using the standard portable +;;; hooks and output constructors. They are not used by expanded code, +;;; and so need be present only at expansion time. +;;; +;;; (eval x) +;;; where x is always in the form ("noexpand" expr). +;;; returns the value of expr. the "noexpand" flag is used to tell the +;;; evaluator/expander that no expansion is necessary, since expr has +;;; already been fully expanded to core forms. +;;; +;;; eval will not be invoked during the loading of psyntax.pp. After +;;; psyntax.pp has been loaded, the expansion of any macro definition, +;;; whether local or global, will result in a call to eval. If, however, +;;; sc-expand has already been registered as the expander to be used +;;; by eval, and eval accepts one argument, nothing special must be done +;;; to support the "noexpand" flag, since it is handled by sc-expand. +;;; +;;; (error who format-string why what) +;;; where who is either a symbol or #f, format-string is always "~a ~s", +;;; why is always a string, and what may be any object. error should +;;; signal an error with a message something like +;;; +;;; "error in : " +;;; +;;; (gensym) +;;; returns a unique symbol each time it's called +;;; +;;; (putprop symbol key value) +;;; (getprop symbol key) +;;; key is always the symbol *sc-expander*; value may be any object. +;;; putprop should associate the given value with the given symbol in +;;; some way that it can be retrieved later with getprop. + +;;; When porting to a new Scheme implementation, you should define the +;;; procedures listed above, load the expanded version of psyntax.ss +;;; (psyntax.pp, which should be available whereever you found +;;; psyntax.ss), and register sc-expand as the current expander (how +;;; you do this depends upon your implementation of Scheme). You may +;;; change the hooks and constructors defined toward the beginning of +;;; the code below, but to avoid bootstrapping problems, do so only +;;; after you have a working version of the expander. + +;;; Chez Scheme allows the syntactic form (syntax