[plt-scheme] make-module macro

From: wayne at taxupdate.com (wayne at taxupdate.com)
Date: Tue Jan 17 13:20:19 EST 2006

I'd like to do this in a macro:

(begin
  (module test mzscheme
    (provide (all-defined))
    (define (testf) (display "worked\n")))
  (require (prefix test. test))
  
Testing with:

(test.testf) 

produces:

worked
  
Here's my attempt:

(define-syntax (make-module stx)
  (syntax-case stx ()
   ((make-module module-name expr ...)
    (with-syntax ((dotted-id
                   (datum->syntax-object
		    (syntax make-module)
		    (string->symbol
		     (string-append
		      (symbol->string
 		       (syntax-object->datum (syntax module-name)))
		       ".")))))
     #`(begin
        (module module-name mzscheme
	 (provide (all-defined))
	 expr ...
	 )
	(require (prefix dotted-id module-name)))))))
	

Testing with:

(make-module test
  (define (testf) (display 'ok))
  (display "test ran\n"))
  
produces:
test ran

but (test.testf) fails with reference to undefined identifier.  Any suggestions?

Wayne


Posted on the users mailing list.