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