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