David Hopwood wrote:
Peter Van Roy wrote:
Raphael Collet wrote:
Alan Oswald wrote:
The GetText function uses get($) as a text string. How do I get it
as a number?
Convert it: {String.toInt "42"} returns 42.
A more powerful way is to compile it:
I={Compiler.evalExpression "42" env _}
This compiles the string as if you typed it as source code, and then
evaluates the expression.
Unless there is a very good reason why this power is needed, the
String.toInt method should be used, since evaluating expressions from
potentially untrusted input will create security problems.
I agree. I just wanted to give an example to show the limits of what is
possible.
If you call the compiler, then you should probably filter the input. If
you're
really paranoid, you should call the compiler in another process using
Mozart's
distribution support (e.g., using the functor technique on page 730 of CTM).
That way, you can kill the process if the compilation takes too many
resources.
Peter
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users