Monday, May 7, 2012


Macros are considered evil by those who have seen how disastrous their effect on program and difficult debugging may be. Like anonymous closures, they simplify the code but without the runtime overhead of procedures (procedures require argument computation event if they are not used) and closures (closures create loads of use-once classes, which need to be instantiated and garbage-collected). They are just useful code generators.

It would be simpler to define a macros like
   if (v1Declar != null)
        simulator.setObjectValue(v1Declar, args);
        return ReturnStatus.CONTINUE;
   else {
        throwReport(msg, location);
        return ReturnStatus.ERROR;
and call it in two different places rather than copy-paste over and over again. You cannot define a procedure for that.

No comments: