[racket] Overload #%module-begin

From: Ryan Culpepper (ryanc at ccs.neu.edu)
Date: Wed Feb 26 16:44:11 EST 2014

'syntax-parameterize' is an *expression* form that takes a sequence of 
internal definitions and a non-empty sequence of expressions---like 
lambda. It requires a final expression, and it can't contain requires, 
provides, etc.

You probably want 'splicing-syntax-parameterize' instead. It can be used 
around top-level (or module-level) definitions as well as (IIRC) 
requires and provides.

Ryan


On 02/26/2014 04:43 PM, antoine wrote:
> Hello,
>
> I would like to change the expansion of a given module.
>
> I tested:
> ;; abc.rkt
> #lang racket
> (require racket/stxparam)
>
> (define-syntax-parameter param-abc #f)
>
> (define-syntax-rule (enable-abc body ...)
>    (#%plain-module-begin
>     (syntax-parameterize ([param-abc #t])
> 			body ...)))
>
> (provide (rename-out [enable-abc #%module-begin])
> 	 (except-out
> 	  (all-from-out racket)
> 	  #%module-begin))
>
> ;;edf.rkt
> (module garage "abc.rkt"
>     (define (a) 1))
>
>
> When i do a "raco expand edf.rkt" i get:
> begin (possibly implicit): no expression after a sequence of internal definitions
>    in: (begin (define-values (a) (lambda () 1)))
>
> I have no idea by who this begin is introduced?
>
> My ultimate goal is to change the expansion result of a module given some parameters.
> example:
> (expand
>    (transform-the-list
>      (read (open-input-file "some-file.rkt"))
>      params))
>
> where transform-the-list will transform something like '(module bla bla (%module-begin ...)) into '(module bla bal (%module-begin (syntax-parameterize (...) ...)))
>
> But for now i am stick with the first problem :)
>
> Thanks you.
> ____________________
>    Racket Users list:
>    http://lists.racket-lang.org/users
>


Posted on the users mailing list.