是否有Java或C#宏工具? [英] Are there macro facility for Java or C#?

查看:83
本文介绍了是否有Java或C#宏工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

宏是很有用的。

所以,我偶尔会哀叹没有Java和C#宏。宏允许我在网上力量,而是让我非宏代码代码管理。

Therefore, I occasionally bemoan the absence of macros in Java and C#. Macros allow me to force in-line but allow me the code-manageability of non-macro code.

有没有基于Java或C#为基础的项目/产品某处有没有有效地让宏或指定的在线扩展。

Is there any Java- or C#-based project/product somewhere out there that effectively allow macros or specifying in-line expansion.

我想到的是这样

@macro公共无效打招呼(INT X){...}

@macro public void hello(int x){ ... }

或当我调用一个方法,在调用之前的@inline注释将影响被叫方法是在-lined。

or when I call a method, an @inline annotation preceding the call would effect the called-method to be in-lined.

或者,我应该要知道,我只相信编译器能够做出最好的决定对我来说,在最佳其分析它可能在-line的电话。

or, should I need to know that I should just trust the compiler to make the best the decision for me that at the best of its analysis it might in-line a call.

我希望这个问题不会导致辩论PRO /缺点/宏的用处。

I hope this question will not lead to debating the pro/cons/usefulness of macros.

推荐答案

宏是不是标准的Java语言的一部分,我不知道任何宏观预处理器的主流Java工具,集成开发环境等支撑。所以,如果你在Java代码中使用宏你应该会遇到一些痛。例如,

Macros are not part of the standard Java language, and I'm not aware of any macro preprocessor being supported by mainstream Java tools, IDEs and so on. So if you use macros in your Java code you should expect to experience some "pain". For example,


  • 源代码调试器不会让你设置相对于原始源代码中设置断点。

  • 如果您共享您的Java使用的宏代码,许多Java开发人员很可能在它打开了自己的鼻子,和/或抱怨不得不安装/使用额外的工具。

有第三方的宏预处理器的Java相当多的例子;例如 Jatha ,的 OpenJava PrintMacroJ JavaMacros ,等等......(但你有没有曾经遇到过使用其中的任何一个项目?)

There are quite a few examples of third-party macro pre-processors for Java; e.g. Jatha, OpenJava, PrintMacroJ, JavaMacros, and so on ... (But have you ever come across a project that uses any of them?)

宏让我给力在网上,但让我非宏代码代码管理。

Macros allow me to force in-line but allow me the code-manageability of non-macro code.

真。但是JIT编译器也许可以做一个更好的工作比你能确定哪些的内联。它会知道(肯定)的块有多大,这将对执行频率,分支预测等不属于提供给您的运行时统计信息。

True. But the JIT compiler can probably do a better job than you can in determining what should be inlined. It will know (for sure) how big the chunks are, and it will have runtime stats on execution frequency, branch prediction, etc that are not available to you.

请注意有可对内联影响优化的决定一些热点JVM优化选项;看到此页面,并扫描inlin。例如,有一个似乎让你增加一个内联方法体上大小阈值。

Note that there are some Hotspot JVM tuning options that can influence the optimizer's decisions on inlining; see this page, and scan for "inlin". For instance, there is one that seems to allow you to increase the upper size threshold for an inlined method body.

这篇关于是否有Java或C#宏工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