MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Evaluate a string

  • To: mathgroup at
  • Subject: [mg25129] Evaluate a string
  • From: Phlip <phlip_cpp at>
  • Date: Sun, 10 Sep 2000 03:14:49 -0400 (EDT)
  • Sender: owner-wri-mathgroup at


The inner problem. In Perl, for example, you can evaluate a string back
in thru the Perl parser:

    my x = 0;
    eval "x = 3";
    assert (x == 3);

I have a string containing Mathematica language code. How do I evaluate
it as a Mathematica statement?

Taking the code out of the string is not an option. (But I could
conceivably write the string to a file, and then Load or Run this. But
I can't find a Mathematica command to load a file and execute it.)

The outer problem:

I'm trying to turn Mathematica into a server, using Python's PYML
package. This cleverly wraps up all the Mathematica language primitives
into Python primitives, so you _don't_ need to evaluate strings; you
just add and subtract Python objects. I don't want that; I just need
glue that takes in the string from some client, warms up MathLink,
submits the string, and gets the results off the drive.

To do this the MathLink way, I need to use MLEvaluateString().

But this is not a real MathLink function (!?). It's code you get
automagically generated using the Mathematica Template preprocessor.

I can't use that, because PYML already has a ML.c, which is a finished,
working program that does not use the preprocessor. I don't want to
rewrite it or retrofit it. If I try to copy-n-paste MLEvaluateString
from a template-based project, it suffers runaway dependencies.

Where is the optimal path thru all this to some simple environmental
features that all other languages have???

======= =======

Sent via
Before you buy.

  • Prev by Date: Re: Assumptions ignored?
  • Next by Date: Re: Security considerations in Mathematica&J/Link
  • Previous by thread: Re: 1.11.5 Exporting Formulas from Notebooks
  • Next by thread: Re: Evaluate a string