Search for eval function in any .NET language

Does any .NET / CLR language support the eval function and also allow calls to standard .NET code (for example, calls to C # code)? I know that neither F # nor support for C # eval . Are there any other options?

I am ideally looking for a solution compatible with .NET 3.5 (so I think this excludes Clojure -CLR), but I'm interested in any / all options.

+4
source share
4 answers

JScript.NET has an eval function, see this answer

+1
source
+3
source

Not sure if this will help, but as you said, you are looking for some solution. What about IronRuby?

 public static class RubyEngineCreator { private static ScriptEngine ironRubyEngine = null; private static ScriptEngine CreateEngine() { if (ironRubyEngine == null) ironRubyEngine = Ruby.CreateEngine(); return ironRubyEngine; } public static dynamic GetRubyObject(string script) { return CreateEngine().CreateScriptSourceFromString(script).Execute(); } } [TestClass] public class UnitTest { private T Eval<T>(string s) { return (T)RubyEngineCreator.GetRubyObject(s); } [TestMethod] public void Should_Return4_4() { var result = Eval<int>("2 + 2"); Assert.AreEqual(4, result); } } 

Example taken from http://viniciusquaiato.com/blog/eval-em-c-com-ironruby/ (pt-BR)

+1
source

My possible solution was to accept IronPython. JScript.NET technically works, but it is clumsy for use with Visual Studio 2008 and JScript.NET seems to be deprecated by Microsoft. IronPython, on the other hand, has a fairly active community.

0
source

All Articles