Hi all Anybody has any idea how to achieve macro substitution in java. I ve following code. Which works fine in fox pro
same thing is also possible in VB So please let me know how to access a value inside a variable's value. please reply asap thx in adv vishal
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
posted
0
This isn't very easy in Java. Chances are good you'd want to reconsider your design to avoid needing to do this. But you can use reflection to achieve this sort of effect if you need to:
"I'm not back." - Bill Harding, Twister
vishal avad
Ranch Hand
Joined: Nov 29, 2001
Posts: 45
posted
0
Hi Jim Thanx It works Fine, Sorry for my repeat post of message in begineer. Actually i m a bit confused with the level of question. It wont happen again thanx again vishal
Mapraputa Is
Leverager of our synergies
Sheriff
Joined: Aug 26, 2000
Posts: 10065
posted
0
Recently I was investigating macros as a way to extend a language, and here this question came There are several interesting projects that add macro functionality to Java at various levels. Vishal's example is simple abbreviation (an advanced variant allows parameters), Jatha can do that. More interesting applications are where macros are a tool for building abstractions. OpenJava extends Java's reflection system by providing a programmer with "metaobject" abstraction, via which he can query a state of the program (classes, methods...) and modify it at compile time, thus adding new features to the language. (syntax extensions have only limited support). Even more advanced approach is to allow programmer extend syntax of the language with new constructs. Java Syntactic Extender (JSE) is one such project, Metamorphic Syntax Macros is another. (the latter paper has a nice general overview of macro functionality). You can, for example, amend Java with forEach operator: forEach(Task elt in tasks) elt.stop(); and whose expansion would be: Iterator i = tasks.iterator(); while (i.hasNext()) { Task elt = (Task)i.next(); elt.stop(); } (this example is stolen from JSE paper) As an extreme manifestation of power of macros, totally new, domain-specific languages can be build on base of a host language. On base of Java and "metamorphic syntax macros", a DSL for Web services was built. The Jakarta Tool Set (JTS) provides tools for creating domain specific languages. [ August 11, 2002: Message edited by: Mapraputa Is ]