strict-1.03 > 1.04 との差分

strict 1.04 と 1.03 の差分

1
2=encoding euc-jp
2=encoding euc-jp
3
4=head1 NAME
4=head1 NAME
5
6=begin original
6strict - 安全ではないコンストラクトを制限する Perl プラグマ
7
8strict - Perl pragma to restrict unsafe constructs
8=head1 SYNOPSIS
9
10=end original
10 use strict;
11
12strict - 安全ではない構文を制限する Perl プラグマ
12 use strict "vars";
13 use strict "refs";
14=head1 SYNOPSIS
14 use strict "subs";
15
16 use strict;
16 use strict;
17 no strict "vars";
18 use strict "vars";
18
19 use strict "refs";
19=head1 DESCRIPTION
20 use strict "subs";
20
21インポートリストを与えない場合は、可能な限り全ての制約を受けます。
22 use strict;
22(これは、最も安全な動作モードです。ただ、カジュアルプログラミング
23 no strict "vars";
23のためには厳しすぎます。)今のところ、"subs"、"vars"、"refs" の
243つの制約が用意されています。
25=head1 DESCRIPTION
25
26=over 6
27=begin original
27
28=item C<strict refs>
29If no import list is supplied, all possible restrictions are assumed.
29
30(This is the safest mode to operate in, but is sometimes too strict for
30シンボリックリファレンスが使われたときにランタイムエラーになります。
31casual programming.) Currently, there are three possible things to be
31(L<perlref> を見てください。)
32strict about: "subs", "vars", and "refs".
32
33 use strict 'refs';
34=end original
34 $ref = \$foo;
35 print $$ref; # ok
36インポートリストを与えない場合は、利用可能な全ての制約を受けます。
36 $ref = "foo";
37(これは最も安全な動作モードですが、カジュアルプロググの
37 print $$ref; # ランタイムエラー; 普段は ok
38ためには厳しすぎる場合もあります。)
38 $file = "STDOUT";
39今のところ、"subs"、"vars""refs" 3 つの制約用意されてます
39 print $file "Hi!"; # エラー; note: $file後にコンマい。
40
41=over 6
41このルールには 1つの例外があります。
42
43=item C<strict refs>
43 $bar = \&{'foo'};
44 &$bar;
45=begin original
45
46上記のものは許容されます。だから C<goto &$AUTOLOAD> はこの制約下でも
47This generates a runtime error if you
47動きます。
48use symbolic references (see L<perlref>).
48
49=item C<strict vars>
50=end original
50
51C<our> や C<use vars>、C<my()> で宣言された変数や完全に修飾された
52シンボリッリファレンが使われたときに実行時エラーになります。
52変数以外にアたときにコンパイル時エラーを出します。
53(L<perlref> を見ください。)
53変数が自殺ししまう問題や微表な動的スコープの問題があるため、
54local() 変数だけでは十分ではありません。L<perlfunc/my> や
55=begin original
55L<perlfunc/local> を見てください。
56
57 use strict 'refs';
57 use strict 'vars';
58 $ref = \$foo;
58 $X::foo = 1; # ok, 完全に修飾されています
59 print $$ref; # ok
59 my $foo = 10; # ok, my() 変数
60 $ref = "foo";
60 local $foo = 9; # ダメ
61 print $$ref; # runtime error; normally ok
61
62 $file = "STDOUT";
62 package Cinna;
63 print $file "Hi!"; # error; note: no comma after $file
63 our $bar; # パッケージ内で宣言された $bar
64 $bar = 'HgS'; # ok, プラグマでグローバルに宣言された
65=end original
65
66local() は、完全な修飾無しにグローバルな名前を触ってしまうため
67 use strict 'refs';
67コンパイル時エラーを出します。
68 $ref = \$foo;
68
69 print $$ref; # ok
69sort() によって使われるという理由で $a $b はこのチェックの
70 $ref = "foo";
70適用外という特別扱いになっています。
71 print $$ref; # ランタイムエラー; 普段は ok
71
72 $file = "STDOUT";
72=item C<strict subs>
73 print $file "Hi!"; # エラー; 注意: $file の後にコンマがない
73
74詩的な最適化を禁止し、サブルーチン以外の裸の識別子を使おうとしたときか、
75=begin original
75(コロンのない)単純な識別子や中括弧の中 C<< => >> シンボルの左側に
76無いときにコンパイル時エラーを出します。
77There is one exception to this rule:
77
78 use strict 'subs';
79=end original
79 $SIG{PIPE} = Plumber; # ダメ
80 $SIG{PIPE} = "Plumber"; # 問題なし: 中括弧の中ならいつでも裸で ok
81このルールには 1 つの例外がありす:
81 $SIG{PIPE} = \&Plumber; # 好しい方法
82
83 $bar = \&{'foo'};
83=back
84 &$bar;
84
85L<perlmodlib/Pragmatic Modules> を見てください。
86=begin original
86
87=head1 HISTORY
88is allowed so that C<goto &$AUTOLOAD> would not break under stricture.
88
89Perl 5.6.1 での C<strict 'subs'> は、(C<< => >> の前や中括弧の中での)
90=end original
90ハッシュのキーのとしてクオートすることなしに(C<Foo::Bar> のような)
91複合の識別子を使えるようにしてしまっています。このことは間違いでした。
92上記のものは許容さ;
92は、いつでもリテラル文字列で
93だから C<goto &$AUTOLOAD> はこの制約下でも動きます。
93
94Perl 5.8.1 からの strict は、それらの制約事項について厳格です:
95=item C<strict vars>
95もし、知られていない制約事項が使われるならば、strict プラグマは、
96次にある記述と共に中断するでしょう。
97=begin original
97
98 Unknown 'strict' tag(s) '...'
99This generates a compile-time error if you access a variable that wasn't
99
100declared via C<our> or C<use vars>,
100=cut
101localized via C<my()>, or wasn't fully qualified. Because this is to avoid
101
102variable suicide problems and subtle dynamic scoping issues, a merely
103local() variable isn't good enough. See L<perlfunc/my> and
104L<perlfunc/local>.
105
106=end original
107
108C<our> や C<use vars>、C<my()> で宣言された変数や完全に修飾された
109変数以外にアクセスしたときにコンパイル時エラーを出します。
110変数が自殺してしまう問題や微妙な動的スコープの問題があるため、
111local() 変数だけでは十分ではありません。
112L<perlfunc/my> や L<perlfunc/local> を見てください。
113
114=begin original
115
116 use strict 'vars';
117 $X::foo = 1; # ok, fully qualified
118 my $foo = 10; # ok, my() var
119 local $foo = 9; # blows up
120
121=end original
122
123 use strict 'vars';
124 $X::foo = 1; # ok, 完全に修飾されています
125 my $foo = 10; # ok, my() 変数
126 local $foo = 9; # ダメ
127
128=begin original
129
130 package Cinna;
131 our $bar; # Declares $bar in current package
132 $bar = 'HgS'; # ok, global declared via pragma
133
134=end original
135
136 package Cinna;
137 our $bar; # パッケージ内で宣言された $bar
138 $bar = 'HgS'; # ok, プラグマでグローバルに宣言された
139
140=begin original
141
142The local() generated a compile-time error because you just touched a global
143name without fully qualifying it.
144
145=end original
146
147local() は、完全な修飾無しにグローバルな名前を触ってしまうため
148コンパイル時エラーを出します。
149
150=begin original
151
152Because of their special use by sort(), the variables $a and $b are
153exempted from this check.
154
155=end original
156
157sort() によって特別扱いされるという理由で $a と $b はこのチェックの
158適用外になっています。
159
160=item C<strict subs>
161
162=begin original
163
164This disables the poetry optimization, generating a compile-time error if
165you try to use a bareword identifier that's not a subroutine, unless it
166is a simple identifier (no colons) and that it appears in curly braces or
167on the left hand side of the C<< => >> symbol.
168
169=end original
170
171詩的な最適化を禁止し、サブルーチン以外の裸の識別子を使おうとしたとき、
172それが(コロンのない)単純な識別子や中括弧の中 C<< => >> シンボルの
173左側でない場合にコンパイル時エラーを出します。
174
175=begin original
176
177 use strict 'subs';
178 $SIG{PIPE} = Plumber; # blows up
179 $SIG{PIPE} = "Plumber"; # just fine: quoted string is always ok
180 $SIG{PIPE} = \&Plumber; # preferred form
181
182=end original
183
184 use strict 'subs';
185 $SIG{PIPE} = Plumber; # ダメ
186 $SIG{PIPE} = "Plumber"; # 問題なし: クォートされた文字は常に ok
187 $SIG{PIPE} = \&Plumber; # 好ましい方法
188
189=back
190
191=begin original
192
193See L<perlmodlib/Pragmatic Modules>.
194
195=end original
196
197L<perlmodlib/Pragmatic Modules> を見てください。
198
199=head1 HISTORY
200
201=begin original
202
203C<strict 'subs'>, with Perl 5.6.1, erroneously permitted to use an unquoted
204compound identifier (e.g. C<Foo::Bar>) as a hash key (before C<< => >> or
205inside curlies), but without forcing it always to a literal string.
206
207=end original
208
209Perl 5.6.1 での C<strict 'subs'> は、(C<< => >> の前や中括弧の中での)
210ハッシュのキーのとして、クォートすることなしに(C<Foo::Bar> のような)
211複合の識別子を使えるようにしてしまっています; このことは間違いでした;
212それは、いつでもリテラル文字列です。
213
214=begin original
215
216Starting with Perl 5.8.1 strict is strict about its restrictions:
217if unknown restrictions are used, the strict pragma will abort with
218
219=end original
220
221Perl 5.8.1 からの strict は、それらの制約事項について厳格です:
222もし、知られていない制約事項が使われるならば、strict プラグマは、
223以下のような出力と共に中断します。
224
225 Unknown 'strict' tag(s) '...'
226
227=begin original
228
229As of version 1.04 (Perl 5.10), strict verifies that it is used as
230"strict" to avoid the dreaded Strict trap on case insensitive file
231systems.
232
233=end original
234
235バージョン 1.04 (Perl 5.10) から、大文字小文字の区別のない
236ファイルシステムでの恐ろしい "Strict" の罠を避けるために、strict は
237"strict" として使われているかを検証します。
238
239=begin meta
240
241Update: Kentaro Shirakata <argrath@ub32.org> (1.04)
242
243=end meta
244
245=cut