Ruby 是否有正式的规范(如 Java 语言规范 (JLS))?
Ruby 是否有一个明确的规范,类似于 Java 的 Java 语言规范。谷歌搜索 ruby 语言规范提供了 http://ruby-std.netlab.jp/ 结果,但是该网站已关闭,我不确定它是否是最新的
Is there a definitive specification for Ruby, akin to the Java Language Specification for Java. Googling ruby language specification provides http://ruby-std.netlab.jp/ as a result, but the site is down and i am not sure whether it is current
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有草案用于Ruby 的正式规范。它由开放标准推广中心开发http://WWW.IPA.Go.Jp/index-e.html" rel="nofollow noreferrer">信息技术振兴机构(日本政府机构)提交给 日本工业标准委员会,然后进一步访问 国际标准化组织。
然而,没有人真正使用这个规范。 实际使用的规范是直接可执行的 RubySpec,所有主要 Ruby 实现者都使用它,例如 Rubinius、< a href="http://IronRuby.Net/" rel="nofollow noreferrer">IronRuby, JRuby, MacRuby, 磁悬浮等等。
ISO 草案规范和 RubySpec 之间的三个主要区别是:
有关 Ruby 行为的另一个重要来源(双关语)是 源代码Rubinius内核,它实现了Ruby语言和Ruby核心库的语义。 (注意:很多人更喜欢 源代码 YARV,但我不这样做,原因有两个:首先,YARV 是 C 语言,并不是每个 Ruby 专家都知道这种语言,而 Rubinius 是(希望)每个 Rubiyst 都知道 Ruby,其次,Rubinius 代码库的结构更好,设计良好,组织良好,测试良好,文档齐全。)
There is a draft for a formal specification of Ruby. It is being developed by the Open Standards Promotion Center of the Information-Technology Promotion Agency (a Japanese government agency) for submission to the Japanese Industrial Standards Committee and then further on to the International Organization for Standardization.
However, nobody actually uses this specification. The specification that is actually being used is the directly executable RubySpec, which is used by all the major Ruby implementors like Rubinius, IronRuby, JRuby, MacRuby, MagLev and so on.
The three main differences between the ISO Draft Specification and RubySpec are:
Another great source (pun intended) of information about the behavior of Ruby is the source code of the Rubinius kernel, which implements the semantics of the Ruby language and the Ruby core library. (Note: a lot of people prefer the source code of YARV, but I don't, for two reasons: firstly, YARV is in C, which is a language that not every Rubyist knows, whereas Rubinius is in Ruby, which (hopefully) every Rubiyst knows, and secondly, the Rubinius codebase is much better structured, well-designed, well-organized, well-tested, well-documented.)
参考文献
另请参阅
References
See also
如果您转到
https://docs.ruby-lang.org/ en/2.6.0/syntax_rdoc.html
或
https://www.ruby -lang.org/en/documentation/
“官方 Ruby API 文档”
https:// /docs.ruby-lang.org/en/
https:// docs.ruby-lang.org/en/2.6.0/
然后在“页面”下选择“语法”
然后您将看到此页面,其中包含指向其他相关页面的链接
https://docs.ruby-lang.org/en/2.6.0/syntax_rdoc.html
Ruby 语法很大,分为以下几个部分:
文字
数字、字符串、数组、哈希等
赋值
赋值和变量
控制表达式
if、unless、while、until、for、break、next、redo
方法
方法和方法参数语法
调用方法
如何调用方法(或向方法发送消息)
模块和类
创建模块和类,包括继承
异常
异常处理语法
优先级
ruby 运算符的优先级
改进
实验性改进功能的使用和行为
其他
别名、undef、开始、结束
If you go to
https://docs.ruby-lang.org/en/2.6.0/syntax_rdoc.html
or
https://www.ruby-lang.org/en/documentation/
"The official Ruby API documentation"
https://docs.ruby-lang.org/en/
https://docs.ruby-lang.org/en/2.6.0/
then under 'pages' choose 'syntax'
Then you get this page, with its links to other relevant pages
https://docs.ruby-lang.org/en/2.6.0/syntax_rdoc.html
The Ruby syntax is large and is split up into the following sections:
Literals
Numbers, Strings, Arrays, Hashes, etc.
Assignment
Assignment and variables
Control Expressions
if, unless, while, until, for, break, next, redo
Methods
Method and method argument syntax
Calling Methods
How to call a method (or send a message to a method)
Modules and Classes
Creating modules and classes including inheritance
Exceptions
Exception handling syntax
Precedence
Precedence of ruby operators
Refinements
Use and behavior of the experimental refinements feature
Miscellaneous
alias, undef, BEGIN, END