[CM] R7RS support
Rudolf Adamkovič
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)))
(chars-new
(let recur ((chars chars-old))
(if (null? chars) chars
(let* ((old (car chars))
(new (cond ((or (char-alphabetic? old)
(char-numeric? old)
(char=? old #\-)) old)
((char-whitespace? old) #\/)
(else #f))))
(if new
(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
box?
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))
(flush-output-port (current-error-port))
(exit 1)
Thank you again for all your help!
Rudy
--
"Thinking is a momentary dismissal of irrelevancies."
-- Richard Buckminster Fuller, 1969
Rudolf Adamkovič <salutis at me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia
More information about the Cmdist
mailing list