[racket] local-expand and stop-lists?

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Fri Aug 12 13:55:58 EDT 2011

Darn it, I declared victory too soon, as usual.  :)


I'm still running into the same problem even switching out with
#%plain-module-begin.  Here's where I am now:


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; small-lang.rkt
#lang racket
(provide (except-out (all-from-out racket)
                     #%module-begin)
         (rename-out [my-module-begin #%module-begin])
         lift-to-toplevel)

;; lift-to-toplevel is meant to cooperate with module-begin.
(define-syntax (lift-to-toplevel stx)
  (printf "lift to toplevel\n")
  #'(void))

(define-syntax (my-module-begin stx)
  (syntax-case stx ()
    [(_ body ...)
     (begin
       (printf "Expanding...\n")
       (with-syntax ([(pmb expanded-body ...)
                      (local-expand #'(#%plain-module-begin body ...)
                                    'module-begin
                                    (list #'lift-to-toplevel))])
         (printf "expanded\n")
         (syntax/loc stx
           (#%module-begin expanded-body ...))))]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



but I'm seeing the expander still expanding out lift-to-toplevel much
too early when I compile and run the program:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#lang s-exp "small-lang.rkt"
(lift-to-toplevel)
42
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

I see:

--------------------
Expanding...
lift to toplevel
expanded
42
--------------------


I want to see this instead:

-----------------------
Expanding...
expanded
lift to toplevel
42
-----------------------


Posted on the users mailing list.