[plt-scheme] Expand with stop-list?

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Mon Nov 20 17:32:22 EST 2006

Is there a version of expand with a stop-list tugged away in
a library somewhere?

I'd like to use it in the following sitation:

The module B implements a "base language".
Module A expands to constructs in B.
It is now interesting to see what the expansion
of A, where syntax from B is not expanded.


Here is a base-language:

   (module my-or mzscheme
     (provide my-or
              (all-from-except mzscheme or))
     (define-syntax my-or
       (syntax-rules ()
         [(my-or expr ...)
          (or expr ...)])))

Here is a module implemented in the base-language:

   (module foo my-or
     (display (my-or 1 2)))

A normal expansion gives:

 > (syntax-object->datum
    (expand '(module foo my-or
               (display (my-or 1 2)))))

(module foo my-or
     (require-for-syntax mzscheme)
     (#%app display (let-values
                      (((or-part) (#%datum . 1)))
                       (if or-part
                           (#%datum . 2))))))

I imagine an "expand with stop-list" with my-or
in the stop-list would produce:

   (module foo my-or
       (require-for-syntax mzscheme)
       (#%app display (my-or 1 2))))

My experiments with local-expand with a 'top-level
as expansion context didn't work.

Jens Axel Søgaard

Posted on the users mailing list.