If, in C/C++, we use #define, what about in Java? -
okay so, if not mistaken, in c or c++ use code below shorten or substitute statement different one. can write p
rather printf
command right?
#define p printf
then how in java?
java not have macros, or pre-processing step.
1 must realize every programming language comes own set of tools.
many times macros used c++ templates or java generics can used, example in case of max macro.
if want have pre processing state, should consider inserting step build system (i.e - maven pluggin) go on "java code macros", generate real java files (similar how inline functions behave in c++), , compile generated java code.
can find examples example in case java code generated xsd or other schemas, theoretically, why not generate "java macros code"?
if example @ project lombok see introduce "properties" systax java, in fact introduced ide plugins (so code not "broken" or "in error" when code favorite ide), , introduced mavan steps/goals can build developed lombok.
maybe should adopt similar approach, if crucial (actually in past , prior jdk 5, how "annotations" used in frameworks, should have reason in code).
Comments
Post a Comment