宏是什么东西啊,呵,现在都什么年代了,谁还用宏啊,java里面有输出测试语句,在jbuilder里面也有debug。

解决方案 »

  1.   

    “输出测试语句”是什么?
    没有宏,那如果在编程时插入测试语句,发布时就要一句一句删去那些测试语句了呀~
    还有一些常量的定义怎么办?(用static好像耗内存呀)
      

  2.   

    use assert in 1.4
    wrap up the System.out as another class like Debug.
    such as:
    class Debug{
       public final debug(String msg){System.out.println(msg);}
    }
    when publishing, comment out the System.out.println in the debug() method.
    Theoretically, static final variable does not have to use memory.
    Even though Java does, Java does not care that little memory overhead at all.
      

  3.   

    但如果这种情况:有两个编译器,其中有某个语法的写法在两个编译器各不相同,C用可以用宏来进行条件判断,那JAVA怎样做呢?(虽然现在没有这种情况,但万一如果有怎办)
      

  4.   

    not possible. although there're differences between different version, you are only targeting one version when you write code.even standard C does not have this problem.conditional compilation makes it harder to maintain your code.
      

  5.   

    那当初为什么要在C中引入宏,现在的assert不也是宏来的吗?
      

  6.   

    It's just a trade-off. macro makes something easier, but also makes many things hard. it just depends on the language designer's decision.
    at the beginning, Java decided to keep it simple. and now, assert is introduced, which is one step toward C's side. but assert is still not as flexible as macro, so not so dangerous as macro as well.
      

  7.   

    聊了这么久终于有点神会了,既是说JAVA去掉了C的灵活性,用这个代价换取语言的简单性,是吧。
    ajoo(聪明的一猪):
         你是留学生吗?这手英文是怎样练出来的呀??请教!
      

  8.   

    Java prefers simplicity and robustness to flexibility. Do you know refactoring? Now, many refactoring theory is only based on smalltalk and Java. C/C++ is too hard to be refactored in generalbut, actually I don't quite like Java's over-zealous insistence on language's simplicity too much. Many things like enum, const annotation(most importantly) should be there. My english? don't joke on me. you don't see how awkward I am when I speak to those GuiZi.