Thank you for your replies.
@TomasMatousek: no, I'm not using IronJS at the moment, though I will as soon as I'm out of the "design phase" (not much else to use when it comes to dlr and ecmascript, it seems).
@dinov: thanks for your input, I'll keep the "scope + .Execute()" suggestion in mind.
I'm writing a library. Some of the infrastructure provided by this library should be (scripting) language-independent. I chose Ecmascript as an example because that's the language I'd like to use when I'll be doing tests. Library users should be able to
load a "schema", from either a xml file or a db for instance. This schema features scripted event handlers (something happens, script runs).
I'd like library users / end users to just type method bodies in the schema, in order to a) enforce a specific method signature b) specific param names c) minimize method signature mistakes or name collisions when dealing with many scripts d) have less to
type for very simple event handlers (one line).
I also think that method bodies alone can help me swap out languages and scripts more easily, because of the following (purely imaginary) code:
IScriptingEngine engine = /* pick engine from config file or hardcoded here */;
IScript script = engine.LoadFromChunk("component.HP -= msg.Value;"); // valid only if it's the engine language, of course
var componentInst = /* */;
var msgInst = /* */;
script.Run(new ScriptScope(new ScriptParam("component", componentInst), new ScriptParam("msg", msgInst)));
The only thing changing is the script passed to the LoadFromChunk method; parameters passed are something that I, as the library author, have full control on.
I hope that made sense...
Thank you again for your time.