Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: How to use CLR enum in script?

I see that we have a design philosophy difference here. You want to keep the .NETish part as much as possible. But when we use scripts, we want to minimize that as much possible. In ideal case, script writers don't need to know .NET at all. The .NET interop layer is only a convenience so that we don't need to go back to C++ to provide objects to script. It is just like a web developer who works with the web page DOM, where the script writer does not need to know C++/COM nor follow C++/COM typing rules. I agree that it is not easy/trouble-free to achieve 100% of that. But I will expect a script writer can feel at home most of the time. If he/she encounters .NET quirks frequently and has to use varies workarounds, it is clearly wrong design (either the language choice or the interop choice).

Having tried LuaInterface and IronPython, I'd say they do the job very well. You really feel at home when working with them. However, some irrational part of me really want the web language instead. Pity that the road to .NET-Javascript integration is not so easy.

Anyway, here's more findings:
1) I finally find out why I was confused on enum values:
print() is a host method with a string parameter.
print("Key.Space = " + Key.Space); // result is "Key.Space = [object HostObject]"
print(Key.Space); // result is "Space"
You see the different results?

2) ScriptEngineException.ErrorDetails is null when an error happened inside an event callback function.
This only happens with JScriptEngine. V8ScriptEngine works fine.

And 2 feature related questions:
1) Does ClearScript support or intend to support .NET's dynamic/expendo object? I mean, in natural script syntax.
2) It is possible to enable V8's harmony features?

Viewing all articles
Browse latest Browse all 2297