argra****@users*****
argra****@users*****
2018年 1月 16日 (火) 03:06:03 JST
Index: docs/perl/5.22.1/perlref.pod diff -u docs/perl/5.22.1/perlref.pod:1.1 docs/perl/5.22.1/perlref.pod:1.2 --- docs/perl/5.22.1/perlref.pod:1.1 Tue Mar 28 23:40:49 2017 +++ docs/perl/5.22.1/perlref.pod Tue Jan 16 03:06:03 2018 @@ -1812,6 +1812,8 @@ =head1 Assigning to References +(リファレンスへの代入) + =begin original Beginning in v5.22.0, the referencing operator can be assigned to. It @@ -1821,15 +1823,20 @@ =end original -Beginning in v5.22.0, the referencing operator can be assigned to. It -performs an aliasing operation, so that the variable name referenced on the -left-hand side becomes an alias for the thing referenced on the right-hand -side: -(TBT) +v5.22.0 から、リファレンス演算子は代入できるようになります。 +これは別名化操作を行い、左側で参照される変数名は右側で参照されるものへの +別名になります: + +=begin original \$a = \$b; # $a and $b now point to the same scalar \&foo = \&bar; # foo() now means bar() +=end original + + \$a = \$b; # $a と $b は同じスカラを示す + \&foo = \&bar; # foo() は bar() を意味する + =begin original This syntax must be enabled with C<use feature 'refaliasing'>. It is @@ -1838,10 +1845,9 @@ =end original -This syntax must be enabled with C<use feature 'refaliasing'>. It is -experimental, and will warn by default unless C<no warnings -'experimental::refaliasing'> is in effect. -(TBT) +この文法は C<use feature 'refaliasing'> で有効にされなければなりません。 +これは実験的であり、C<no warnings 'experimental::refaliasing'> が +有効でない限り、デフォルトでは警告されます。 =begin original @@ -1850,9 +1856,7 @@ =end original -These forms may be assigned to, and cause the right-hand side to be -evaluated in scalar context: -(TBT) +以下の型式は代入され、右側はスカラコンテキストで評価されます: \$scalar \@array @@ -1879,10 +1883,7 @@ =end original -Slicing operations and parentheses cause -the right-hand side to be evaluated in -list context: -(TBT) +スライス演算子とかっこは右側をリストコンテキストで評価します: \@array[5..7] (\@array[5..7]) @@ -1910,11 +1911,9 @@ =end original -Each element on the right-hand side must be a reference to a datum of the -right type. Parentheses immediately surrounding an array (and possibly -also C<my>/C<state>/C<our>/C<local>) will make each element of the array an -alias to the corresponding scalar referenced on the right-hand side: -(TBT) +右側の各要素は右側の型へのリファレンスでなければなりません。 +配列 (および場合によっては C<my>/C<state>/C<our>/C<local>) を直接囲むかっこは、 +配列の各要素を、右側のリファレンスになる対応するスカラへの別名にします: \(@a) = \(@b); # @a and @b now have the same elements \my(@a) = \(@b); # likewise @@ -1929,9 +1928,8 @@ =end original -Combining that form with C<local> and putting parentheses immediately -around a hash are forbidden (because it is not clear what they should do): -(TBT) +この型式と C<local> を組み合わせるのと、ハッシュのすぐ周りにかっこを置くのは +禁止されています (これが何をしたいかがはっきりしないからです): \local(@array) = foo(); # WRONG \(%hash) = bar(); # wRONG @@ -1945,11 +1943,10 @@ =end original -Assignment to references and non-references may be combined in lists and -conditional ternary expressions, as long as the values on the right-hand -side are the right type for each element on the left, though this may make -for obfuscated code: -(TBT) +リファレンスと非リファレンスの代入は、 +右側の値が左側の各要素に対して正しい型である限りにおいて、 +リストの中と 3 項条件式で組み合わせられますが、 +これは不明瞭なコードになります: (my $tom, \my $dick, \my @harry) = (\1, \2, [1..3]); # $tom is now \1 @@ -1967,10 +1964,9 @@ =end original -The C<foreach> loop can also take a reference constructor for its loop -variable, though the syntax is limited to one of the following, with an -optional C<my>, C<state>, or C<our> after the backslash: -(TBT) +C<foreach> ループは、そのループ変数にリファレンス生成子を取ることも +できますが、その文法は以下のうち一つに、オプションとして逆スラッシュの後に +C<my>, C<state>, C<our> を置く形に制限されます: \$s \@a @@ -1984,9 +1980,8 @@ =end original -No parentheses are permitted. This feature is particularly useful for -arrays-of-arrays, or arrays-of-hashes: -(TBT) +かっこは許されません。 +この機能は、配列の配列やハッシュの配列に特に有用です: foreach \my @a (@array_of_arrays) { frobnicate($a[0], $a[-1]); @@ -2006,12 +2001,11 @@ =end original -B<CAVEAT:> Aliasing does not work correctly with closures. If you try to -alias lexical variables from an inner subroutine or C<eval>, the aliasing -will only be visible within that inner sub, and will not affect the outer -subroutine where the variables are declared. This bizarre behavior is -subject to change. -(TBT) +B<警告:> 別名化はクロージャでは正しく動作しません。 +内側のサブルーチンは C<eval> からレキシカル変数への別名化をしようとすると、 +別名化はその内側のサブルーチンの中でのみ見ることができ、 +変数が宣言された外側のサブルーチンには影響を与えません。 +このおかしな振る舞いは変更予定です。 =head1 SEE ALSO @@ -2043,7 +2037,7 @@ Translate: KIMURA Koichi (5.005) Update: SHIRAKATA Kentaro <argra****@ub32*****> (5.8.8-) -Status: in progress +Status: completed =end meta