argra****@users*****
argra****@users*****
2008年 12月 8日 (月) 18:05:17 JST
Index: docs/perl/5.8.8/perlobj.pod diff -u docs/perl/5.8.8/perlobj.pod:1.3 docs/perl/5.8.8/perlobj.pod:1.4 --- docs/perl/5.8.8/perlobj.pod:1.3 Sat Dec 6 03:44:53 2008 +++ docs/perl/5.8.8/perlobj.pod Mon Dec 8 18:05:17 2008 @@ -269,11 +269,10 @@ コンストラクタは現在参照されているオブジェクトを別のクラスに 属させるために、再 bless するかもしれません。 -this is almost certainly going -to get you into trouble. +これはほとんど確実にトラブルに巻き込まれます。 しかし、その新しいクラスは、後で掃除する原因となります。 オブジェクトは一度に一つのクラスにしか属することができないかのように -以前のblessは忘れ去られます(多くのクラスからメソッドを継承することが +以前の bless は忘れ去られます(多くのクラスからメソッドを継承することが 自由にできるとしても、です)。 もし再ブレスしなければならないというのなら、その親クラスは不正な 振る舞いをしています。 @@ -307,7 +306,7 @@ =end original これは "$b as being a BLAH" と表示されます; -これで明らかなように、 bless() はリファレンスに対してではなく +これで明らかなように、bless() はリファレンスに対してではなく オブジェクトに作用します。 =head2 A Class is Simply a Package @@ -412,7 +411,7 @@ =end original -AUTOLOAD の継承を止めたい場合は、単にとすると: +AUTOLOAD の継承を止めたい場合は、単に以下のようにすると: X<AUTOLOAD> sub AUTOLOAD; @@ -439,7 +438,7 @@ =end original -Perlのクラスはメソッドの継承のみを行います。 +Perl のクラスはメソッドの継承のみを行います。 データの継承はクラス自身にまかされています。 このことは Perl の問題ではありません。 なぜなら、大部分のクラスは無名ハッシュを使って、クラスのオブジェクトの @@ -623,11 +622,11 @@ =end original -Here C<MyCritter> is presumably a subclass of C<Critter> that defines -its own versions of find() and display(). We haven't specified what -those methods do, but that doesn't matter above since we've forced Perl -to start looking for the subroutines in C<Critter>. -(TBT) +ここで C<MyCritter> は、おそらく自分自身の find() と display() を +定義しているC<Critter> のサブクラスです。 +これらのメソッドが何をしているかは指定していませんが、 +これらのサブルーチンを C<Critter> から探すように Perl に強制しているので、 +それは問題になりません。 =begin original @@ -638,11 +637,9 @@ =end original -As a special case of the above, you may use the C<SUPER> pseudo-class to -tell Perl to start looking for the method in the packages named in the -current class's C<@ISA> list. +上記の特別な場合として、現在のクラスの C<@ISA> リストにあるパッケージから +メソッドを探し始めるように Perl に指示する、C<SUPER> 擬似クラスもあります。 X<SUPER> -(TBT) package MyCritter; use base 'Critter'; # sets @MyCritter::ISA = ('Critter'); @@ -663,13 +660,12 @@ =end original -It is important to note that C<SUPER> refers to the superclass(es) of the -I<current package> and not to the superclass(es) of the object. Also, the -C<SUPER> pseudo-class can only currently be used as a modifier to a method -name, but not in any of the other ways that class names are normally used, -eg: +C<SUPER> は、オブジェクトのスーパークラスではなく、I<カレントパッケージ> の +スーパークラスを参照するということに注意することは重要です。 +また C<SUPER> 擬似クラスは現在のところメソッド名への修飾子としてのみ +使え、普通に使われるクラス名のその他の方法は使えません。 +つまり: X<SUPER> -(TBT) something->SUPER::method(...); # OK SUPER::method(...); # WRONG @@ -683,10 +679,9 @@ =end original -Instead of a class name or an object reference, you can also use any -expression that returns either of those on the left side of the arrow. -So the following statement is valid: -(TBT) +クラス名やオブジェクトリファレンスの代わりに、矢印の左側に +置けるもののどちらかを返す任意の式も使えます。 +従って、以下の文は有効です: Critter->find("Fred")->display("Height", "Weight"); @@ -708,10 +703,8 @@ =end original -The right side of the arrow typically is the method name, but a simple -scalar variable containing either the method name or a subroutine -reference can also be used. -(TBT) +矢印の右側は典型的にはメソッド名ですが、メソッド名やサブルーチン +リファレンスが入った単純スカラ変数も使えます。 =head2 Indirect Object Syntax X<indirect object syntax> X<invocation, indirect> X<indirect> @@ -726,10 +719,10 @@ =end original -The other way to invoke a method is by using the so-called "indirect -object" notation. This syntax was available in Perl 4 long before -objects were introduced, and is still used with filehandles like this: -(TBT) +メソッドを起動する他の方法は、「間接オブジェクト」記法と呼ばれる方法を +使うものです。 +この文法は、オブジェクトが導入されるよりずっと以前の Perl 4 から +利用可能で、以下のように、ファイルハンドルで今でも使われています: print STDERR "help!!!\n"; @@ -753,10 +746,10 @@ =end original -Notice that there is no comma between the object or class name and the -parameters. This is how Perl can tell you want an indirect method call -instead of an ordinary subroutine call. -(TBT) +オブジェクトやクラス名とパラメータの間にカンマがないことに +注目してください。 +これによって、通常のサブルーチン呼び出しではなく間接メソッド呼び出しを +しようとしていることを Perl に伝えています。 =begin original @@ -848,9 +841,8 @@ =end original -To get the correct behavior with indirect object syntax, you would have -to use a block around the indirect object: -(TBT) +間接オブジェクト構文の正しい振る舞いを得るためには、間接オブジェクトの周りに +ブロックを使う必要があるかもしれません: move {$obj->{FIELD}}; move {$ary[$i]}; @@ -866,13 +858,12 @@ =end original -Even then, you still have the same potential problem if there happens to -be a function named C<move> in the current package. B<The C<< -> >> -notation suffers from neither of these disturbing ambiguities, so we -recommend you use it exclusively.> However, you may still end up having -to read code using the indirect object notation, so it's important to be -familiar with it. -(TBT) +この場合でも、もし現在のパッケージにたまたま C<move> という名前の関数が +あると、同じ潜在的問題があります。 +B<C<< -> >> 記法はこれらの物騒なあいまいさのどちらの影響も受けないので、 +これだけを使うことを勧めます。> +しかし、結局は間接オブジェクト記法を使ったコードを読む必要が +あるかもしれないので、この記法に親しんでおくことが重要です。 =head2 Default UNIVERSAL methods X<UNIVERSAL> @@ -911,10 +902,9 @@ =end original -You can also call C<UNIVERSAL::isa> as a subroutine with two arguments. Of -course, this will do the wrong thing if someone has overridden C<isa> in a -class, so don't do it. -(TBT) +C<UNIVERSAL::isa> を、2 引数を持つサブルーチンとして呼び出すこともできます。 +もちろん、もし誰かがクラスの中で C<isa> をオーバーライドしていると +良くないことになるので、これをしてはいけません。 =begin original @@ -924,10 +914,9 @@ =end original -If you need to determine whether you've received a valid invocant, use the -C<blessed> function from L<Scalar::Util>: +もし、有効な呼び出し元を受け取っているかどうかを決定する必要があるなら、 +L<Scalar::Util> の C<blessed> を使ってください: X<invocant> X<blessed> -(TBT) if (blessed($ref) && $ref->isa( 'Some::Class')) { # ... @@ -966,10 +955,9 @@ =end original -C<UNIVERSAL::can> can also be called as a subroutine with two arguments. It'll -always return I<undef> if its first argument isn't an object or a class name. -The same caveats for calling C<UNIVERSAL::isa> directly apply here, too. -(TBT) +C<UNIVERSAL::can> を、2 引数を持つサブルーチンとして呼び出すこともできます。 +もし 1 つめの引数がオブジェクトかクラス名でなかった場合、常に I<undef> を +C<UNIVERSAL::isa> を直接呼び出す場合と同じ問題点もあります。 =item VERSION( [NEED] ) X<VERSION> @@ -1069,11 +1057,10 @@ =end original -Since DESTROY methods can be called at unpredictable times, it is -important that you localise any global variables that the method may -update. In particular, localise C<$@> if you use C<eval {}> and -localise C<$?> if you use C<system> or backticks. -(TBT) +DESTROY メソッドは予測不能な回数呼び出されるかもしれないので、 +メソッドが更新する全てのグローバル変数をローカル化することが重要です。 +特に、C<eval {}> を使うなら C<$@> を、C<system> や逆クォートを使うなら +C<$?> をローカル化してください。 =begin original @@ -1317,7 +1304,7 @@ =end original -より完璧なガーベッジコレクションの戦略は将来実装されるでしょう。 +より完璧なガベージコレクションの戦略は将来実装されるでしょう。 =begin original @@ -1329,7 +1316,7 @@ =end original 方法として最善なものは、自己再帰的なデータ構造に対するポインタを -保持するような非再帰的なコンテナークラスを作成することです。 +保持するような非再帰的なコンテナクラスを作成することです。 そういったオブジェクトのクラスでの DESTORY メソッドの定義は 自己参照構造中の循環を手作業で断ち切るようなものになります。 @@ -1354,7 +1341,7 @@ =begin meta Created: KIMURA Koichi -Updated: Kentaro Shirakata <argra****@ub32*****> +Updated: Kentaro Shirakata <argra****@ub32*****> (5.8.8-) =end meta