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