所有 Ruby 解释器都遵循相同的 Ruby 语法吗?

发布于 2024-09-17 17:42:15 字数 439 浏览 2 评论 0原文

所有 Ruby 解释器都遵循 www.ruby-lang.org 中定义的相同 Ruby 语法吗?

  • MRI
  • YARV
  • Rubinius
  • JRuby
  • IronRuby

因为它是定义 Ruby 语言的解释器。这是否意味着一个解释器可以添加其他解释器没有的功能/语法糖?

如果是这样的话,是不是所有的解释器都有自己的 API 文档呢?

因为我正在使用: http://ruby-doc.org/ruby-1.9/索引.html

哪些解释器正在实施该解释?

有人可以阐明这个话题吗?

谢谢!

Do all Ruby interpreters follow the same Ruby syntax defined in www.ruby-lang.org?

  • MRI
  • YARV
  • Rubinius
  • JRuby
  • IronRuby

Cause it is the interpreter that defines the Ruby language. Does that mean one interpreter could add a feature/syntatic sugar that other interpreters haven't?

If that is the case, do all interpreters have their own API documentation?

Cause I'm using: http://ruby-doc.org/ruby-1.9/index.html.

Which interpreters are implementing that one?

Could someone shed a light on this topic.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沫雨熙 2024-09-24 17:42:15

所有 Ruby 解释器都遵循 www.ruby-lang.org 中定义的相同 Ruby 语法吗?

是的,它们都使用相同的语法。事实上,它们实际上都使用相同的解析器,或者至少是从同一源文件自动生成的解析器。

因为我正在使用:http://ruby-doc.org/ruby -1.9/index.html.

哪些解释器正在实现该解释器?

目前,唯一完全实现 Ruby 1.9 的生产就绪型 Rub​​y 执行引擎是 YARV。

JRuby 本身已做好生产准备,它实现了 Ruby 1.8.7 和 Ruby 1.9.2,但 Ruby 1.9.2 实现尚未完成。 IronRuby 和 Rubinius 也在致力于 Ruby 1.9.2 的实现。 MacRuby 拥有相当完整的 Ruby 1.9 实现,但距离 1.0 版本还很远。 MRI 没有实现 Ruby 1.9,而且可能永远不会。

但我不明白你为什么如此关心语法。语法差异很容易发现:如果语法存在差异,引擎将简单地拒绝解析您的文件,您会立即知道有问题。另一方面,语义的差异则危险得多。

Do all Ruby interpreters follow the same Ruby syntax defined in www.ruby-lang.org?

Yes, they all use the same syntax. In fact, they actually all use the same parser, or at least a parser that was automatically generated from the same source file.

Cause I'm using: http://ruby-doc.org/ruby-1.9/index.html.

Which interpreters are implementing that one?

At the moment, the only production-ready Ruby execution engine that implements Ruby 1.9 fully is YARV.

JRuby itself is production-ready, and it implements both Ruby 1.8.7 and Ruby 1.9.2, but the Ruby 1.9.2 implementation is not yet complete. IronRuby and Rubinius are also working on implementations of Ruby 1.9.2. MacRuby has a fairly complete Ruby 1.9 implementation, but it is still far from a 1.0 release. MRI doesn't implement Ruby 1.9 and probably never will.

But I don't understand why you are so concerned about the syntax. Syntax differences are trivial to spot: if there were a difference in the syntax, the engine would simply refuse to parse your file and you would know immediately that there is something wrong. Differences in semantics on the other hand are much more dangerous.

森末i 2024-09-24 17:42:15

您指的是哪一点“语法糖”?

请记住,Ruby 有非常小的一组关键字。很多乍一看似乎是关键字的东西实际上是由内核实现的(例如 requireputsraise)。

http://apidock.com/ruby/Kernel

Which bit of "syntactic sugar" are you referring to?

Keep in mind that ruby has a very small set of keywords. A lot of stuff that seems to be a keyword at first is actually implemented by Kernel (eg require, puts, and raise).

http://apidock.com/ruby/Kernel

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文