[plt-scheme] module-begin change in 203->204?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu May 8 10:26:19 EDT 2003

At Thu, 8 May 2003 02:36:25 -0400, Daniel Hagerty wrote:
> The following example
> definitely behaves differently under 202 vs 204.  204 will error this,
> whereas earlier will evaluate it.  Was it an intentional effect?

Yes. 

> (module modlang mzscheme
>   (provide (all-from-except mzscheme #%module-begin))
> 
>   (provide (rename my-modbegin #%module-begin))
>   (define-syntax (my-modbegin stx)
>     (syntax-case stx ()
>       ((_ F E ...)
>        #'(#%module-begin
> 	  (require "langdata.ss")
> 	  F E ...
> 	  ))))
>   )

Top-level `define's and `require's now introduce bindings hygienically,
just like `let'.

In this case, `my-modbegin' introduces bindings from "langdata.ss", but
the bindings are visible only to other expressions introduced by
`my-modbegin' (and there aren't any such other expressions).

The solution is to introduce the "require" non-hygienically:

(module modlang mzscheme
  (provide (all-from-except mzscheme #%module-begin))

  (provide (rename my-modbegin #%module-begin))
  (define-syntax (my-modbegin stx)
    (syntax-case stx ()
      ((_ F E ...)
       #`(#%module-begin
	  #,(datum->syntax-object stx '(require "langdata.ss"))
	  F E ...
	  ))))
  )


Matthew



Posted on the users mailing list.