4 ms·
Does anyone have more information on this bit? "It resembles a model developed by Miguel de Icaza's Mono Project, in which the information the compiler generat
by haasted 15y ago
Does anyone have more information on this bit?
"It resembles a model developed by Miguel de Icaza's Mono Project, in which the information the compiler generates about a program can be reused as a library."
Sounds very interesting, but the article unfortunately doesn't go into much detail about the information that is made available.
- bad_user 15y agoBasically you can just compile and execute arbitrary strings of C# code at runtime. Here's a small tutorial on doing something with Mono's implementation: http://weblogs.asp.net/jgalloway/archive/2011/05/26/dynamic-asp-net-mvc-3-models-using-mono-s-compiler-as-a-service.aspx http://weblogs.asp.net/jgalloway/archive/2011/05/26/dynamic-...
- thwarted 15y agoSo it's eval, and they skip all the dire warnings from everyone about eval being bad by calling it Compiler as a Service.
- LeafStorm 15y agoThe main issues with using eval come when eval has access to the scope of whatever is calling it, as it can make unpredictable changes. Just compiling and running code constructed at runtime isn't a bad idea in itself, as long as you use proper techniques to ensure that users can't do code injection.
- thwarted 15y agoThat's a good point, and is an language design/implementation specific condition. PHP doesn't create a new stack frame for eval'ed code, so it runs right in the context of the calling function. In constrast, LambdaMOO does create a separate stack frame, which is subjected to the same scope rules as any other function call. You can control if it does or not in perl (by stuffing some additional syntax into the eval'ed string). But the usual issue that is bandied about is how it's inefficient because it needs to invoke the code parser. Searching hacker news for eval shows the wide range of positions, a lot (but not a wide majority) just parrot the inefficiency argument. But there are also a few posts with solid reasons to use eval too.