OSDN Git Service

残りの流し込み。10章未翻訳部分途中まで翻訳.
[omake-japanese/omake_trans.git] / language-naming.rst
index d4bc289..01a324a 100644 (file)
@@ -1,12 +1,14 @@
 .. 5-language-naming
 
-.. index:
+.. index::
    single: 修飾子
    single: 名前空間
 .. _label5:
 
 5. 変数と名前空間
 ==================================
+.. During evaluation, there are three different kinds of namespaces. Variables can be private, or they may refer to fields in the current this object, or they can be part of the global namespace. The namespace can be specified directly by including an explicit qualifier before the variable name. The three namespaces are separate; a variable can be bound in one or more simultaneously.
+
 コードを評価する際、OMakeの変数には3つの異なる種類の名前空間があります。変数は *プライベート* なものにしたり、 *現在の* オブジェクトのプロパティを参照したり、 *グローバル* な名前空間の一部として用いることができます。名前空間を指定するには、変数名の前に修飾子を直接明示する必要があります。この3つの名前空間は分割されており、変数は一つ、あるいはさらに多くの名前空間に束縛することができます。 ::
 
     # プライベートな名前空間
@@ -23,6 +25,8 @@
 
 5.1 private.
 ----------------------------------
+.. The private. qualifier is used to define variables that are private to the current file/scope. The values are not accessible outside the scope. Private variables are statically (lexically) scoped.
+
 ``private.`` 修飾子は変数が現在のファイルやスコープ上のプライベートなものであると定義したい場合に用います。値は外のスコープから参照することができません。プライベートな変数は静的にスコープされています。 ::
 
     Obj. =
@@ -38,6 +42,8 @@
     # XはObj内のプライベート変数なので、エラーとなります
     y = $(Obj.X)
 
+.. In addition, private definitions do not affect the global value of a variable.
+
 加えて、プライベート変数はグローバルな変数の値に影響を及ぼしません。 ::
 
    # パブリックなxの値は1
    #    The public value of x is: 1
    Obj.print()
 
+.. Private variables have two additional properties.
+
+     1. Private variables are local to the file in which they are defined.
+     2. Private variables are not exported by the export directive, unless they are mentioned explicitly.
+
 プライベート変数は2つの性質を持っています。
 
 #. プライベート変数は定義されたファイルしか参照できません。
@@ -83,6 +94,8 @@
 
 5.2 this.
 ----------------------------------
+.. The this. qualifier is used to define fields that are local to an object. Object variables are dynamically scoped.
+
 ``this.`` 修飾子はオブジェクトのローカルなプロパティについて定義したい場合に用います。オブジェクト変数は動的にスコープされます。 ::
 
     X = 1
     # この文は正しく、Yには3が束縛されます。
     Y = $(Obj.X)
 
-一般的に、保護されたオブジェクト変数を定義するのは良いとされています。プロジェクトの他の部分で定義された変数と被ってしまったために起こる、意図しないバグを生み出さないためです。その結果、コードはよりモジュール化されます。
+.. In general, it is a good idea to define object variables as protected. The resulting code is more modular because variables in your object will not produce unexpected clashes with variables defined in other parts of the project.
+
+一般的に、保護されたオブジェクト変数を定義することは良いとされています。プロジェクトの他の部分で定義された変数と被ってしまったために起こる、意図しないバグを生み出さないためです。その結果、コードはよりモジュール化されます。
 
 .. index::
    single: global.
 
 5.3 global.
 ----------------------------------
+.. The global. qualifier is used to specify global dynamically-scoped variables. In the following example, the global. definition specifies that the binding X = 4 is to be dynamically scoped. Global variables are not defined as fields of an object.
+
 ``global.`` 修飾子はグローバルに動的なスコープを持つ変数を定義したい場合に用います。以下の例では、 ``global.`` 宣言は束縛文 ``X = 4`` が動的にスコープされた変数であることを指定しています。グローバル変数はオブジェクトのプロパティとして定義することが *できません* 。 ::
 
     X = 1
 
 5.4 protected.
 ----------------------------------
+.. In OMake 0.9.8, protected is a synonym for this.
+
 OMake 0.9.8では、 ``protected`` は ``this`` 修飾子と同義語でした。 ::
 
     osh>protected.x = 1
@@ -157,6 +176,8 @@ OMake 0.9.8では、 ``protected`` は ``this`` 修飾子と同義語でした
     osh>value $(this.x)
     - : "1" : Sequence
 
+.. In 0.9.9, this will change, so that the qualifier protected means (in 0.9.9) that a variable is local to the current object or file, and may not be accessed outside it.
+
 0.9.9ではこの仕様は変更され、 ``protected`` 修飾子は変数が現在のオブジェクトまたはファイルについてのローカル変数とし、外部からアクセスできないようにしたい場合に用います。
 
 .. index::
