Implementing AST Vistitor inside or outside the Analysis class
-
Hi, I'm writing a simple visitor-based analysis in Java using Eclipse. Here I have to implement a tree-walker analysis within Crystal. But I wanna know the difference (advantages/disadvantages) between implementing the visitor class inside the analysis class or outside that. Ex: Inner visitor class public class MyAnalysis extends AbstractCrystalMethodAnalysis { ... private class MyVisitor extends ASTVisitor { ... } ... } I really appreciate if some can tell me the difference between these two implementations.
-
Hi, I'm writing a simple visitor-based analysis in Java using Eclipse. Here I have to implement a tree-walker analysis within Crystal. But I wanna know the difference (advantages/disadvantages) between implementing the visitor class inside the analysis class or outside that. Ex: Inner visitor class public class MyAnalysis extends AbstractCrystalMethodAnalysis { ... private class MyVisitor extends ASTVisitor { ... } ... } I really appreciate if some can tell me the difference between these two implementations.
I would turn the question around and ask: why do you want to make the visitor a private inner class? What are you hoping to gain by doing that?
-
I would turn the question around and ask: why do you want to make the visitor a private inner class? What are you hoping to gain by doing that?
I'm new to this stuff. I was following some sample codes and there I saw inner-class implementations. So I wonder what's the difference between inner and outter implementations. BTW I'm implementing the AST visitor as a public class even inside the Analysis class.
-
I'm new to this stuff. I was following some sample codes and there I saw inner-class implementations. So I wonder what's the difference between inner and outter implementations. BTW I'm implementing the AST visitor as a public class even inside the Analysis class.
Usage of inner classes is one of those things that some Java coders get very worked up about, for and against. Personally, I don't much like them but they have their uses. There are plenty of opinions on the net about whether to use them, when to use them, how to use them. For every one person who says "Do it this way" you will find another who says "Don't do it that way". The one thing I would say is: if you are making AST Visitor publicly visible outside Analysis, why not just make it an outer class on its own? What do you gain by making it an inner class of Analysis?