この規格 プレビューページの目次
※一部、英文及び仏文を自動翻訳した日本語訳を使用しています。
序文
ISO (国際標準化機構) と IEC (国際電気標準会議) は、世界標準化のための専門システムを形成しています。 ISO または IEC のメンバーである国家機関は、技術活動の特定の分野を扱うために、それぞれの組織によって設立された技術委員会を通じて、国際規格の開発に参加しています。 ISO と IEC の技術委員会は、相互に関心のある分野で協力しています。 ISO および IEC と連携して、政府および非政府の他の国際機関もこの作業に参加しています。情報技術の分野では、ISO と IEC が合同技術委員会 ISO/IEC JTC 1 を設立しました。
国際規格は、ISO/IEC 指令で指定された規則に従って起草されます。 2.
合同技術委員会の主な任務は、国際規格を作成することです。合同技術委員会によって採択された国際規格草案は、投票のために各国の機関に回覧されます。国際規格として発行するには、投票を行う国の機関の少なくとも 75% による承認が必要です。
このドキュメントの要素の一部が特許権の対象となる可能性があることに注意してください。 ISO および IEC は、そのような特許権の一部またはすべてを特定する責任を負わないものとします。
ISO/IEC 30170 は、日本工業規格委員会によって (JIS X3017 として) 作成され、合同技術委員会 ISO/IEC JTC 1, 情報技術によって、特別な「ファストトラック手順」の下で採用されました。 ISO および IEC の国家機関。
序章
この国際標準は、JIS X3017「プログラミング言語 Ruby」と呼ばれる日本の国家標準化団体からの提出物に基づいており、2011 年に登録および公開されました。
Ruby は、開発者にとって使いやすく、生産的で直感的に使えるように設計されたオブジェクト指向のスクリプト言語です。世界中で、特に Web アプリケーション開発者の間で Ruby への関心が高まり続けており、Ruby の使用は Web アプリケーションからプライベート ツールにまで及びます。
Ruby 言語の成長と普及に伴い、世界的に合意された文書化された Ruby 仕様はありません。用途の多様化や実装間の非互換性による混乱を避けるため、国際標準として日本工業規格が提案されています。
複数の Ruby 実装が利用可能です。それらの多くは、オープン ソース ソフトウェアとして配布されています。 「Matz Ruby 実装 (MRI)」と呼ばれる実装は、事実上すべての実装者が MRI と比較して実装の互換性をチェックする限り、リファレンス実装として扱われてきました。したがって、Ruby のこの仕様は、MRI の厳密なサブセットとして体系化されています。
この国際標準は、十分に安定しており、MRI バージョン間で共通であり、既存の実装間で互換性があるコア言語機能とコア ライブラリのみを指定します。現在配布および保守されている MRI には 2 つのバージョンがあります。2003 年から利用できる MRI 1.8 と、2010 年にリリースされた MRI 1.9 です。現在、MRI 1.8 は MRI 1.9 よりも広く使用されています。 MRI 1.9 の使用は、今後数年間で広がる可能性があります。将来の相違を避けるために、変更が計画されているか、または予想される機能は、このバージョンの仕様から除外されるか、機能の動作が指定されていないことが明確に述べられています。たとえば、この仕様では、文字タイプの取り扱いについては、ISO/IEC 10646 の完全なサポートのために MRI 1.9 で変更される予定であるため、詳細に指定していません。ISO/IEC 10646 の完全なサポートは、将来的に標準化される予定です。この規格のバージョン。この仕様で定義されているライブラリは、一般的に使用されているか、単純なプログラムを作成するために必要なものに限定されています。
この国際標準では、Ruby 言語の柔軟な構文と動的なセマンティクスをできるだけ単純に指定するために、特別な表記法と「実行コンテキスト」と呼ばれる概念が導入されています。
1 スコープ
この国際標準は、コンピュータ プログラミング言語 Ruby の構文とセマンティクス、および準拠する Ruby プロセッサ、厳密に準拠する Ruby プログラム、および準拠する Ruby プログラムの要件を指定します。
この国際規格は、
- •適合プロセッサが評価するプログラム テキストのサイズまたは複雑さの制限。
- •適合プロセッサをサポートできるデータ処理システムの最小要件。
- •データ処理システム上でプログラムの実行をアクティブ化する方法、および
- •構文エラーおよび実行時エラーを報告する方法。
注Ruby プログラムの実行とは、Ruby プロセッサによってプログラム(10 を参照) を評価することです。
2 参考文献
本書の適用には、以下の参考文献が不可欠です。日付のある参考文献については、引用された版のみが適用されます。日付のない参照については、参照文書の最新版 (修正を含む) が適用されます。
- ISO/IEC 646:1991, 情報技術 — 情報交換用の ISO 7 ビット コード化文字セット。
- IEC 60559:1989, マイクロプロセッサ システムのバイナリ浮動小数点演算。
- ISO/IEC 2382-1:1993, 情報技術 — 語彙 — 1: 基本用語。
4 用語と定義
このドキュメントでは、次の用語と定義が適用されます。その他の用語は、 太字斜体 または構文規則の左側に表示される場所で定義されます。
4.1
ブロック
メソッド呼び出しに渡される手続き
4.2
クラス
インスタンスと呼ばれる他のオブジェクトのセットの動作を定義するオブジェクト
注記 1:動作は、インスタンスで呼び出すことができる一連のメソッドです。
4.3
クラス変数
クラスのすべてのインスタンスによって値が共有される変数
4.4
絶え間ない
クラスまたはモジュールで定義され、クラスまたはモジュールの内外でアクセス可能な変数
注記1通常、定数の値はプログラムの実行中に変更されないままであると予想されますが、この国際規格はこの予想を強制しません。
4.5
例外
例外的な出来事を表すオブジェクト
4.6
グローバル変数
プログラムのどこからでもアクセスできる変数
4.7
実装定義
実装ごとに異なる可能性があるが、実装ごとに定義されている動作
4.8
インスタンスメソッド
クラスのすべてのインスタンスで呼び出すことができるメソッド
4.9
インスタンス変数
オブジェクトのすべてのインスタンスが持つ一連の変数バインディングに存在する変数
4.10
ローカル変数
メソッド定義、ブロック、クラス定義、モジュール定義、シングルトン クラス定義、またはプログラムのトップ レベルなどのプログラム構造によって導入された特定のスコープでのみアクセス可能な変数
4.11
方法
オブジェクトに対して呼び出されたときに、オブジェクトに対して一連の計算を実行するプロシージャ
4.12
メソッドの可視性
メソッド呼び出しが許可される条件を決定するメソッドの属性
4.13
モジュール
クラスまたは別のモジュールに含まれる機能を提供するオブジェクト
4.14
オブジェクト
状態と振る舞いを持つ計算エンティティ
注記 1オブジェクトの動作は、オブジェクトで呼び出すことができる一連のメソッドです。
4.15
シングルトンクラス
関連付けられたオブジェクトの動作を変更できるオブジェクト
注記 1シングルトン クラスは通常、1 つのオブジェクトに関連付けられます。ただし、適合プロセッサは、13.4.1 で説明されているように、シングルトン クラスを複数のオブジェクトに関連付けることができます。
4.16
シングルトーン方式
シングルトンクラスのインスタンスメソッド
4.17
不特定
実装間で異なる可能性があり、必ずしもすべての実装で定義されているわけではない動作
4.18
変数
変数の値と呼ばれるオブジェクトを参照する計算エンティティ
4.19
変数バインディング
変数と変数によって参照されるオブジェクトとの間の関連付け
Foreword
ISO (the International Organization for Standardization) and IEC (the International Electrotechnical Commission) form the specialized system for worldwide standardization. National bodies that are members of ISO or IEC participate in the development of International Standards through technical committees established by the respective organization to deal with particular fields of technical activity. ISO and IEC technical committees collaborate in fields of mutual interest. Other international organizations, governmental and non-governmental, in liaison with ISO and IEC, also take part in the work. In the field of information technology, ISO and IEC have established a joint technical committee, ISO/IEC JTC 1.
International Standards are drafted in accordance with the rules given in the ISO/IEC Directives, 2.
The main task of the joint technical committee is to prepare International Standards. Draft International Standards adopted by the joint technical committee are circulated to national bodies for voting. Publication as an International Standard requires approval by at least 75 % of the national bodies casting a vote.
Attention is drawn to the possibility that some of the elements of this document may be the subject of patent rights. ISO and IEC shall not be held responsible for identifying any or all such patent rights.
ISO/IEC 30170 was prepared by the Japanese Industrial Standards Committee (as JIS X3017) and was adopted, under a special"fast-track procedure", by Joint Technical Committee ISO/IEC JTC 1, Information technology, in parallel with its approval by the national bodies of ISO and IEC.
Introduction
This International Standard is based upon a submission from the Japanese National Standards Body called JIS X3017"Programming Language Ruby", registered and published in 2011.
Ruby is an object-oriented scripting language designed to be developer-friendly, productive and intuitive. There is a continuing growth of interest in Ruby around the world, especially among web application developers, while its use spans from web applications to private tools.
As the Ruby language grows and spreads, there is no globally agreed upon documented Ruby specification. In order to avoid confusion as a result of diversification of usage and incompatibility among implementations, the Japan Industry Standard is proposed as an international standard.
There are multiple Ruby implementations available. Many of them are distributed as open source software. The implementation called"Matz Ruby Implementation (MRI)" has been treated as a reference implementation insofar as virtually all implementers check compatibility of their implementations by comparing them to MRI. Therefore, this specification of Ruby is codified as a strict subset of MRI.
This International Standard specifies only core language features and core libraries which are stable enough and common between MRI versions and compatible between existing implementations. There are two versions of MRI currently distributed and maintained: MRI 1.8, which has been available since 2003 and MRI 1.9, which was released in 2010. Currently, MRI 1.8 is more widely used than MRI 1.9. Use of MRI 1.9 will likely spread in the next several years. To avoid future divergence, features which are planned or prospected to be changed are excluded from this version of the specification, or it is clearly stated that the behavior of the features are not specified. For example, this specification does not specify the handling of character type in detail because it is planned to be changed in MRI 1.9 for full support of ISO/IEC 10646. The full support of ISO/IEC 10646 is going to be standardized in a future version of this standard. The library defined in this specification is limited to that which is commonly used or necessary to write simple programs.
This International Standard introduces special notations and a concept called"Execution context" in order to specify flexible syntax and dynamic semantics of the Ruby language as simple as possible.
1 Scope
This International Standard specifies the syntax and semantics of the computer programming language Ruby, and the requirements for conforming Ruby processors, strictly conforming Ruby programs, and conforming Ruby programs.
This International Standard does not specify,
- • the limit of size or complexity of a program text which a conforming processor evaluates,
- • the minimal requirements of a data processing system that is capable of supporting a conforming processor,
- • the method for activating the execution of programs on a data processing system, and
- • the method for reporting syntactic and runtime errors.
NOTE Execution of a Ruby program is to evaluate the program (see 10) by a Ruby processor.
2 Normative references
The following referenced documents are indispensable for the application of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.
- ISO/IEC 646:1991, Information technology — ISO 7-bit coded character set for information interchange.
- IEC 60559:1989, Binary floating-point arithmetic for microprocessor systems.
- ISO/IEC 2382-1:1993, Information technology — Vocabulary — 1: Fundamental terms.
4 Terms and definitions
For the purposes of this document, the following terms and definitions apply. Other terms are defined where they appear in bold slant face or on the left side of a syntax rule.
4.1
block
procedure which is passed to a method invocation
4.2
class
object which defines the behavior of a set of other objects, called its instances
Note 1 to entry: The behavior is a set of methods which can be invoked on an instance.
4.3
class variable
variable whose value is shared by all the instances of a class
4.4
constant
variable which is defined in a class or a module, and is accessible both inside and outside the class or module
Note 1 to entry: The value of a constant is ordinarily expected to remain unchanged during the execution of a program, but this International Standard does not enforce this expectation.
4.5
exception
object which represents an exceptional event
4.6
global variable
variable which is accessible everywhere in a program
4.7
implementation-defined
behavior that possibly differs between implementations, but is defined for every implementation
4.8
instance method
method which can be invoked on all the instances of a class
4.9
instance variable
variable that exists in a set of variable bindings which every instance of an object has
4.10
local variable
variable which is accessible only in a certain scope introduced by a program construct such as a method definition, a block, a class definition, a module definition, a singleton class definition,or the top level of a program
4.11
method
procedure which, when invoked on an object, performs a set of computations on the object
4.12
method visibility
attribute of a method which determines the conditions under which a method invocation isallowed
4.13
module
object which provides features to be included into a class or another module
4.14
object
computational entity which has a state and a behavior
Note 1 to entry: The behavior of an object is a set of methods which can be invoked on the object.
4.15
singleton class
object which can modify the behavior of its associated object
Note 1 to entry: A singleton class is ordinarily associated with a single object. However, a conforming processor may associate a singleton class with multiple objects as described in 13.4.1.
4.16
singleton method
instance method of a singleton class
4.17
unspecified
behavior that possibly differs between implementations, and is not necessarily defined for every implementation
4.18
variable
computational entity that refers to an object, which is called the value of the variable
4.19
variable binding
association between a variable and an object which is referred to by the variable