英文:
Is Groovy 3 syntax an exact superset of Java syntax?
问题
这个问题,Groovy语法是否完全是Java语法的超集?,在近十年内没有更新。
我的理解是,Groovy 3已经填补了与Java语法之间的剩余差距,成为了一个纯粹的超集。我相信这就是Wikipedia在提到Groovy时所指的,
与Java语法兼容
这是正确的吗,还是仍然有Java(11)语法在Groovy中无效?
英文:
The question, Is Groovy syntax an exact superset of Java syntax? has not been updated in nearly a decade.
My understanding is that Groovy 3 has closed the remaining gaps with Java syntax, to become a pure superset. I believe this is what Wikipedia means when it refers to Groovy as,
> Java-syntax-compatible
Is this correct, or is there still Java (11) syntax that is invalid Groovy?
答案1
得分: 1
我找到了一个权威页面:http://groovy-lang.org/differences.html,然而,大多数的区别是行为上的(运行时),而不是语法上的。
可能只有两个语法差距仍然存在。
- Groovy 3 不支持 Java 的速记数组初始化。
int[] array = {1, 2, 3};
- Groovy 3 不支持 Java 的字符串字面字符
$
。String dollar = "$"
Groovy 3 包括五个额外的关键字;然而,这可能对编译 Java 代码没有问题。
Groovy 比 Java 更宽松,因为它允许一些关键字出现在在 Java 中是非法的地方。
英文:
I found an authoritative page: http://groovy-lang.org/differences.html, however, most of the differences are behavioral (runtime) rather than syntactic.
There may be only two syntax gaps remaining.
- Groovy 3 does not support Java's shorthand array initialization.<br/>
int[] array = {1, 2, 3};
- Groovy 3 does not support Java's String literal dollar character.<br/>
String dollar = "$"
Groovy 3 includes five additional keywords; however, this may not be a problem for compiling Java code.
> Groovy is less stringent than Java in that it allows some keywords to appear in places that would be illegal in Java
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论