[racket] MzCOM

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Aug 15 11:09:03 EDT 2012

At Wed, 15 Aug 2012 17:01:43 +0200, "murat demirtas" wrote:
> Ok I try your suggestion: In drRacket I make this:
> 
> (require ffi/com)
> (define MZCOM (com-create-instance "MzCOM.MzObj"))
> (com-invoke MZCOM "eval" 
>              (format "~s"
>                      '(with-output-to-string
>                        (lambda ()
>                           (print "hello")))))
> 
> This gives me an output like exactly this:"\"\\\"hello\\\"\""

That looks right. The string you are sending to Eval() is

 "(with-output-to-string (lambda () (print \"hello\")))"

> When I create an Com-Object in C++ and eval the expression:
> (format "~s" '(with-output-to-string (lambda () (print "hello"))))
> I get this: "(with-output-to-string (lambda () (print \"hello\")))"

Since

 (format "~s" '(with-output-to-string (lambda () (print "hello"))))

isn't a C++ expression, I think the string you are sending to Eval() in
this case is

 "(format \"~s\" '(with-output-to-string (lambda () (print \"hello\"))))"

If that's right, then the string you get back is the right result.


In other words, it seems that I have confused you by trying to format
the Racket code more nicely. Forget `format' for now and just consider
this form:

 (com-invoke MZCOM "eval" 
              "(with-output-to-string (lambda () (print \"hello\")))")



Posted on the users mailing list.