[racket] MzCOM

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Aug 9 11:17:23 EDT 2012

At Thu, 09 Aug 2012 11:17:44 +0200, heraklea at gmx.de wrote:
> Hello friends,
> I have questions again about MzCom. 
> 1.: I create an Object in DrRacket from MzCom. Like this:
> (require ffi/com)
> (define MZCOM (com-create-instance "MzCOM.MzObj"))
> (com-invoke MZCOM "eval" "print \"hello\"")
> I get this output: "\"hello\""

When you evaluate "print \"hello\"", then you're evaluating two expressions:




where only the result of the last expression is returned.

Did you mean "(print \"hello\")"?

> So far so good.
> When I create an Object in C++ and eval the same expression I get a
> #<void>

If you used "(print \"hello\")", then you'd get a #<void> result, so I
wonder whether you used different strings in your Racket and C++ tests.

To capture printed output, use something like

 (com-invoke MZCOM "eval" 
             (format "~s"
                       (lambda ()
                          (print "hello")))))

> 2.: Is it possible to get all Objects/Functions/variable that I create in the 
> actual scope?

I'm not sure what you mean by "actual scope", but for a top-level
namespace, `namespace-mapped-symbols' will give you a list of defined
names, and `namespace-variable-value' will let you get the value of

Posted on the users mailing list.