strawberryfrog.livejournal.com |
Mon 2013-07-15 16:21 |
If you're going to parse it at compile time, then any language with first-class functions will do something much simpler than this, unless I'm missing something. in C#:
Func<int, int> doubler = x => x * 2;
in Javascript:
var doubler = function(x) { return x * 2 };
I know, there's no "compile time" in JS. But it's equivalent syntax anyway.
If it's deferred until runtime, then the c# syntax is far more complex and unwieldy but probably more flexible: http://blogs.msdn.com/b/csharpfaq/archive/2009/09/14/generating-dynamic-methods-with-expression-trees-in-visual-studio-2010.aspx |
|