[plt-scheme] Difference between 'send' and 'send' in an eval?

From: Sarino Suon (ssuon at polaris.umuc.edu)
Date: Tue Apr 29 11:46:21 EDT 2003


Thank you, thank you. It works!

Your little example elucidates everything about how the class mechanism

This is my summary of what's going on for those who run into this
problem, reflecting what you explained in the last email: 
When another "instance" of the "class.ss" module is created,
you are really working within a new class mechanism, and thus the same
objects created by both mechanisms are incompatible. Therefore, you
will see a cryptic error message complaining that a target X is
incorrect for a certain method, when it really requires X' (the same X but
within the other class mechanism).

The code example you gave of reusing the same module within the new
namespace works great. I give it again below, with an additional necessary
step to reload the "class.ss" module:

> (define (make-namespace-with-class)
>     (let ([orig (current-namespace)]
> 	  [mod-name ((current-module-name-resolver)
> 		      '(lib "class.ss") #f #f)]
> 	  [ns (make-namespace 'initial)])
>       (parameterize ([current-namespace ns])
> 	(namespace-attach-module orig mod-name)
>       ns)))

(define ns (make-namespace-with-class))

;; Set up namespace so it can access the variable
(parameterize ((current-namespace ns))
	(namespace-set-variable-value! 'obj obj))

;; Now load the same version of the class module into it and eval
(parameterize ((current-namespace ns))
	(eval '(require (lib "class.ss")))
	(eval '(send obj method)))

--- Sarino

Posted on the users mailing list.