[plt-scheme] Evaluating code in namespace of calling module

From: Corey Sweeney (corey.sweeney at gmail.com)
Date: Sat Mar 19 13:50:50 EST 2005

> I'd like to evaluate code by a function or macro that is defined in a
> module foo, but the code should be evaluated with respect to all of the
> bindings that are currently active in the module bar that calls the
> custom evaluation function required from foo. So far, I've tried
> passing (current-namespace) to the evaluation function and then use
> parameterize in module foo, but this doesn't seem to work. Perhaps it
> doesn't work because I use let*?

i ran into similar namespace problems with modules myself so coded
another solutoin up.  here's it is:

put this is the module:

  (define gb:cont #f)
  (define param-in (list #f (lambda () void)))
  (eval (let ((sexp-pair (call/cc (lambda (x) (set! gb:cont x)))))
          (if (not (list? sexp-pair))
              (lambda () void)
                (set! param-in sexp-pair)
                (car sexp-pair))))) 
 (if (not (equal? (car param-in) `starting-state-xyzzy))
      ((cadr param-in)))

(provides gb:cont)

;;then use it like this in the calling code:
;;(call/cc (lambda (z) (gb:cont (list `(define xdf 88) z))))

it works, but didn't solve my problem as i was trying to access a
library that was already loaded by the drscheme gui, but doing a
"requires" aparenly makes another copy, so i set everything in the
right module, but the wrong running instance.


Posted on the users mailing list.