From: Eduard R. <asp...@ed...> - 2005-04-04 15:49:22
|
Hi hammett > > As you've already used ANTLR, I was wondering if it might not be a better > > idea to develop a C# compiler with some added keywords, that contains > > "normal" C# as subset and implement the Aspect features into the compiler > > instead. > Wow! That's quite a move, huh? Instead of a compiler we could develop a > pre-processor, but then we would need to integrate it with VS.Net and > several issues could come afterwards... The thought had occurred to me to do it over a pre-processor. In my experience that generally ends up being an unhappy solution because you generally have a hard time pinning some of the problems. I once worked with a pre-processor from oracle for embedded SQL in C++ and that was a real dog. That was one of the reasons I dropped that idea early on. AFAIK ANTLR already has a C# compiler, so I was thinking just to use that and extend it. I don't know in what sort of state it is, so that might be more work too, but it would probably save a lot of extra hassle, etc. > IMHO it would be best to stick with the dynamic approach, the same used by > dynaop. I'll admit I've written only a few very small compilers so far (hardly worth the name), so the work one would face is probably more then I would believe. I also see that it would be a shame to loose all the effort invested so far. > > For one thing certain limitations like having to declare the methods > > virtual > > for an IMethodInterceptor could be resolved. > If you weave the resulting code, then it's true. I'll also admit I haven't thought it through in every detail, which is why some input from your side would be great. Like I said, I'm just toying with the idea right now. > > For another thing it would also > > allow for realizing Interceptors for constuctors or maybe for assignments > > or > > comparisons. > I thought DynProxy would be able to intercept operators.... I also haven't looked at your code in detail so my thinking might be going in the wrong way. Unfortunately one can't overload the assignment, nor the new operator (which is why you have this engine-builder thing). That means one would never be able to intercept assignments - at least not the ones from builtin types. Of course that would create some security issues as well (which is why they don't allow it in the first place). The other thing that occurred to me in connection with the issue of security and access restriction: as far as I can tell, I can intercept and mix in my code into any object which was instantiated over the engine. It probably would be sensible to somehow include mechanisms to not allow it under certain circumstances (like when something is sealed, etc) but that might be able to be implemented in the current makeup. An own compiler could just make it slightly easier, that is all. Greets, Eduard |