Commit | Line | Data |
600f7f85 |
1 | =pod |
2 | |
3 | =head1 NAME |
4 | |
5 | Moose::Manual::Delta - Important Changes in Moose |
6 | |
7 | =head1 DESCRIPTION |
8 | |
0f13f53c |
9 | This documents any important or noteworthy changes in Moose, with a |
10 | focus on backwards. This does duplicate data from the F<Changes> file, |
11 | but aims to provide more details and when possible workarounds. |
12 | |
13 | Besides helping keep up with changes, you can also use this document |
14 | for finding the lowest version of Moose that supported a given |
15 | feature. If you encounter a problem and have a solution but don't see |
16 | it documented here, or think we missed an important feature, please |
17 | send us a patch. |
600f7f85 |
18 | |
19 | =head1 Version 0.73 |
20 | |
0f13f53c |
21 | Calling C<subtype> with a name as the only argument now throws an |
600f7f85 |
22 | exception. If you want an anonymous subtype do: |
23 | |
24 | my $subtype = subtype as 'Foo'; |
25 | |
0f13f53c |
26 | This is related to the changes in version 0.71_01. |
600f7f85 |
27 | |
28 | =head1 Version 0.72 |
29 | |
0f13f53c |
30 | A mutable class accepted C<< Foo->new(undef) >> without complaint, |
31 | while an immutable class would blow up with an unhelpful error. Now, |
32 | in both cases we throw a helpful error instead. |
600f7f85 |
33 | |
0f13f53c |
34 | This "feature" was originally added to allow for cases such as this: |
600f7f85 |
35 | |
36 | my $args; |
0f13f53c |
37 | |
38 | if ( something() ) { |
39 | $args = {...}; |
600f7f85 |
40 | } |
0f13f53c |
41 | |
600f7f85 |
42 | return My::Class->new($args); |
43 | |
0f13f53c |
44 | But we decided this is a bad idea and a little too magical, because it |
45 | can easily mask real errors. |
600f7f85 |
46 | |
47 | =head1 Version 0.71_01 |
48 | |
0f13f53c |
49 | Calling C<type> or C<subtype> without the sugar helpers (C<as>, |
50 | C<where>, C<message>) is now deprecated. |
51 | |
52 | As a side effect, this meant we ended up using Perl prototypes on |
53 | C<as>, and code like this will no longer work: |
600f7f85 |
54 | |
55 | use Moose::Util::TypeConstraints; |
56 | use Declare::Constraints::Simple -All; |
0f13f53c |
57 | |
58 | subtype 'ArrayOfInts' |
600f7f85 |
59 | => as 'ArrayRef' |
60 | => IsArrayRef(IsInt); |
61 | |
62 | Instead it must be changed to this: |
63 | |
0f13f53c |
64 | subtype( |
65 | 'ArrayOfInts' => { |
66 | as => 'ArrayRef', |
67 | where => IsArrayRef(IsInt) |
68 | } |
600f7f85 |
69 | ); |
70 | |
0f13f53c |
71 | If you want to maintain backwards compat with older versions of Moose, |
72 | you must explicitly test Moose's C<VERSION>: |
600f7f85 |
73 | |
0f13f53c |
74 | if ( Moose->VERSION < 0.71_01 ) { |
75 | subtype 'ArrayOfInts' |
600f7f85 |
76 | => as 'ArrayRef' |
77 | => IsArrayRef(IsInt); |
78 | } |
79 | else { |
0f13f53c |
80 | subtype( |
81 | 'ArrayOfInts' => { |
82 | as => 'ArrayRef', |
83 | where => IsArrayRef(IsInt) |
84 | } |
600f7f85 |
85 | ); |
86 | } |
87 | |
88 | =head1 Version 0.70 |
89 | |
0f13f53c |
90 | We no longer pass the meta-attribute object as a final argument to |
91 | triggers. This actually changed for inlined code a while back, but the |
92 | non-inlined version and the docs were still out of date. |
93 | |
94 | If by some chance you actually used this feature, the workaround is |
95 | simple. You fetch the attribute object from out of the C<$self> |
96 | that is passed as the first argument to trigger, like so: |
97 | |
98 | has 'foo' => ( |
99 | is => 'ro', |
100 | isa => 'Any', |
101 | trigger => sub { |
102 | my ( $self, $value ) = @_; |
103 | my $attr = $self->meta->find_attribute_by_name('foo'); |
104 | |
105 | # ... |
106 | } |
107 | ); |
600f7f85 |
108 | |
109 | =head1 Version 0.66 |
110 | |
0f13f53c |
111 | If you created a subtype and passed a parent that Moose didn't know |
112 | about, it simply ignored the parent. Now it automatically creates the |
113 | parent as a class type. This may not be what you want, but is less |
114 | broken than before. |
600f7f85 |
115 | |
0f13f53c |
116 | You could declare a name with subtype such as "Foo!Bar". Moose would |
117 | accept this allowed, but if you used it in a parameterized type such |
118 | as "ArrayRef[Foo!Bar]" it wouldn't work. We now do some vetting on |
119 | names created via the sugar functions, so that they can only contain |
120 | alphanumerics, ":", and ".". |
600f7f85 |
121 | |
122 | =head1 Version 0.65 |
123 | |
124 | Methods created via an attribute can now fulfill a C<requires> |
0f13f53c |
125 | declaration for a role. Honestly we don't know why Stevan didn't make |
126 | this work originally, he was just insane or something. |
600f7f85 |
127 | |
0f13f53c |
128 | Stack traces from inlined code will now report the line and file as |
129 | being in your class, as opposed to in Moose guts. |
600f7f85 |
130 | |
131 | =head1 Version 0.62_02 |
132 | |
0f13f53c |
133 | When a class does not provide all of a role's required methods, the |
134 | error thrown now mentions all of the missing methods, as opposed to |
135 | just the first missing method. |
600f7f85 |
136 | |
0f13f53c |
137 | Moose will no longer inline a constructor for your class unless it |
138 | inherits its constructor is inherited from Moose::Object, and will |
139 | warn when it doesn't inline. If you want to force inlining anyway, |
140 | pass C<< "replace_constructor => 1 >> to C<make_immutable>. |
141 | |
142 | If you want to get rid of the warning, pass C<< inline_constructor => |
143 | 1 >>. |
600f7f85 |
144 | |
145 | =head1 Version 0.62 |
146 | |
0f13f53c |
147 | Removed the (deprecated) C<make_immutable> keyword. |
600f7f85 |
148 | |
149 | Removing an attribute from a class now also removes delegation |
0f13f53c |
150 | (C<handles>) methods installed for that attribute. This is correct |
600f7f85 |
151 | behavior, but if you were wrongly relying on it you might get bit. |
152 | |
153 | =head1 Version 0.58 |
154 | |
0f13f53c |
155 | Roles now add methods by calling C<add_method>, not |
156 | C<alias_method>. They make sure to always provide a method object, |
157 | which will be cloned internally. This means that it is now possible to |
158 | track the source of a method provided by a role, and even follow its |
159 | history through intermediate roles. This means that methods added by |
160 | a role now show up when looking at a class's method list/map. |
161 | |
162 | Parameter and Union args are now sorted, this makes Int|Str the same |
163 | constraint as Str|Int. Also, incoming type constraint strings are |
164 | normalized to remove all whitespace differences. This is mostly for |
165 | internals and should not affect outside code. |
166 | |
167 | L<Moose::Exporter> will no longer remove a subroutine that the |
168 | exporting package re-exports. Moose re-exports the Carp::confess |
169 | function, among others. The reasoning is that we cannot know whether |
170 | you have also explicitly imported those functions for your own use, so |
171 | we err on the safe side and always keep them. |
600f7f85 |
172 | |
173 | =head1 Version 0.56 |
174 | |
0f13f53c |
175 | C<Moose::init_meta> should now be called as a method. |
600f7f85 |
176 | |
0f13f53c |
177 | New modules for extension writers, L<Moose::Exporter> and |
178 | L<Moose::Util::MetaRole>. |
600f7f85 |
179 | |
180 | =head1 Version 0.55_01 |
181 | |
182 | Implemented metaclass traits (and wrote a recipe for it): |
183 | |
184 | use Moose -traits => 'Foo' |
185 | |
186 | This should make writing small Moose extensions a little |
187 | easier. |
188 | |
189 | =head1 Version 0.55 |
190 | |
191 | Fixed C<coerce> to accept anon types just like C<subtype> can. |
192 | So that you can do: |
193 | |
194 | coerce $some_anon_type => from 'Str' => via { ... }; |
195 | |
196 | =head1 Version 0.51 |
197 | |
52da380a |
198 | Added C<BUILDARGS>, a new step in C<< Moose::Object->new() >>. |
600f7f85 |
199 | |
200 | =head1 Version 0.49 |
201 | |
0f13f53c |
202 | Fixed how the C<< is => (ro|rw) >> works with custom defined |
203 | C<reader>, C<writer> and C<accessor> options. See the below table for |
600f7f85 |
204 | details: |
205 | |
206 | is => ro, writer => _foo # turns into (reader => foo, writer => _foo) |
207 | is => rw, writer => _foo # turns into (reader => foo, writer => _foo) |
208 | is => rw, accessor => _foo # turns into (accessor => _foo) |
209 | is => ro, accessor => _foo # error, accesor is rw |
210 | |
211 | =head1 Version 0.45 |
212 | |
0f13f53c |
213 | The C<before/around/after> method modifiers now support regexp |
214 | matching of method names. NOTE: this only works for classes, it is |
215 | currently not supported in roles, but, ... patches welcome. |
600f7f85 |
216 | |
0f13f53c |
217 | The C<has> keyword for roles now accepts the same array ref form that |
218 | L<Moose>.pm does for classes. |
600f7f85 |
219 | |
0f13f53c |
220 | A trigger on a read-only attribute is no longer an error, as it's |
221 | useful to trigger off of the constructor. |
600f7f85 |
222 | |
0f13f53c |
223 | Subtypes of parameterizable types now are parameterizable types |
224 | themselves. |
600f7f85 |
225 | |
226 | =head1 Version 0.44 |
227 | |
0f13f53c |
228 | Fixed issue where C<DEMOLISHALL> was eating the value in C<$@>, and so |
229 | not working correctly. It still kind of eats them, but so does vanilla |
230 | perl. |
600f7f85 |
231 | |
232 | =head1 Version 0.41 |
233 | |
0f13f53c |
234 | Inherited attributes may now be extended without restriction on the |
600f7f85 |
235 | type ('isa', 'does'). |
236 | |
0f13f53c |
237 | The entire set of Moose::Meta::TypeConstraint::* classes were |
238 | refactored in this release. If you were relying on their internals you |
239 | should test your code carefully. |
600f7f85 |
240 | |
241 | =head1 Version 0.40 |
242 | |
0f13f53c |
243 | Documenting the use of '+name' with attributes that come from recently |
244 | composed roles. It makes sense, people are using it, and so why not |
245 | just officially support it. |
600f7f85 |
246 | |
0f13f53c |
247 | The C<< Moose::Meta::Class->create >> method now supports roles. |
600f7f85 |
248 | |
0f13f53c |
249 | It is now possible to make anononymous enum types by passing C<enum> |
250 | an array reference instead of the C<< enum $name => @values >>. |
600f7f85 |
251 | |
252 | =head1 Version 0.37 |
253 | |
0f13f53c |
254 | Added the C<make_immutable> keyword as a shortcut to calling |
255 | C<make_immutable> on the meta object. This eventually got removed! |
600f7f85 |
256 | |
0f13f53c |
257 | Made C<< init_arg => undef >> work in Moose. This means "do not accept |
600f7f85 |
258 | a constructor parameter for this attribute". |
259 | |
0f13f53c |
260 | Type errors now use the provided message. Prior to this release they |
261 | didn't. |
600f7f85 |
262 | |
263 | =head1 Version 0.34 |
264 | |
265 | Moose is now a postmodern object system :) |
266 | |
0f13f53c |
267 | The Role system was completely refactored. It is 100% backwards |
268 | compat, but the internals were totally changed. If you relied on the |
269 | internals then you are advised to test carefully. |
600f7f85 |
270 | |
271 | Added method exclusion and aliasing for Roles in this release. |
272 | |
0f13f53c |
273 | Added the L<Moose::Util::TypeConstraints::OptimizedConstraints> |
274 | module. |
600f7f85 |
275 | |
0f13f53c |
276 | Passing a list of values to an accessor (which is only expecting one |
277 | value) used to be silently ignored, now it throws an error. |
600f7f85 |
278 | |
279 | =head1 Version 0.26 |
280 | |
0f13f53c |
281 | Added parameterized types and did a pretty heavy refactoring of the |
282 | type constraint system. |
600f7f85 |
283 | |
0f13f53c |
284 | Better framework extendability and better support for "making your own |
285 | Moose". |
600f7f85 |
286 | |
287 | =head1 Version 0.25 or before |
288 | |
0f13f53c |
289 | Honestly, you shouldn't be using versions of Moose that are this old, |
290 | so many bug fixes and speed improvements have been made you would be |
291 | crazy to not upgrade. |
600f7f85 |
292 | |
0f13f53c |
293 | Also, I am tired of going through the Changelog so I am stopping here, |
294 | if anyone would like to continue this please feel free. |
600f7f85 |
295 | |
296 | =head1 AUTHOR |
297 | |
298 | Stevan Little E<lt>stevan@iinteractive.comE<gt> |
299 | |
300 | =head1 COPYRIGHT AND LICENSE |
301 | |
302 | Copyright 2009 by Infinity Interactive, Inc. |
303 | |
304 | L<http://www.iinteractive.com> |
305 | |
306 | This library is free software; you can redistribute it and/or modify |
307 | it under the same terms as Perl itself. |
308 | |
0f13f53c |
309 | =cut |