feature-1.42 >
1.54
との差分
feature 1.54 と 1.42 の差分
1 | 1 | |
2 | =encoding u | |
2 | =encoding euc-jp | |
3 | 3 | |
4 | 4 | =head1 NAME |
5 | 5 | |
6 | 6 | =begin original |
7 | 7 | |
8 | 8 | feature - Perl pragma to enable new features |
9 | 9 | |
10 | 10 | =end original |
11 | 11 | |
12 | 12 | feature - 新しい機能を有効にするプラグマ |
13 | 13 | |
14 | 14 | =head1 SYNOPSIS |
15 | 15 | |
16 | 16 | use feature qw(say switch); |
17 | 17 | given ($foo) { |
18 | 18 | when (1) { say "\$foo == 1" } |
19 | 19 | when ([2,3]) { say "\$foo == 2 || \$foo == 3" } |
20 | 20 | when (/^a[bc]d$/) { say "\$foo eq 'abd' || \$foo eq 'acd'" } |
21 | 21 | when ($_ > 100) { say "\$foo > 100" } |
22 | 22 | default { say "None of the above" } |
23 | 23 | } |
24 | 24 | |
25 | 25 | use feature ':5.10'; # loads all features available in perl 5.10 |
26 | 26 | |
27 | 27 | use v5.10; # implicitly loads :5.10 feature bundle |
28 | 28 | |
29 | 29 | =head1 DESCRIPTION |
30 | 30 | |
31 | 31 | =begin original |
32 | 32 | |
33 | 33 | It is usually impossible to add new syntax to Perl without breaking |
34 | 34 | some existing programs. This pragma provides a way to minimize that |
35 | 35 | risk. New syntactic constructs, or new semantic meanings to older |
36 | 36 | constructs, can be enabled by C<use feature 'foo'>, and will be parsed |
37 | 37 | only when the appropriate feature pragma is in scope. (Nevertheless, the |
38 | 38 | C<CORE::> prefix provides access to all Perl keywords, regardless of this |
39 | 39 | pragma.) |
40 | 40 | |
41 | 41 | =end original |
42 | 42 | |
43 | 43 | 既に存在しているプログラムを壊すことなく、Perl に新しい文法を追加することは、 |
44 | 44 | 普通は不可能です。 |
45 | 45 | このプラグマは、リスクを最小化する方法を提供します。 |
46 | 46 | 新しい文法構造や、古い構造の新しい意味は、C<use feature 'foo'> で有効化され、 |
47 | 47 | 適切な feature プラグマがスコープ内にある場合にのみパースされます。 |
48 | 48 | (それでも、このプラグマに関わらず、C<CORE::> 接頭辞は全ての |
49 | 49 | Perl キーワードへのアクセスを提供します。) |
50 | 50 | |
51 | 51 | =head2 Lexical effect |
52 | 52 | |
53 | 53 | (レキシカルな効果) |
54 | 54 | |
55 | 55 | =begin original |
56 | 56 | |
57 | 57 | Like other pragmas (C<use strict>, for example), features have a lexical |
58 | 58 | effect. C<use feature qw(foo)> will only make the feature "foo" available |
59 | 59 | from that point to the end of the enclosing block. |
60 | 60 | |
61 | 61 | =end original |
62 | 62 | |
63 | 63 | (例えば C<use strict> のような) その他のプラグマと同様、feature は |
64 | 64 | レキシカルな効果を持ちます。 |
65 | 65 | C<use feature qw(foo)> は、この地点からブロックの終わりまでの間だけ、 |
66 | 66 | "foo" 機能を利用可能にします。 |
67 | 67 | |
68 | 68 | { |
69 | 69 | use feature 'say'; |
70 | 70 | say "say is available here"; |
71 | 71 | } |
72 | 72 | print "But not here.\n"; |
73 | 73 | |
74 | 74 | =head2 C<no feature> |
75 | 75 | |
76 | 76 | =begin original |
77 | 77 | |
78 | 78 | Features can also be turned off by using C<no feature "foo">. This too |
79 | 79 | has lexical effect. |
80 | 80 | |
81 | 81 | =end original |
82 | 82 | |
83 | 83 | 機能は C<no feature "foo"> を使うことで無効にすることも出来ます。 |
84 | 84 | これもまたレキシカルな効果を持ちます。 |
85 | 85 | |
86 | 86 | use feature 'say'; |
87 | 87 | say "say is available here"; |
88 | 88 | { |
89 | 89 | no feature 'say'; |
90 | 90 | print "But not here.\n"; |
91 | 91 | } |
92 | 92 | say "Yet it is here."; |
93 | 93 | |
94 | 94 | =begin original |
95 | 95 | |
96 | 96 | C<no feature> with no features specified will reset to the default group. To |
97 | 97 | disable I<all> features (an unusual request!) use C<no feature ':all'>. |
98 | 98 | |
99 | 99 | =end original |
100 | 100 | |
101 | 101 | C<no feature> と、機能を指定せずに使うと、デフォルトグループにリセットします。 |
102 | 102 | I<全ての> 機能を無効にする(普通でない要求!)には、C<no feature ':all'> を |
103 | 103 | 使ってください。 |
104 | 104 | |
105 | 105 | =head1 AVAILABLE FEATURES |
106 | 106 | |
107 | 107 | (利用可能な機能) |
108 | 108 | |
109 | 109 | =head2 The 'say' feature |
110 | 110 | |
111 | 111 | ('say' 機能) |
112 | 112 | |
113 | 113 | =begin original |
114 | 114 | |
115 | 115 | C<use feature 'say'> tells the compiler to enable the Perl 6 style |
116 | 116 | C<say> function. |
117 | 117 | |
118 | 118 | =end original |
119 | 119 | |
120 | 120 | C<use feature 'say'> は、コンパイラに Perl 6 形式の C<say> 関数を |
121 | 121 | 有効にするように伝えます。 |
122 | 122 | |
123 | 123 | =begin original |
124 | 124 | |
125 | 125 | See L<perlfunc/say> for details. |
126 | 126 | |
127 | 127 | =end original |
128 | 128 | |
129 | 129 | 詳しくは L<perlfunc/say> を参照してください。 |
130 | 130 | |
131 | 131 | =begin original |
132 | 132 | |
133 | 133 | This feature is available starting with Perl 5.10. |
134 | 134 | |
135 | 135 | =end original |
136 | 136 | |
137 | 137 | この機能は Perl 5.10 から利用可能です。 |
138 | 138 | |
139 | 139 | =head2 The 'state' feature |
140 | 140 | |
141 | 141 | ('state' 機能) |
142 | 142 | |
143 | 143 | =begin original |
144 | 144 | |
145 | 145 | C<use feature 'state'> tells the compiler to enable C<state> |
146 | 146 | variables. |
147 | 147 | |
148 | 148 | =end original |
149 | 149 | |
150 | 150 | C<use feature 'state'> は、コンパイラに C<state> 変数を有効にするように |
151 | 151 | 伝えます。 |
152 | 152 | |
153 | 153 | =begin original |
154 | 154 | |
155 | 155 | See L<perlsub/"Persistent Private Variables"> for details. |
156 | 156 | |
157 | 157 | =end original |
158 | 158 | |
159 | 159 | 詳しくは L<perlsub/"Persistent Private Variables"> を参照してください。 |
160 | 160 | |
161 | 161 | =begin original |
162 | 162 | |
163 | 163 | This feature is available starting with Perl 5.10. |
164 | 164 | |
165 | 165 | =end original |
166 | 166 | |
167 | 167 | この機能は Perl 5.10 から利用可能です。 |
168 | 168 | |
169 | 169 | =head2 The 'switch' feature |
170 | 170 | |
171 | 171 | ('switch' 機能) |
172 | 172 | |
173 | 173 | =begin original |
174 | 174 | |
175 | 175 | B<WARNING>: Because the L<smartmatch operator|perlop/"Smartmatch Operator"> is |
176 | 176 | experimental, Perl will warn when you use this feature, unless you have |
177 | 177 | explicitly disabled the warning: |
178 | 178 | |
179 | 179 | =end original |
180 | 180 | |
181 | 181 | B<WARNING>: L<スマートマッチング演算子|perlop/"Smartmatch Operator"> は |
182 | 182 | 実験的なので、この機能を使うと、明示的に無効にしない限り警告が発生します: |
183 | 183 | |
184 | 184 | no warnings "experimental::smartmatch"; |
185 | 185 | |
186 | 186 | =begin original |
187 | 187 | |
188 | 188 | C<use feature 'switch'> tells the compiler to enable the Perl 6 |
189 | 189 | given/when construct. |
190 | 190 | |
191 | 191 | =end original |
192 | 192 | |
193 | 193 | C<use feature 'switch'> は、コンパイラに Perl 6 given/when 構文を |
194 | 194 | 有効にするように伝えます。 |
195 | 195 | |
196 | 196 | =begin original |
197 | 197 | |
198 | 198 | See L<perlsyn/"Switch Statements"> for details. |
199 | 199 | |
200 | 200 | =end original |
201 | 201 | |
202 | 202 | 詳しくは L<perlsyn/"Switch Statements"> を参照してください。 |
203 | 203 | |
204 | 204 | =begin original |
205 | 205 | |
206 | 206 | This feature is available starting with Perl 5.10. |
207 | 207 | |
208 | 208 | =end original |
209 | 209 | |
210 | 210 | この機能は Perl 5.10 から利用可能です。 |
211 | 211 | |
212 | 212 | =head2 The 'unicode_strings' feature |
213 | 213 | |
214 | 214 | ('unicode_strings' 機能) |
215 | 215 | |
216 | 216 | =begin original |
217 | 217 | |
218 | 218 | C<use feature 'unicode_strings'> tells the compiler to use Unicode rules |
219 | 219 | in all string operations executed within its scope (unless they are also |
220 | 220 | within the scope of either C<use locale> or C<use bytes>). The same applies |
221 | 221 | to all regular expressions compiled within the scope, even if executed outside |
222 | 222 | it. It does not change the internal representation of strings, but only how |
223 | 223 | they are interpreted. |
224 | 224 | |
225 | 225 | =end original |
226 | 226 | |
227 | 227 | C<use feature 'unicode_strings'> は、(C<use locale> か C<use bytes> の |
228 | 228 | スコープないでない限り) そのスコープ内で実行される全ての文字列操作に |
229 | 229 | Unicode の規則を使うようにコンパイラに伝えます。 |
230 | 230 | これは文字列の内部表現は変更しません; それをどう解釈するかだけです。 |
231 | 231 | |
232 | 232 | =begin original |
233 | 233 | |
234 | 234 | C<no feature 'unicode_strings'> tells the compiler to use the traditional |
235 | 235 | Perl rules wherein the native character set rules is used unless it is |
236 | 236 | clear to Perl that Unicode is desired. This can lead to some surprises |
237 | 237 | when the behavior suddenly changes. (See |
238 | 238 | L<perlunicode/The "Unicode Bug"> for details.) For this reason, if you are |
239 | 239 | potentially using Unicode in your program, the |
240 | 240 | C<use feature 'unicode_strings'> subpragma is B<strongly> recommended. |
241 | 241 | |
242 | 242 | =end original |
243 | 243 | |
244 | 244 | C<no feature 'unicode_strings'> は、Unicode が求められているのが |
245 | 245 | Perl にとって明らかでない限り、ネイティブな文字集合規則が使われるところで |
246 | 246 | 伝統的な Perl の規則を使うようにコンパイラに伝えます。 |
247 | 247 | これは、振る舞いが突然変更されたときに驚きを引き起こすかもしれません。 |
248 | 248 | (詳しくは L<perlunicode/The "Unicode Bug"> を参照してください。) |
249 | 249 | この理由により、もしプログラムで Unicode を扱う可能性があるなら、 |
250 | 250 | C<use feature 'unicode_strings'> 副プラグマを B<強く> 勧めます。 |
251 | 251 | |
252 | 252 | =begin original |
253 | 253 | |
254 | 254 | This feature is available starting with Perl 5.12; was almost fully |
255 | implemented in Perl 5.14; and extended in Perl 5.16 to cover C<quotemeta> | |
255 | implemented in Perl 5.14; and extended in Perl 5.16 to cover C<quotemeta>. | |
256 | was extended further in Perl 5.26 to cover L<the range | |
257 | operator|perlop/Range Operators>; and was extended again in Perl 5.28 to | |
258 | cover L<special-cased whitespace splitting|perlfunc/split>. | |
259 | 256 | |
260 | 257 | =end original |
261 | 258 | |
262 | 259 | この機能は Perl 5.12 から利用可能になりました; Perl 5.14 でほぼ完全に |
263 | 実装されました; Perl 5.16 で C<quotemeta> に対応するように拡張されました | |
260 | 実装されました; Perl 5.16 で C<quotemeta> に対応するように拡張されました。 | |
264 | Perl 5.26 では | |
265 | L<範囲演算子|perlop/Range Operators> に対応するようにさらに拡張されました; | |
266 | そして Perl 5.28 では | |
267 | L<特殊な場合の空白の split|perlfunc/split> に対応するように | |
268 | さらに拡張されました。 | |
269 | 261 | |
270 | 262 | =head2 The 'unicode_eval' and 'evalbytes' features |
271 | 263 | |
272 | 264 | ('unicode_eval' と 'evalbytes' 機能) |
273 | 265 | |
274 | 266 | =begin original |
275 | 267 | |
276 | ||
268 | Under the C<unicode_eval> feature, Perl's C<eval> function, when passed a | |
277 | ||
269 | string, will evaluate it as a string of characters, ignoring any | |
278 | ||
270 | C<use utf8> declarations. C<use utf8> exists to declare the encoding of | |
279 | ||
271 | the script, which only makes sense for a stream of bytes, not a string of | |
272 | characters. Source filters are forbidden, as they also really only make | |
273 | sense on strings of bytes. Any attempt to activate a source filter will | |
274 | result in an error. | |
280 | 275 | |
281 | 276 | =end original |
282 | 277 | |
283 | ||
278 | C<unicode_eval> 機能の基では、Perl の C<eval> 関数に文字列が渡されると、 | |
284 | ||
279 | 文字の文字列として評価し、C<use utf8> 宣言を無視します。 | |
285 | ||
280 | C<use utf8> はスクリプトのエンコーディングを宣言するために存在し、 | |
286 | ||
281 | バイトの並びにのみ意味があり、文字の文字列では意味がありません。 | |
282 | ソースフィルタは禁止されます; これらもバイトの文字列に対してのみ | |
283 | 意味があるからです。 | |
284 | ソースフィルタを有効にしようとするあらゆる試みはエラーとなります。 | |
287 | 285 | |
288 | 286 | =begin original |
289 | 287 | |
290 | C< | |
288 | The C<evalbytes> feature enables the C<evalbytes> keyword, which evaluates | |
291 | ||
289 | the argument passed to it as a string of bytes. It dies if the string | |
292 | co | |
290 | contains any characters outside the 8-bit range. Source filters work | |
293 | th | |
291 | within C<evalbytes>: they apply to the contents of the string being | |
294 | ||
292 | evaluated. | |
295 | 293 | |
296 | 294 | =end original |
297 | 295 | |
298 | C< | |
296 | C<evalbytes> 機能は C<evalbytes> キーワードを有効にします; | |
299 | ||
297 | これは引数として渡されたものをバイトの文字列として評価します。 | |
300 | ||
298 | 文字列に 8 ビットの範囲の外側の文字が含まれていると die します。 | |
301 | ||
299 | ソースフィルタは C<evalbytes> の中では動作します: これらは | |
302 | ||
300 | 評価される文字列の中身に対して適用されます。 | |
303 | 詳細は L<perlfunc/Under the "unicode_eval" feature> にあります。 | |
304 | 301 | |
305 | 302 | =begin original |
306 | 303 | |
307 | ||
304 | Together, these two features are intended to replace the historical C<eval> | |
308 | n | |
305 | function, which has (at least) two bugs in it, that cannot easily be fixed | |
309 | ||
306 | without breaking existing programs: | |
310 | the current scope, you can still access it by instead writing | |
311 | C<CORE::evalbytes>. | |
312 | 307 | |
313 | 308 | =end original |
314 | 309 | |
315 | ||
310 | これら二つの機能は共に、歴史的な C<eval> 関数を置き換えることを | |
316 | ||
311 | 目的としています; これには(少なくとも)二つのバグがあり、既存のプログラムを | |
317 | ||
312 | 壊すことなく簡単に修正することができません: | |
318 | 現在のスコープに S<C<use feature 'evalbytes'>> や | |
319 | S<C<use v5.16>> (またはそれ以上) の宣言がない場合でも、 | |
320 | C<CORE::evalbytes> と書くことでこれにアクセスできます。 | |
321 | 313 | |
314 | =over | |
315 | ||
316 | =item * | |
317 | ||
318 | =begin original | |
319 | ||
320 | C<eval> behaves differently depending on the internal encoding of the | |
321 | string, sometimes treating its argument as a string of bytes, and sometimes | |
322 | as a string of characters. | |
323 | ||
324 | =end original | |
325 | ||
326 | C<eval> は文字列音内部エンコーディングに依存して異なる振る舞いを行い、 | |
327 | 時には引数をバイトの文字列として扱い、時には文字の文字列として扱います。 | |
328 | ||
329 | =item * | |
330 | ||
331 | =begin original | |
332 | ||
333 | Source filters activated within C<eval> leak out into whichever I<file> | |
334 | scope is currently being compiled. To give an example with the CPAN module | |
335 | L<Semi::Semicolons>: | |
336 | ||
337 | =end original | |
338 | ||
339 | C<eval> の中で有効にされたソースフィルタは、どの I<file> スコープが | |
340 | コンパイルされているかについてリークします。 | |
341 | CPAN モジュールである L<Semi::Semicolons> を例にします: | |
342 | ||
343 | BEGIN { eval "use Semi::Semicolons; # not filtered here " } | |
344 | # filtered here! | |
345 | ||
346 | =begin original | |
347 | ||
348 | C<evalbytes> fixes that to work the way one would expect: | |
349 | ||
350 | =end original | |
351 | ||
352 | C<evalbytes> は、想定通りに動作するように修正します: | |
353 | ||
354 | use feature "evalbytes"; | |
355 | BEGIN { evalbytes "use Semi::Semicolons; # filtered " } | |
356 | # not filtered | |
357 | ||
358 | =back | |
359 | ||
360 | =begin original | |
361 | ||
362 | These two features are available starting with Perl 5.16. | |
363 | ||
364 | =end original | |
365 | ||
366 | これら二つの機能は Perl 5.16 から利用可能です。 | |
367 | ||
322 | 368 | =head2 The 'current_sub' feature |
323 | 369 | |
324 | 370 | ('current_sub' 機能) |
325 | 371 | |
326 | 372 | =begin original |
327 | 373 | |
328 | 374 | This provides the C<__SUB__> token that returns a reference to the current |
329 | 375 | subroutine or C<undef> outside of a subroutine. |
330 | 376 | |
331 | 377 | =end original |
332 | 378 | |
333 | 379 | これは C<__SUB__> トークンを提供します; これは現在のサブルーチンへの |
334 | 380 | リファレンスか、サブルーチンの外側では C<undef> を返します。 |
335 | 381 | |
336 | 382 | =begin original |
337 | 383 | |
338 | 384 | This feature is available starting with Perl 5.16. |
339 | 385 | |
340 | 386 | =end original |
341 | 387 | |
342 | 388 | この機能は Perl 5.16 から利用可能です。 |
343 | 389 | |
344 | 390 | =head2 The 'array_base' feature |
345 | 391 | |
346 | 392 | ('array_base' 機能) |
347 | 393 | |
348 | 394 | =begin original |
349 | 395 | |
350 | This feature support | |
396 | This feature supports the legacy C<$[> variable. See L<perlvar/$[> and | |
351 | It | |
397 | L<arybase>. It is on by default but disabled under C<use v5.16> (see | |
352 | L</IMPLICIT LOADING>, below) | |
398 | L</IMPLICIT LOADING>, below). | |
353 | 399 | |
354 | 400 | =end original |
355 | 401 | |
356 | この機能はレガシーな C<$[> 変数に対応し | |
402 | この機能はレガシーな C<$[> 変数に対応します。 | |
357 | L<perlvar/$[> を参照してください。 | |
403 | L<perlvar/$[> と L<arybase> を参照してください。 | |
358 | これはデフォルトではオンで | |
404 | これはデフォルトではオンですが C<use v5.16> (後述の | |
359 | L</IMPLICIT LOADING> 参照) の | |
405 | L</IMPLICIT LOADING> 参照) の基では無効になります。 | |
360 | perl 5.30 から利用できなくなりました。 | |
361 | 406 | |
362 | 407 | =begin original |
363 | 408 | |
364 | 409 | This feature is available under this name starting with Perl 5.16. In |
365 | 410 | previous versions, it was simply on all the time, and this pragma knew |
366 | 411 | nothing about it. |
367 | 412 | |
368 | 413 | =end original |
369 | 414 | |
370 | 415 | この機能は Perl 5.16 からこの名前で利用可能です。 |
371 | 416 | 以前のバージョンでは、単に常時適用されていて、このプラグマはこれについて |
372 | 417 | 何も知りませんでした。 |
373 | 418 | |
374 | 419 | =head2 The 'fc' feature |
375 | 420 | |
376 | 421 | ('fc' 機能) |
377 | 422 | |
378 | 423 | =begin original |
379 | 424 | |
380 | 425 | C<use feature 'fc'> tells the compiler to enable the C<fc> function, |
381 | 426 | which implements Unicode casefolding. |
382 | 427 | |
383 | 428 | =end original |
384 | 429 | |
385 | 430 | C<use feature 'fc'> は、Unicode 畳み込みを実装した C<fc> 関数を |
386 | 431 | 有効にするようにコンパイラに伝えます。 |
387 | 432 | |
388 | 433 | =begin original |
389 | 434 | |
390 | 435 | See L<perlfunc/fc> for details. |
391 | 436 | |
392 | 437 | =end original |
393 | 438 | |
394 | 439 | 詳しくは L<perlfunc/fc> を参照してください。 |
395 | 440 | |
396 | 441 | =begin original |
397 | 442 | |
398 | 443 | This feature is available from Perl 5.16 onwards. |
399 | 444 | |
400 | 445 | =end original |
401 | 446 | |
402 | 447 | この機能は Perl 5.16 から利用可能です。 |
403 | 448 | |
404 | 449 | =head2 The 'lexical_subs' feature |
405 | 450 | |
406 | 451 | ('lexical_subs' 機能) |
407 | 452 | |
408 | 453 | =begin original |
409 | 454 | |
410 | I | |
455 | B<WARNING>: This feature is still experimental and the implementation may | |
411 | ||
456 | change in future versions of Perl. For this reason, Perl will | |
412 | an | |
457 | warn when you use the feature, unless you have explicitly disabled the | |
458 | warning: | |
413 | 459 | |
414 | 460 | =end original |
415 | 461 | |
416 | ||
462 | B<警告>: この機能はまだ実験的で、実装は将来のバージョンの Perl で | |
417 | ||
463 | 変わるかもしれません。 | |
418 | ||
464 | このため、この機能を使うと、明示的に無効にしない限り警告が発生します: | |
419 | 詳しくは L<perlsub/Lexical Subroutines> を参照してください。 | |
420 | 465 | |
466 | no warnings "experimental::lexical_subs"; | |
467 | ||
421 | 468 | =begin original |
422 | 469 | |
423 | This | |
470 | This enables declaration of subroutines via C<my sub foo>, C<state sub foo> | |
424 | ||
471 | and C<our sub foo> syntax. See L<perlsub/Lexical Subroutines> for details. | |
425 | usage, except when explicitly disabled: | |
426 | 472 | |
427 | 473 | =end original |
428 | 474 | |
429 | こ | |
475 | これは、C<my sub foo>, C<state sub foo>, C<our sub foo> 文法による | |
430 | ||
476 | サブルーチンの定義を有効にします。 | |
431 | ||
477 | 詳しくは L<perlsub/Lexical Subroutines> を参照してください。 | |
432 | 478 | |
433 | no warnings "experimental::lexical_subs"; | |
434 | ||
435 | 479 | =begin original |
436 | 480 | |
437 | ||
481 | This feature is available from Perl 5.18 onwards. | |
438 | the C<experimental::lexical_subs> warning category still exists (for | |
439 | compatibility with code that disables it). In addition, this syntax is | |
440 | not only no longer experimental, but it is enabled for all Perl code, | |
441 | regardless of what feature declarations are in scope. | |
442 | 482 | |
443 | 483 | =end original |
444 | 484 | |
445 | Perl 5. | |
485 | この機能は Perl 5.18 から利用可能です。 | |
446 | C<experimental::lexical_subs> 警告カテゴリは(これを無効にするコードとの | |
447 | 互換性のために)存在するままです。 | |
448 | さらにl、この文法はもはや実験的ではないだけでなく、 | |
449 | どんな機能宣言がスコープ内にあるかに関わらず、 | |
450 | 全ての Perl コードで有効です。 | |
451 | 486 | |
452 | 487 | =head2 The 'postderef' and 'postderef_qq' features |
453 | 488 | |
454 | 489 | ('postderef' と 'postderef_qq' 機能) |
455 | 490 | |
456 | 491 | =begin original |
457 | 492 | |
458 | 493 | The 'postderef_qq' feature extends the applicability of L<postfix |
459 | 494 | dereference syntax|perlref/Postfix Dereference Syntax> so that postfix array |
460 | 495 | and scalar dereference are available in double-quotish interpolations. For |
461 | 496 | example, it makes the following two statements equivalent: |
462 | 497 | |
463 | 498 | =end original |
464 | 499 | |
465 | 500 | 'postderef_qq' 機能は、 |
466 | 501 | L<後置デリファレンス文法|perlref/Postfix Dereference Syntax> の機能を、 |
467 | 502 | 後置配列と後置スカラのデリファレンスがダブルクォート風変数展開で |
468 | 503 | 利用可能になるように拡張します。 |
469 | 504 | 例えば、次の二つの文が等価になります: |
470 | 505 | |
471 | 506 | my $s = "[@{ $h->{a} }]"; |
472 | 507 | my $s = "[$h->{a}->@*]"; |
473 | 508 | |
474 | 509 | =begin original |
475 | 510 | |
476 | 511 | This feature is available from Perl 5.20 onwards. In Perl 5.20 and 5.22, it |
477 | 512 | was classed as experimental, and Perl emitted a warning for its |
478 | 513 | usage, except when explicitly disabled: |
479 | 514 | |
480 | 515 | =end original |
481 | 516 | |
482 | 517 | この機能は Perl 5.20 から利用可能です。 |
483 | 518 | Perl 5.20 と 5.22 では、これは実験的と位置づけられていて、 |
484 | 519 | 明示的に無効にしない限り Perl は警告を出力していました: |
485 | 520 | |
486 | 521 | no warnings "experimental::postderef"; |
487 | 522 | |
488 | 523 | =begin original |
489 | 524 | |
490 | 525 | As of Perl 5.24, use of this feature no longer triggers a warning, though |
491 | 526 | the C<experimental::postderef> warning category still exists (for |
492 | 527 | compatibility with code that disables it). |
493 | 528 | |
494 | 529 | =end original |
495 | 530 | |
496 | 531 | Perl 5.24 から、この機能の使用はもはや警告を出力しなくなりましたが、 |
497 | 532 | C<experimental::postderef> 警告カテゴリは(これを無効にするコードとの |
498 | 533 | 互換性のために)存在するままです。 |
499 | 534 | |
500 | 535 | =begin original |
501 | 536 | |
502 | 537 | The 'postderef' feature was used in Perl 5.20 and Perl 5.22 to enable |
503 | 538 | postfix dereference syntax outside double-quotish interpolations. In those |
504 | 539 | versions, using it triggered the C<experimental::postderef> warning in the |
505 | 540 | same way as the 'postderef_qq' feature did. As of Perl 5.24, this syntax is |
506 | 541 | not only no longer experimental, but it is enabled for all Perl code, |
507 | 542 | regardless of what feature declarations are in scope. |
508 | 543 | |
509 | 544 | =end original |
510 | 545 | |
511 | 546 | 'postderef' 機能は、ダブルクォート風変数展開の外側での |
512 | 547 | 後置デリファレンス文法を有効にするために Perl 5.20 から Perl 5.22 で |
513 | 548 | 使われていました。 |
514 | 549 | これらのバージョンでは、'postderef_qq' 機能と同様に、これを使うと |
515 | 550 | C<experimental::postderef> 警告を引き起こします。 |
516 | 551 | Perl 5.24 から、この文法はもはや実験的ではなくなっただけではなく、 |
517 | 552 | スコープ中でどんな機能が宣言されているかに関わらず、全ての Perl コードで |
518 | 553 | 有効になりました。 |
519 | 554 | |
520 | 555 | =head2 The 'signatures' feature |
521 | 556 | |
522 | 557 | ('signatures' 機能) |
523 | 558 | |
524 | 559 | =begin original |
525 | 560 | |
526 | 561 | B<WARNING>: This feature is still experimental and the implementation may |
527 | 562 | change in future versions of Perl. For this reason, Perl will |
528 | 563 | warn when you use the feature, unless you have explicitly disabled the |
529 | 564 | warning: |
530 | 565 | |
531 | 566 | =end original |
532 | 567 | |
533 | 568 | B<警告>: この機能はまだ実験的で、実装は将来のバージョンの Perl で |
534 | 569 | 変わるかもしれません。 |
535 | 570 | このため、この機能を使うと、明示的に無効にしない限り警告が発生します: |
536 | 571 | |
537 | 572 | no warnings "experimental::signatures"; |
538 | 573 | |
539 | 574 | =begin original |
540 | 575 | |
541 | 576 | This enables unpacking of subroutine arguments into lexical variables |
542 | 577 | by syntax such as |
543 | 578 | |
544 | 579 | =end original |
545 | 580 | |
546 | 581 | これは、次のような文法によってサブルーチンの引数をレキシカル変数に |
547 | 582 | 展開できるようにします: |
548 | 583 | |
549 | 584 | sub foo ($left, $right) { |
550 | 585 | return $left + $right; |
551 | 586 | } |
552 | 587 | |
553 | 588 | =begin original |
554 | 589 | |
555 | 590 | See L<perlsub/Signatures> for details. |
556 | 591 | |
557 | 592 | =end original |
558 | 593 | |
559 | 594 | 詳しくは L<perlsub/Signatures> を参照してください。 |
560 | 595 | |
561 | 596 | =begin original |
562 | 597 | |
563 | 598 | This feature is available from Perl 5.20 onwards. |
564 | 599 | |
565 | 600 | =end original |
566 | 601 | |
567 | 602 | この機能は Perl 5.20 から利用可能です。 |
568 | 603 | |
569 | 604 | =head2 The 'refaliasing' feature |
570 | 605 | |
571 | 606 | ('refaliasing' 機能) |
572 | 607 | |
573 | 608 | =begin original |
574 | 609 | |
575 | 610 | B<WARNING>: This feature is still experimental and the implementation may |
576 | 611 | change in future versions of Perl. For this reason, Perl will |
577 | 612 | warn when you use the feature, unless you have explicitly disabled the |
578 | 613 | warning: |
579 | 614 | |
580 | 615 | =end original |
581 | 616 | |
582 | 617 | B<警告>: この機能はまだ実験的で、実装は将来のバージョンの Perl で |
583 | 618 | 変わるかもしれません。 |
584 | 619 | このため、この機能を使うと、明示的に無効にしない限り警告が発生します: |
585 | 620 | |
586 | 621 | no warnings "experimental::refaliasing"; |
587 | 622 | |
588 | 623 | =begin original |
589 | 624 | |
590 | 625 | This enables aliasing via assignment to references: |
591 | 626 | |
592 | 627 | =end original |
593 | 628 | |
594 | 629 | これはリファレンスへの代入による別名化を有効にします: |
595 | 630 | |
596 | 631 | \$a = \$b; # $a and $b now point to the same scalar |
597 | 632 | \@a = \@b; # to the same array |
598 | 633 | \%a = \%b; |
599 | 634 | \&a = \&b; |
600 | 635 | foreach \%hash (@array_of_hash_refs) { |
601 | 636 | ... |
602 | 637 | } |
603 | 638 | |
604 | 639 | =begin original |
605 | 640 | |
606 | 641 | See L<perlref/Assigning to References> for details. |
607 | 642 | |
608 | 643 | =end original |
609 | 644 | |
610 | 645 | 詳しくは L<perlref/Assigning to References> を参照してください。 |
611 | 646 | |
612 | 647 | =begin original |
613 | 648 | |
614 | 649 | This feature is available from Perl 5.22 onwards. |
615 | 650 | |
616 | 651 | =end original |
617 | 652 | |
618 | 653 | この機能は Perl 5.22 から利用可能です。 |
619 | 654 | |
620 | 655 | =head2 The 'bitwise' feature |
621 | 656 | |
622 | 657 | ('bitwise' 機能) |
623 | 658 | |
624 | 659 | =begin original |
625 | 660 | |
661 | B<WARNING>: This feature is still experimental and the implementation may | |
662 | change in future versions of Perl. For this reason, Perl will | |
663 | warn when you use the feature, unless you have explicitly disabled the | |
664 | warning: | |
665 | ||
666 | =end original | |
667 | ||
668 | B<警告>: この機能はまだ実験的で、実装は将来のバージョンの Perl で | |
669 | 変わるかもしれません。 | |
670 | このため、この機能を使うと、明示的に無効にしない限り警告が発生します: | |
671 | ||
672 | no warnings "experimental::bitwise"; | |
673 | ||
674 | =begin original | |
675 | ||
626 | 676 | This makes the four standard bitwise operators (C<& | ^ ~>) treat their |
627 | 677 | operands consistently as numbers, and introduces four new dotted operators |
628 | 678 | (C<&. |. ^. ~.>) that treat their operands consistently as strings. The |
629 | 679 | same applies to the assignment variants (C<&= |= ^= &.= |.= ^.=>). |
630 | 680 | |
631 | 681 | =end original |
632 | 682 | |
633 | 683 | これは四つの標準ビット単位演算子 (C<& | ^ ~>) がそのオペランドを |
634 | 684 | 数値として一貫して扱うようになり、 |
635 | 685 | オペランドを一貫して文字列として扱う新しいドット付き演算子 |
636 | 686 | (C<&. |. ^. ~.>) を導入します。 |
637 | 687 | 同じものは代入の亜種 (C<&= |= ^= &.= |.= ^.=>) にも適用されます。 |
638 | 688 | |
639 | 689 | =begin original |
640 | 690 | |
641 | 691 | See L<perlop/Bitwise String Operators> for details. |
642 | 692 | |
643 | 693 | =end original |
644 | 694 | |
645 | 695 | 詳しくは L<perlop/Bitwise String Operators> を参照してください。 |
646 | 696 | |
647 | 697 | =begin original |
648 | 698 | |
649 | This feature is available from Perl 5.22 onwards. | |
699 | This feature is available from Perl 5.22 onwards. | |
650 | C<use v5.28> will enable the feature. Before 5.28, it was still | |
651 | experimental and would emit a warning in the "experimental::bitwise" | |
652 | category. | |
653 | 700 | |
654 | 701 | =end original |
655 | 702 | |
656 | 703 | この機能は Perl 5.22 から利用可能です。 |
657 | Perl 5.28 から、C<use v5.28> はこの機能を有効にします。 | |
658 | 5.28 より前では、これはまだ実験的で、 | |
659 | "experimental::bitwise" カテゴリの警告が出力されます。 | |
660 | 704 | |
661 | =head2 The 'declared_refs' feature | |
662 | ||
663 | ('declared_refs' 機能) | |
664 | ||
665 | =begin original | |
666 | ||
667 | B<WARNING>: This feature is still experimental and the implementation may | |
668 | change in future versions of Perl. For this reason, Perl will | |
669 | warn when you use the feature, unless you have explicitly disabled the | |
670 | warning: | |
671 | ||
672 | =end original | |
673 | ||
674 | B<警告>: この機能はまだ実験的で、実装は将来のバージョンの Perl で | |
675 | 変わるかもしれません。 | |
676 | このため、この機能を使うと、明示的に無効にしない限り警告が発生します: | |
677 | ||
678 | no warnings "experimental::declared_refs"; | |
679 | ||
680 | =begin original | |
681 | ||
682 | This allows a reference to a variable to be declared with C<my>, C<state>, | |
683 | our C<our>, or localized with C<local>. It is intended mainly for use in | |
684 | conjunction with the "refaliasing" feature. See L<perlref/Declaring a | |
685 | Reference to a Variable> for examples. | |
686 | ||
687 | =end original | |
688 | ||
689 | これは C<my>, C<state>, C<our>, C<local> でのローカル化において、 | |
690 | 変数へのリファレンスを宣言できるようになります。 | |
691 | これは主に "refaliasing" 機能と併せて使うことを意図しています。 | |
692 | 例については L<perlref/Declaring a Reference to a Variable> を | |
693 | 参照してください。 | |
694 | ||
695 | =begin original | |
696 | ||
697 | This feature is available from Perl 5.26 onwards. | |
698 | ||
699 | =end original | |
700 | ||
701 | この機能は Perl 5.26 から利用可能です。 | |
702 | ||
703 | 705 | =head1 FEATURE BUNDLES |
704 | 706 | |
705 | 707 | (機能の束) |
706 | 708 | |
707 | 709 | =begin original |
708 | 710 | |
709 | 711 | It's possible to load multiple features together, using |
710 | 712 | a I<feature bundle>. The name of a feature bundle is prefixed with |
711 | 713 | a colon, to distinguish it from an actual feature. |
712 | 714 | |
713 | 715 | =end original |
714 | 716 | |
715 | 717 | 複数の機能のまとめて読み込むためには、I<機能の束> (feature bundle) が |
716 | 718 | 使えます。 |
717 | 719 | 機能の束の名前には、実際の機能と区別するためにコロンが前置されます。 |
718 | 720 | |
719 | 721 | use feature ":5.10"; |
720 | 722 | |
721 | 723 | =begin original |
722 | 724 | |
723 | 725 | The following feature bundles are available: |
724 | 726 | |
725 | 727 | =end original |
726 | 728 | |
727 | 729 | 以下の機能の束が利用可能です: |
728 | 730 | |
729 | =begin original | |
730 | ||
731 | 731 | bundle features included |
732 | 732 | --------- ----------------- |
733 | :default | |
733 | :default array_base | |
734 | 734 | |
735 | ||
735 | :5.10 say state switch array_base | |
736 | 736 | |
737 | | |
737 | :5.12 say state switch unicode_strings array_base | |
738 | --------- ----------------- | |
739 | :default | |
740 | 738 | |
741 | :5.1 | |
739 | :5.14 say state switch unicode_strings array_base | |
742 | 740 | |
743 | :5.12 say state switch unicode_strings | |
744 | ||
745 | :5.14 say state switch unicode_strings | |
746 | ||
747 | 741 | :5.16 say state switch unicode_strings |
748 | 742 | unicode_eval evalbytes current_sub fc |
749 | 743 | |
750 | 744 | :5.18 say state switch unicode_strings |
751 | 745 | unicode_eval evalbytes current_sub fc |
752 | 746 | |
753 | 747 | :5.20 say state switch unicode_strings |
754 | 748 | unicode_eval evalbytes current_sub fc |
755 | 749 | |
756 | 750 | :5.22 say state switch unicode_strings |
757 | 751 | unicode_eval evalbytes current_sub fc |
758 | 752 | |
759 | 753 | :5.24 say state switch unicode_strings |
760 | 754 | unicode_eval evalbytes current_sub fc |
761 | 755 | postderef_qq |
762 | 756 | |
763 | :5.26 say state switch unicode_strings | |
764 | unicode_eval evalbytes current_sub fc | |
765 | postderef_qq | |
766 | ||
767 | :5.28 say state switch unicode_strings | |
768 | unicode_eval evalbytes current_sub fc | |
769 | postderef_qq bitwise | |
770 | ||
771 | :5.30 say state switch unicode_strings | |
772 | unicode_eval evalbytes current_sub fc | |
773 | postderef_qq bitwise | |
774 | ||
775 | 757 | =begin original |
776 | 758 | |
777 | 759 | The C<:default> bundle represents the feature set that is enabled before |
778 | 760 | any C<use feature> or C<no feature> declaration. |
779 | 761 | |
780 | 762 | =end original |
781 | 763 | |
782 | 764 | C<:default> 束は、C<use feature> や C<no feature> 宣言が有効になる前の |
783 | 765 | 機能集合を表現しています。 |
784 | 766 | |
785 | 767 | =begin original |
786 | 768 | |
787 | 769 | Specifying sub-versions such as the C<0> in C<5.14.0> in feature bundles has |
788 | 770 | no effect. Feature bundles are guaranteed to be the same for all sub-versions. |
789 | 771 | |
790 | 772 | =end original |
791 | 773 | |
792 | 774 | 機能の束での C<5.14.0> の C<0> のような副バージョンを指定しても効果は |
793 | 775 | ありません。 |
794 | 776 | 機能の束は全ての副バージョンに関して同じ事が保証されています。 |
795 | 777 | |
796 | 778 | use feature ":5.14.0"; # same as ":5.14" |
797 | 779 | use feature ":5.14.1"; # same as ":5.14" |
798 | 780 | |
799 | 781 | =head1 IMPLICIT LOADING |
800 | 782 | |
801 | 783 | (暗黙の読み込み) |
802 | 784 | |
803 | 785 | =begin original |
804 | 786 | |
805 | 787 | Instead of loading feature bundles by name, it is easier to let Perl do |
806 | 788 | implicit loading of a feature bundle for you. |
807 | 789 | |
808 | 790 | =end original |
809 | 791 | |
810 | 792 | 機能の束を名前で読み込むより、Perl に機能の束を暗黙に読み込ませるように |
811 | 793 | した方が簡単です。 |
812 | 794 | |
813 | 795 | =begin original |
814 | 796 | |
815 | 797 | There are two ways to load the C<feature> pragma implicitly: |
816 | 798 | |
817 | 799 | =end original |
818 | 800 | |
819 | 801 | C<feature> プラグマを暗黙に読み込むには二つの方法があります: |
820 | 802 | |
821 | 803 | =over 4 |
822 | 804 | |
823 | 805 | =item * |
824 | 806 | |
825 | 807 | =begin original |
826 | 808 | |
827 | 809 | By using the C<-E> switch on the Perl command-line instead of C<-e>. |
828 | 810 | That will enable the feature bundle for that version of Perl in the |
829 | 811 | main compilation unit (that is, the one-liner that follows C<-E>). |
830 | 812 | |
831 | 813 | =end original |
832 | 814 | |
833 | 815 | Perl のコマンドラインで C<-e> オプションの代わりに C<-E> オプションを |
834 | 816 | 使用した場合。 |
835 | 817 | これにより、main コンパイル単位(つまり、C<-E> に引き続く 1 行野郎)で |
836 | 818 | そのバージョンの Perl の機能の束が有効になります。 |
837 | 819 | |
838 | 820 | =item * |
839 | 821 | |
840 | 822 | =begin original |
841 | 823 | |
842 | 824 | By explicitly requiring a minimum Perl version number for your program, with |
843 | 825 | the C<use VERSION> construct. That is, |
844 | 826 | |
845 | 827 | =end original |
846 | 828 | |
847 | 829 | C<use VERSION> 構文を使ってプログラムが必要とする最低限の Perl バージョン |
848 | 830 | 番号を明示的に指定した場合。 |
849 | 831 | つまり、以下のようにすると: |
850 | 832 | |
851 | 833 | use v5.10.0; |
852 | 834 | |
853 | 835 | =begin original |
854 | 836 | |
855 | 837 | will do an implicit |
856 | 838 | |
857 | 839 | =end original |
858 | 840 | |
859 | 841 | 暗黙のうちに以下のように: |
860 | 842 | |
861 | 843 | no feature ':all'; |
862 | 844 | use feature ':5.10'; |
863 | 845 | |
864 | 846 | =begin original |
865 | 847 | |
866 | 848 | and so on. Note how the trailing sub-version |
867 | 849 | is automatically stripped from the |
868 | 850 | version. |
869 | 851 | |
870 | 852 | =end original |
871 | 853 | |
872 | 854 | なるということです。 |
873 | 855 | 末尾の副バージョンは自動的にバージョンから取り除かれるようになったことに |
874 | 856 | 注意してください。 |
875 | 857 | |
876 | 858 | =begin original |
877 | 859 | |
878 | 860 | But to avoid portability warnings (see L<perlfunc/use>), you may prefer: |
879 | 861 | |
880 | 862 | =end original |
881 | 863 | |
882 | 864 | しかし移植性の警告(L<perlfunc/use> を参照してください)を避けるために、 |
883 | 865 | 以下のようにするのを好むかもしれません: |
884 | 866 | |
885 | 867 | use 5.010; |
886 | 868 | |
887 | 869 | =begin original |
888 | 870 | |
889 | 871 | with the same effect. |
890 | 872 | |
891 | 873 | =end original |
892 | 874 | |
893 | 875 | これでも同じ効果が得られます。 |
894 | 876 | |
895 | 877 | =begin original |
896 | 878 | |
897 | 879 | If the required version is older than Perl 5.10, the ":default" feature |
898 | 880 | bundle is automatically loaded instead. |
899 | 881 | |
900 | 882 | =end original |
901 | 883 | |
902 | 884 | 要求したバージョンが Perl 5.10 より前の場合、代わりに機能の束 ":default" が |
903 | 885 | 自動的に読み込まれます。 |
904 | ||
905 | =begin original | |
906 | ||
907 | Unlike C<use feature ":5.12">, saying C<use v5.12> (or any higher version) | |
908 | also does the equivalent of C<use strict>; see L<perlfunc/use> for details. | |
909 | ||
910 | =end original | |
911 | ||
912 | C<use feature ":5.12"> と異なり、C<use v5.12> (またはそれ以上) とすると、 | |
913 | C<use strict> と等価なことを行います; | |
914 | 詳しくは L<perlfunc/use> を参照してください。 | |
915 | 886 | |
916 | 887 | =back |
917 | 888 | |
918 | 889 | =cut |
919 | 890 | |
920 | 891 | =begin meta |
921 | 892 | |
922 | 893 | Translate: SHIRAKATA Kentaro <argrath@ub32.org> |
923 | 894 | Status: completed |
924 | 895 | |
925 | 896 | =end meta |