base-2.14 >
2.22
との差分
base 2.22 と 2.14 の差分
1 | 1 | |
2 | 2 | =encoding euc-jp |
3 | 3 | |
4 | 4 | =head1 NAME |
5 | 5 | |
6 | 6 | =begin original |
7 | 7 | |
8 | 8 | base - Establish an ISA relationship with base classes at compile time |
9 | 9 | |
10 | 10 | =end original |
11 | 11 | |
12 | 12 | base - コンパイル時に基底クラスとの ISA 関係を構築する |
13 | 13 | |
14 | 14 | =head1 SYNOPSIS |
15 | 15 | |
16 | 16 | package Baz; |
17 | 17 | use base qw(Foo Bar); |
18 | 18 | |
19 | 19 | =head1 DESCRIPTION |
20 | 20 | |
21 | 21 | =begin original |
22 | 22 | |
23 | 23 | Unless you are using the C<fields> pragma, consider this module discouraged |
24 | 24 | in favor of the lighter-weight C<parent>. |
25 | 25 | |
26 | 26 | =end original |
27 | 27 | |
28 | 28 | C<fields> プラグマを使っているのでない限り、このモジュールは非推奨です; |
29 | 29 | 代わりに軽量な C<parent> を使ってください。 |
30 | 30 | |
31 | 31 | =begin original |
32 | 32 | |
33 | 33 | Allows you to both load one or more modules, while setting up inheritance from |
34 | 34 | those modules at the same time. Roughly similar in effect to |
35 | 35 | |
36 | 36 | =end original |
37 | 37 | |
38 | 38 | 一つまたは複数のモジュールを読み込んで、それらのモジュールから継承するのを |
39 | 39 | 同時に行います。 |
40 | 40 | おおよそ次のような効果があります: |
41 | 41 | |
42 | 42 | package Baz; |
43 | 43 | BEGIN { |
44 | 44 | require Foo; |
45 | 45 | require Bar; |
46 | 46 | push @ISA, qw(Foo Bar); |
47 | 47 | } |
48 | 48 | |
49 | 49 | =begin original |
50 | 50 | |
51 | ||
51 | C<base> employs some heuristics to determine if a module has already been | |
52 | ||
52 | loaded, if it has it doesn't try again. If C<base> tries to C<require> the | |
53 | ||
53 | module it will not die if it cannot find the module's file, but will die on any | |
54 | ||
54 | other error. After all this, should your base class be empty, containing no | |
55 | t | |
55 | symbols, it will die. This is useful for inheriting from classes in the same | |
56 | file as yourself, like so: | |
56 | 57 | |
57 | 58 | =end original |
58 | 59 | |
60 | モジュールが既に読み込まれている場合、再び行わないようにするために | |
61 | C<base> は宣言に経験則を用います。 | |
59 | 62 | C<base> がモジュールを C<require> しようとしたとき、モジュールのファイルが |
60 | 63 | 見つからなくても die しません。 |
61 | 64 | しかしその他のエラーでは die します。 |
62 | これら全ての後、基底クラスが空で、シンボルを含んでいない場合、 | |
65 | これら全ての後、基底クラスが空で、シンボルを含んでいない場合、die します。 | |
63 | ||
66 | これは次のように、自分自身で同じファイルのクラスから継承するのに有用です: | |
64 | これは次のように、自分自身で同じファイルにあるけれども | |
65 | ファイル名が基底モジュール名と一致しないクラスから継承するのに有用です: | |
66 | 67 | |
67 | # in Bar.pm | |
68 | 68 | package Foo; |
69 | 69 | sub exclaim { "I can have such a thing?!" } |
70 | ||
71 | 71 | package Bar; |
72 | 72 | use base "Foo"; |
73 | 73 | |
74 | 74 | =begin original |
75 | 75 | |
76 | ||
76 | If $VERSION is not detected even after loading it, <base> will define $VERSION | |
77 | ||
77 | in the base package, setting it to the string C<-1, set by base.pm>. | |
78 | 78 | |
79 | 79 | =end original |
80 | 80 | |
81 | ||
81 | ロードの後でも $VERSION が検出されなかった場合、 | |
82 | ||
82 | <base> は基底パッケージで $VERSION を定義し、文字列 | |
83 | ||
83 | C<-1, set by base.pm> を設定します。 | |
84 | 84 | |
85 | 85 | =begin original |
86 | 86 | |
87 | 87 | C<base> will also initialize the fields if one of the base classes has it. |
88 | 88 | Multiple inheritance of fields is B<NOT> supported, if two or more base classes |
89 | each have inheritable fields the 'base' pragma will croak. See L<fields> | |
89 | each have inheritable fields the 'base' pragma will croak. See L<fields>, | |
90 | for a description of this feature. | |
90 | L<public> and L<protected> for a description of this feature. | |
91 | 91 | |
92 | 92 | =end original |
93 | 93 | |
94 | 94 | C<base> はまた、基底クラスのいずれかが持っているフィールドを初期化します。 |
95 | 95 | 多重継承は対応して B<いません>; 複数の基底クラスがそれぞれ継承可能な |
96 | 96 | フィールドを持っている場合、'base' プラグマは croak します。 |
97 | この機能の説明については L<fields> を | |
97 | この機能の説明については L<fields>, L<public>, L<protected> を | |
98 | 参照してください。 | |
98 | 99 | |
99 | 100 | =begin original |
100 | 101 | |
101 | 102 | The base class' C<import> method is B<not> called. |
102 | 103 | |
103 | 104 | =end original |
104 | 105 | |
105 | 106 | 基底クラスの C<import> メソッドは B<呼び出されません>。 |
106 | 107 | |
107 | 108 | =head1 DIAGNOSTICS |
108 | 109 | |
109 | 110 | (診断メッセージ) |
110 | 111 | |
111 | 112 | =over 4 |
112 | 113 | |
113 | 114 | =item Base class package "%s" is empty. |
114 | 115 | |
115 | 116 | =begin original |
116 | 117 | |
117 | 118 | base.pm was unable to require the base package, because it was not |
118 | 119 | found in your path. |
119 | 120 | |
120 | 121 | =end original |
121 | 122 | |
122 | 123 | パスに見つからなかったので、base.pm は基底パッケージを |
123 | 124 | require できませんでした。 |
124 | 125 | |
125 | 126 | =item Class 'Foo' tried to inherit from itself |
126 | 127 | |
127 | 128 | =begin original |
128 | 129 | |
129 | 130 | Attempting to inherit from yourself generates a warning. |
130 | 131 | |
131 | 132 | =end original |
132 | 133 | |
133 | 134 | 自分自身を継承しようとすると警告が出ます。 |
134 | 135 | |
135 | | |
136 | use Foo; | |
136 | 137 | use base 'Foo'; |
137 | 138 | |
138 | 139 | =back |
139 | 140 | |
140 | 141 | =head1 HISTORY |
141 | 142 | |
142 | 143 | =begin original |
143 | 144 | |
144 | 145 | This module was introduced with Perl 5.004_04. |
145 | 146 | |
146 | 147 | =end original |
147 | 148 | |
148 | 149 | このモジュールは Perl 5.004_04 で導入されました。 |
149 | 150 | |
150 | 151 | =head1 CAVEATS |
151 | 152 | |
152 | 153 | (注意) |
153 | 154 | |
154 | 155 | =begin original |
155 | 156 | |
156 | 157 | Due to the limitations of the implementation, you must use |
157 | 158 | base I<before> you declare any of your own fields. |
158 | 159 | |
159 | 160 | =end original |
160 | 161 | |
161 | 162 | 実装上の制限により、独自のフィールドを宣言する I<前に>use base しなければなりません。 |
162 | 163 | |
163 | 164 | =head1 SEE ALSO |
164 | 165 | |
165 | 166 | L<fields> |
166 | 167 | |
167 | 168 | =begin meta |
168 | 169 | |
169 | 170 | Translate: SHIRAKATA Kentaro <argrath@ub32.org> |
170 | 171 | Status: completed |
171 | 172 | |
172 | 173 | =end meta |
173 | 174 | |
174 | 175 | =cut |