;FIXME sloppy, # only after srfi, which must be 1st (define (module-name-element? x) (or (symbol? x) (fixnum? x))) (define (module-name-element->string m) (->string m)) (define (reverse-module-name-elements->symbol l) (string->symbol (reverse-string-append (intersperse l "."))) ) (define (srfi-module? mdl) (and (eq? 'srfi (car mdl)) (pair? (cdr mdl)) (number? (cadr mdl))) ) (define (canonicalize-srfi-name n) (string-append "srfi" "-" (number->string n)) ) (define (canonical-module-name x) (cond ((symbol? x) x ) ((and (pair? x) (every module-name-element? x)) (let loop ((mdl x) (l '())) (cond ((null? mdl) (reverse-module-name-elements->symbol l)) ((and (null? l) ;1st time (srfi-module? mdl)) (let ((md (canonicalize-srfi-name (cadr mdl)))) (loop (cddr mdl) (cons md l))) ) (else (let ((md (module-name-element->string (car mdl)))) (loop (cdr mdl) (cons md l))) ) ) ) ) (else #f ) ) ) (define (canonicalize-module-name x) (or (canonical-module-name x) (error 'canonicalize-module-name "invalid module name" x)) )