@@ -165,6 +186,8 @@ OMake 0.9.8では、 ``protected`` は ``this`` 修飾子と同義語でした
 
 5.5 public.
 ----------------------------------
+.. In OMake 0.9.8, public is a synonym for global.
+
 OMake 0.9.8では、 ``public`` は ``global`` 修飾子と同義語でした。 ::
 
     osh>public.x = 1
@@ -172,19 +195,25 @@ OMake 0.9.8では、 ``public`` は ``global`` 修飾子と同義語でした。
     osh>value $(global.x)
     - : "1" : Sequence
 
-0.9.9ではこの使用は変更され、 ``public`` 修飾子は変数が現在のファイルまたはオブジェクトの外部からアクセスできるようにしたい場合に用います。
+.. In 0.9.9, this will change, so that the qualifier public means (in 0.9.9) that a variable is to be accessible from outside the current file or object.
+
+0.9.9ではこの仕様は変更され、 ``public`` 修飾子は変数が現在のファイルまたはオブジェクトの外部からアクセスできるようにしたい場合に用います。
 
 .. _label5.6:
 
 5.6 修飾されたブロック
 ----------------------------------
-もしいくつかの修飾された変数が同時に定義された場合、修飾子のブロックが優先的に定義されます。文法はオブジェクトの定義と似ていますが、それはオブジェクト名それ自体が修飾子だからです。例えば、以下のプログラムはプライベート変数 ``X`` と ``Y`` を定義しています。 ::
+.. If several qualified variables are defined simultaneously, a block form of qualifier can be defined. The syntax is similar to an object definition, where the name of the object is the qualifier itself. For example, the following program defines two private variables X and Y.
+
+いくつかの修飾された変数が同時に定義された場合、修飾子のブロックが優先的に定義されます。文法はオブジェクトの定義と似ていますが、それはオブジェクト名それ自体が修飾子だからです。例えば、以下のプログラムはプライベート変数 ``X`` と ``Y`` を定義しています。 ::
 
     private. =
         X = 1
         Y = 2
 
-修飾子はブロック内で新しく定義された変数の、デフォルトの名前空間を指定しています。その違いを除いて、ブロックの内容は完全に普通のコードとしてふるまいます。 ::
+.. The qualifier specifies a default namespace for new definitions in the block. The contents of the block is otherwise completely general.
+
+修飾子はブロック内で新しく定義された変数の、デフォルトの名前空間を指定しています。その違いを除いて、ブロックの内容は完全に通常のコードとしてふるまいます。 ::
 
     private. =
         X = 1
@@ -200,6 +229,8 @@ OMake 0.9.8では、 ``public`` は ``global`` 修飾子と同義語でした。
 
 5.7 変数宣言
 ----------------------------------
+.. When a variable name is unqualified, its namespace is determined by the most recent definition or declaration that is in scope for that variable. We have already seen this in the examples, where a variable definition is qualified, but the subsequent uses are not qualified explicitly. In the following example, the first occurrence of $X refers to the private definition, because that is the most recent. The public definition of X is still 0, but the variable must be qualified explicitly.
+
 変数名が修飾されていない場合、その名前空間は最も近くで定義された名前空間か、この変数が定義されているスコープの名前空間が用いられます。私たちは以前すでにこの現象を例を通して見ています。その例では、変数の定義が修飾されていても、その後に来る変数は明示的に修飾されていなかったはずです。以下の例では、最初に宣言された ``$X`` は *プライベート* な変数 ``$(private.X)`` が関連付けられています。なぜならこれは最も近くで定義されているからです。パブリックな変数 ``X`` は未だに ``0`` であり、この変数を指定するためには明示的に修飾しなければなりません。 ::
 
     public.X = 0
@@ -209,6 +240,8 @@ OMake 0.9.8では、 ``public`` は ``global`` 修飾子と同義語でした。
         println(The value of private.X is: $X)
         println(The value of public.X is: $(public.X))
 
+.. Sometimes it can be useful to declare a variable without defining it. For example, we might have a function that uses a variable X that is to be defined later in the program. The declare directive can be used for this.
+
 時々、修飾子を定義する事なしに変数宣言することが有効である場合があります。例えば、私たちはプログラムの後ろで定義された変数 ``X`` を用いる関数を持っていたとしましょう。 ``declare`` 文はこのような場合に使うことができます。 ::
 
     declare public.X
@@ -220,6 +253,12 @@ OMake 0.9.8では、 ``public`` は ``global`` 修飾子と同義語でした。
     X = 2
     print()
 
+.. Finally, what about variables that are used but not explicitly qualified? In this case, the following rules are used.
+
+      * If the variable is a function parameter, it is private.
+      * If the variable is defined in an object, it is qualified with this..
+      * Otherwise, the variable is public. 
+
 最後に、明示的に修飾されていない変数についてはどうなるのでしょうか?このような場合、以下のルールが使われます。
 
 * もし変数が関数の引数ならば、その変数はプライベートとなります。