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
-----------------------
_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users

Reply via email to