• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

is macro substitution possible in java?

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
vishal avad
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have been programming in java for only three months so at the risk of sounding dumb I ask, what is macros and what do they do?
 
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
macro. Map's links above are definitely worth a look.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic