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