所有 Ruby 解释器都遵循相同的 Ruby 语法吗?
所有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,它们都使用相同的语法。事实上,它们实际上都使用相同的解析器,或者至少是从同一源文件自动生成的解析器。
目前,唯一完全实现 Ruby 1.9 的生产就绪型 Ruby 执行引擎是 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,而且可能永远不会。
但我不明白你为什么如此关心语法。语法差异很容易发现:如果语法存在差异,引擎将简单地拒绝解析您的文件,您会立即知道有问题。另一方面,语义的差异则危险得多。
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.
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.
您指的是哪一点“语法糖”?
请记住,Ruby 有非常小的一组关键字。很多乍一看似乎是关键字的东西实际上是由内核实现的(例如
require
、puts
和raise
)。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
, andraise
).http://apidock.com/ruby/Kernel