[plt-scheme] chaining module begin

From: Mike T. Machenry (dskippy at ccs.neu.edu)
Date: Wed Oct 6 15:56:13 EDT 2004

I am having trouble figuring out why the following does not work. I want to 
create a module language that provided its own #%module-begin interms of 
another module language that does that same. However, I get an error that 
#%app is unhappy:

module-begin-problem.ss:15:4: compile: bad syntax; function application is 
not allowed, because no #%app syntax transformer is bound in: (syntax-case 
stx () ((_ expr ...) (syntax (#%module-begin (write 2) expr ...))))

-mike

;;;;;;;;;;
;; Start Code

(module foo mzscheme
  (provide (all-from-except mzscheme #%module-begin)
	   (rename module-begin #%module-begin))
  (define-syntax (module-begin stx)
    (syntax-case stx ()
      [(_ expr ...)
       #'(#%module-begin
	  (write 1)
	  expr ...)])))

(module bar foo
  (provide (all-from-except mzscheme #%module-begin)
	   (rename module-begin #%module-begin))
  (define-syntax (module-begin stx)
    (syntax-case stx ()
      [(_ expr ...)
       #'(#%module-begin
	  (write 2)
	  expr ...)])))


Posted on the users mailing list.