mark richardson schrieb:
MyOzCode = "local X=3 in X+X end"
{Browse {Compiler.virtualStringToValue MyOzCode}}
Hi, I can see that working but what if MyOzCode="{Browse 1+2}" for example - that doesn't work!? I tried using Browser.browse, feeding a module link first, but that doesn't work either.
These two alternatives should both work:

(1) First define a functor that imports the
   resources used, then apply it:
declare F={Compiler.virtualStringToValue
"functor $ import Browser define {Browser.browse 1+2} end"}
declare [M]={Module.apply [F]}

(2) Pass the resources to the compiler
   in the environment record, and make
   sure it's really an expression:
declare Result = {Compiler.evalExpression
"{Browser.browse 1+2} unit"
env('Browser':Browser) _}

In (1), if you extend it to export some value,
you can access it from M:

declare F={Compiler.virtualStringToValue
"functor $ import Browser export sum:Sum define Sum=1+2 {Browser.browse Sum} end"}
declare [M]={Module.apply [F]}
{Browse sum#M.sum}

In (2), the Result is just the dummy value
unit that makes it an expression.  You could
of course export Sum instead:

declare Result = {Compiler.evalExpression
"local Sum=1+2 in {Browser.browse Sum} Sum end"
env('Browser':Browser) _}
{Browse result#Result}

HTH,
Andreas

_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to