[CM] R7RS support
salutis at me.com
Tue Jan 25 10:37:54 PST 2022
bil at ccrma.Stanford.EDU writes:
> Thanks. (*s7* 'filenames) should be (*s7* 'file-names).
> If you don't want the libc stuff, just comment out the
> (require libc.scm) at the top of the file. I didn't
> realize that r7rs thinks current-output-port is a built-in
> parameter object. It isn't in s7 -- sorry.
Got it. Thanks so much!
FYI, we still do not use the official s7 import code because it does not
take into account [module] directories. While R7RS says nothing about
it, e.g. Guile interprets library names such that library '(A B-C
D-E-F)' resides in file 'A/B-C/D-E-F.scm'.
I hacked the directory support in as follows:
;; Return the name of the file containing the LIB. For example, we
;; expect the library (A B-C D-E-F) in the file A/B-C/D-E-F.scm.
(define (library-file lib)
(let* ((chars-old (string->list (object->string lib)))
(let recur ((chars chars-old))
(if (null? chars) chars
(let* ((old (car chars))
(new (cond ((or (char-alphabetic? old)
(char=? old #\-)) old)
((char-whitespace? old) #\/)
(cons new (recur (cdr chars)))
(recur (cdr chars))))))))
(string-append (list->string chars-new) ".scm")))
This brings s7 *much* closer to others, and we can now run unit tests on
both s7 and Guile side-by-side! Perhaps s7 should do this out of the
P.S. 1/2: 'r7rs.scm' needs a dummy definition for the '(scheme
process-context)' library. Without it, anything with e.g. 'exit' breaks
for no good reason.
P.S. 2/2: Speaking of ports [in the original message], I found that the
following code does not say "hi" in s7 for some reason:
(display "hi" (current-error-port))
Thank you again for all your help!
"Thinking is a momentary dismissal of irrelevancies."
-- Richard Buckminster Fuller, 1969
Rudolf Adamkovič <salutis at me.com> [he/him]
More information about the Cmdist