[plt-scheme] chaining module begin

From: Mike T. Machenry (dskippy at ccs.neu.edu)
Date: Wed Oct 13 17:47:24 EDT 2004

Matthew, the following gives me the same error:

(module survey mzscheme
  
  (provide (rename module-begin #%module-begin)
	   (all-from-except mzscheme #%module-begin))
  
  (define-syntax (module-begin stx)
    (syntax-case stx (control pages)
      [(_ body ... )
       (let ((s #`(#%module-begin
		   body ...)))
	 (datum->syntax-object s (syntax-e s) s))]))
  )

(module survey-front (file "survey.ss")
  
  (provide (rename module-begin #%module-begin)
	   (all-from-except mzscheme #%module-begin))

  (define-syntax (module-begin stx)
    (syntax-case stx ()
      [(_ body ...)
       (let ([s #'(#%module-begin body ...)])
	 (datum->syntax-object s (syntax-e s) s))]))
  )

(module mysurvey (file "survey-front.ss")
  (+ 1 1))

Did I misinterpret what you said?

-mike

On Wed, Oct 06, 2004 at 02:04:27PM -0600, Matthew Flatt wrote:
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 
> This is a problem expanding to a non-hygienic macro. The
> `#%module-begin' from MzScheme introduces
>   (require-for-syntax mzscheme)
> into the module body. It does that using the context of the
> `#%module-begin' form.
> 
> In this case, you can solve the problem by putting the context of `stx'
> onto the result:
> 
>  (module foo mzscheme
>    (provide (all-from-except mzscheme #%module-begin)
>             (rename module-begin #%module-begin))
>    (define-syntax (module-begin stx)
>      (syntax-case stx ()
>        [(_ expr ...)
>         (let ([s #'(#%module-begin
>                     (write 1)
>                     expr ...)])
>           (datum->syntax-object stx (syntax-e s) stx))])))
> 
> Matthew
> 
> At Wed, 6 Oct 2004 15:56:13 -0400, "Mike T. Machenry" wrote:
> > 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.