|
1 | 1 | (define-library (srfi-tools library)
|
2 |
| - (export srfi-library-names-sxml |
| 2 | + (export srfi-map-library-names |
| 3 | + srfi-library-names |
| 4 | + srfi-r6rs-imports |
| 5 | + srfi-library-names-sxml |
3 | 6 | srfi-generate-library-names)
|
4 | 7 | (import (scheme base)
|
5 | 8 |
|
|
14 | 17 | (srfi-tools url))
|
15 | 18 | (begin
|
16 | 19 |
|
| 20 | + (define (srfi-map-library-names proc) |
| 21 | + (filter-map (lambda (srfi) |
| 22 | + (let ((name (srfi-library-name srfi))) |
| 23 | + (and name (proc (srfi-number srfi) name)))) |
| 24 | + (srfi-list))) |
| 25 | + |
| 26 | + (define (srfi-library-names) |
| 27 | + (srfi-map-library-names cons)) |
| 28 | + |
| 29 | + (define-command (library-names) |
| 30 | + "List library names (SRFI 97 and beyond)." |
| 31 | + (display-two-column-table (srfi-library-names))) |
| 32 | + |
| 33 | + (define (r6rs-import num name) |
| 34 | + ;; Return a string instead of an S-expression because symbols |
| 35 | + ;; starting with a colon are handled inconsistently by Scheme |
| 36 | + ;; implementations. Some of them escape such symbols to avoid |
| 37 | + ;; confusing them with keywords. R6RS standard syntax does not |
| 38 | + ;; support those escapes. |
| 39 | + (format "(import (srfi :~a ~a))" num name)) |
| 40 | + |
| 41 | + (define (r7rs-import num name) |
| 42 | + ;; R7RS may add the names at some point. |
| 43 | + (format "(import (srfi ~a))" num)) |
| 44 | + |
| 45 | + (define (srfi-r6rs-imports) |
| 46 | + (srfi-map-library-names r6rs-import)) |
| 47 | + |
| 48 | + (define-command (r6rs-imports) |
| 49 | + "List R6RS (import ...) for each SRFI (SRFI 97 and beyond)." |
| 50 | + (for-each write-line (srfi-r6rs-imports))) |
| 51 | + |
17 | 52 | (define (srfi-library-names-sxml)
|
18 | 53 | (let ((title "SRFI library names"))
|
19 | 54 | `(html
|
|
31 | 66 | (tr (th "")
|
32 | 67 | (th "R6RS")
|
33 | 68 | (th "R7RS"))
|
34 |
| - ,@(filter-map |
35 |
| - (lambda (srfi) |
36 |
| - (let ((num (srfi-number srfi)) |
37 |
| - (name (srfi-library-name srfi))) |
38 |
| - (and name |
39 |
| - `(tr (td (a (@ (href ,(srfi-landing-url num)) |
40 |
| - (title ,(srfi-title srfi))) |
41 |
| - "SRFI " ,(number->string num))) |
42 |
| - (td (code ,(format "(import (srfi :~a ~a))" |
43 |
| - num name))) |
44 |
| - (td (code ,(format "(import (srfi ~a))" |
45 |
| - num))))))) |
46 |
| - (srfi-list))))))) |
| 69 | + ,@(srfi-map-library-names |
| 70 | + (lambda (num name) |
| 71 | + `(tr (td (a (@ (href ,(srfi-landing-url num)) |
| 72 | + (title ,(srfi-title num))) |
| 73 | + "SRFI " ,(number->string num))) |
| 74 | + (td (code ,(r6rs-import num name))) |
| 75 | + (td (code ,(r7rs-import num name))))))))))) |
47 | 76 |
|
48 | 77 | (define (srfi-generate-library-names)
|
49 | 78 | (let ((file (path-append (srfi-common-dir) "library-names.html"))
|
|
52 | 81 | (write-html-file file sxml)))
|
53 | 82 |
|
54 | 83 | (define-command (generate-library-names)
|
55 |
| - "Display the SRFI 97 library names." |
| 84 | + "Write web page of library names (SRFI 97 and beyond)." |
56 | 85 | (srfi-generate-library-names))))
|
0 commit comments