[plt-scheme] Re: Best place to install custom current-module-name-resolver?

From: Derick Eddington (derick.eddington at gmail.com)
Date: Thu Apr 10 11:40:56 EDT 2008

On Thu, 2008-04-10 at 08:35 -0700, Derick Eddington wrote:
> Hi, I've made a hacked current-module-name-resolver so it can find
> module/library files with more file type extensions than only .ss 

Might as well post it:

  (let ([cmnr (current-module-name-resolver)])
       [(a) (cmnr a)]
       [(mod-path src-mod . args)
        #;(printf "*** My current-module-name-resolver got: ~s\n" 
                (cons mod-path (cons src-mod args)))
        (if (list? mod-path)
          (apply cmnr mod-path src-mod args)
          (let ([mp (if (symbol? mod-path) 
                      (resolved-module-path-name (cmnr mod-path src-mod #f #f))
            (let loop ([exts '(".ss" ".sls" ".scm" ".sch" ".mzscheme.ss" 
                               ".mzscheme.sls" ".mzscheme.scm" 
                       [last-ex #f])            
              (if (null? exts)
                (raise last-ex)
                (let ([r (with-handlers ([exn:fail? values])
                           #;(printf "***   Trying ~a\n" (car exts))
                           (apply cmnr 
                                  ((if (string? mp) path->string values)
                                   (path-replace-suffix mp (car exts))) 
                                  src-mod args))])
                  (if (exn:fail? r) 
                    (loop (cdr exts) r)

: Derick

Posted on the users mailing list.