Make our Makefile.PL work with recent versions of Module::Install.
[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
12885414 19=head1 1.00
20
21=over 4
22
23=item Moose::Meta::Attribute::Native::Trait::Code no longer creates reader methods by default
24
25Earlier versions of L<Moose::Meta::Attribute::Native::Trait::Code> created
26read-only accessors for the attributes it's been applied to, even if you didn't
27ask for it with C<< is => 'ro' >>. This incorrect behaviour has now been fixed.
28
29=back
30
775666aa 31=head1 0.95
32
33=over 4
34
35=item Moose::Util add_method_modifier behavior
36
37add_method_modifier (and subsequently the sugar functions Moose::before,
38Moose::after, and Moose::around) can now accept arrayrefs, with the same
39behavior as lists. Types other than arrayref and regexp result in an error.
40
41=back
42
5b7b27e2 43=head1 0.93_01 and 0.94
44
45=over 4
46
f785aad8 47=item Moose::Util::MetaRole API has changed
48
49The C<apply_metaclass_roles> function is now called C<apply_metaroles>. The
50way arguments are supplied has been changed to force you to distinguish
51between metaroles applied to L<Moose::Meta::Class> (and helpers) versus
52L<Moose::Meta::Role>.
53
54The old API still works, but will warn in a future release, and eventually be
55removed.
56
57=item Moose::Meta::Role has real attributes
58
59The attributes returned by L<Moose::Meta::Role> are now instances of the
60L<Moose::Meta::Role::Attribute> class, instead of bare hash references.
61
5b7b27e2 62=item "no Moose" now removes C<blessed> and C<confess>
63
64Moose is now smart enough to know exactly what it exported, even when it
65re-exports functions from other packages. When you unimport Moose, it will
66remove these functions from your namespace unless you I<also> imported them
67directly from their respective packages.
68
69If you have a C<no Moose> in your code I<before> you call C<blessed> or
70C<confess>, your code will break. You can either move the C<no Moose> call
71later in your code, or explicitly import the relevant functions from the
72packages that provide them.
73
74=item L<Moose::Exporter> is smarter about unimporting re-exports
75
76The change above comes from a general improvement to L<Moose::Exporter>. It
77will now unimport any function it exports, even if that function is a
78re-export from another package.
79
f427b505 80=item Attributes in roles can no longer override class attributes with "+foo"
81
82Previously, this worked more or less accidentally, because role attributes
83weren't objects. This was never documented, but a few MooseX modules took
84advantage of this.
85
86=item The composition_class_roles attribute in L<Moose::Meta::Role> is now a method
87
88This was done to make it possible for roles to alter the the list of
89composition class roles by applying a method modifiers. Previously, this was
90an attribute and MooseX modules override it. Since that no longer works, this
91was made a method.
92
93This I<should> be an attribute, so this may switch back to being an attribute
94in the future if we can figure out how to make this work.
95
5b7b27e2 96=back
97
c378a61a 98=head1 0.93
99
100=over 4
101
102=item Calling $object->new() is no longer deprecated
103
76c89056 104We decided to undeprecate this. Now it just works.
c378a61a 105
d99ec58b 106=item Both C<get_method_map> and C<get_attribute_map> is deprecated
fa6da135 107
d99ec58b 108These metaclass methods were never meant to be public, and they are both now
109deprecated. The work around if you still need the functionality they provided
110is to iterate over the list of names manually.
fa6da135 111
112 my %fields = map { $_ => $meta->get_attribute($_) } $meta->get_attribute_list;
113
d99ec58b 114This was actually a change in L<Class::MOP>, but this version of Moose
115requires a version of L<Class::MOP> that includes said change.
116
c378a61a 117=back
118
b98ef150 119=head1 0.90
871f82f8 120
c985327a 121=over 4
122
93ef4ba1 123=item Added Native delegation for Code refs
124
125See L<Moose::Meta::Attribute::Native::Trait::Code> for details.
126
3f5ff7d0 127=item Calling $object->new() is deprecated
128
129Moose has long supported this, but it's never really been documented, and we
130don't think this is a good practice. If you want to construct an object from
131an existing object, you should provide some sort of alternate constructor like
132C<< $object->clone >>.
133
134Calling C<< $object->new >> now issues a warning, and will be an error in a
135future release.
136
19e60fdd 137=item Moose no longer warns if you call C<make_immutable> for a class with mutable ancestors
138
139While in theory this is a good thing to warn about, we found so many
140exceptions to this that doing this properly became quite problematic.
141
93ef4ba1 142=back
143
144=head1 Version 0.89_02
145
146=over 4
4f0d4488 147
871f82f8 148=item New Native delegation methods from L<List::Util> and L<List::MoreUtils>
149
150In particular, we now have C<reduce>, C<shuffle>, C<uniq>, and C<natatime>.
151
3023f1e4 152=item The Moose::Exporter with_caller feature is now deprecated
153
154Use C<with_meta> instead. The C<with_caller> option will start warning in a
155future release.
156
9b9a5a07 157=item Moose now warns if you call C<make_immutable> for a class with mutable ancestors
158
159This is dangerous because modifying a class after a subclass has been
90b20bd6 160immutabilized will lead to incorrect results in the subclass, due to inlining,
9b9a5a07 161caching, etc. This occasionally happens accidentally, when a class loads one
162of its subclasses in the middle of its class definition, so pointing out that
163this may cause issues should be helpful. Metaclasses (classes that inherit
164from L<Class::MOP::Object>) are currently exempt from this check, since at the
90b20bd6 165moment we aren't very consistent about which metaclasses we immutabilize.
9b9a5a07 166
bce5d4a5 167=item C<enum> and C<duck_type> now take arrayrefs for all forms
168
169Previously, calling these functions with a list would take the first element of
170the list as the type constraint name, and use the remainder as the enum values
171or method names. This makes the interface inconsistent with the anon-type forms
172of these functions (which must take an arrayref), and a free-form list where
173the first value is sometimes special is hard to validate (and harder to give
174reasonable error messages for). These functions have been changed to take
175arrayrefs in all their forms - so, C<< enum 'My::Type' => [qw(foo bar)] >> is
176now the preferred way to create an enum type constraint. The old syntax still
177works for now, but it will hopefully be deprecated and removed in a future
178release.
179
871f82f8 180=back
181
4ada9618 182=head1 Version 0.89_01
a3d98218 183
af44c00c 184L<Moose::Meta::Attribute::Native> has been moved into the Moose core from
a3d98218 185L<MooseX::AttributeHelpers>. Major changes include:
186
ebaaa391 187=over 4
a3d98218 188
189=item C<traits>, not C<metaclass>
190
93ced2bd 191Method providers are only available via traits.
a3d98218 192
193=item C<handles>, not C<provides> or C<curries>
194
93ced2bd 195The C<provides> syntax was like core Moose C<< handles => HASHREF >>
196syntax, but with the keys and values reversed. This was confusing,
197and AttributeHelpers now uses C<< handles => HASHREF >> in a way that
198should be intuitive to anyone already familiar with how it is used for
199other attributes.
a3d98218 200
93ced2bd 201The C<curries> functionality provided by AttributeHelpers has been
202generalized to apply to all cases of C<< handles => HASHREF >>, though
203not every piece of functionality has been ported (currying with a
204CODEREF is not supported).
a3d98218 205
1853a27e 206=item C<empty> is now C<is_empty>, and means empty, not non-empty
af44c00c 207
208Previously, the C<empty> method provided by Arrays and Hashes returned true if
209the attribute was B<not> empty (no elements). Now it returns true if the
1853a27e 210attribute B<is> empty. It was also renamed to C<is_empty>, to reflect this.
af44c00c 211
9a14bd29 212=item C<find> was renamed to C<first>, and C<first> and C<last> were removed
28b96142 213
214L<List::Util> refers to the functionality that we used to provide under C<find>
215as L<first|List::Util/first>, so that will likely be more familiar (and will
9a14bd29 216fit in better if we decide to add more List::Util functions). C<first> and
217C<last> were removed, since their functionality is easily duplicated with
218curries of C<get>.
28b96142 219
220=item Helpers that take a coderef of one argument now use C<$_>
221
222Subroutines passed as the first argument to C<first>, C<map>, and C<grep> now
223receive their argument in C<$_> rather than as a parameter to the subroutine.
224Helpers that take a coderef of two or more arguments remain using the argument
225list (there are technical limitations to using C<$a> and C<$b> like C<sort>
226does).
227
af44c00c 228See L<Moose::Meta::Attribute::Native> for the new documentation.
a3d98218 229
ebaaa391 230=back
231
85e2b15a 232The C<alias> and C<excludes> role parameters have been renamed to C<-alias>
233and C<-excludes>. The old names still work, but new code should use the new
234names, and eventually the old ones will be deprecated and removed.
235
4ada9618 236=head1 Version 0.89
237
8a8856de 238C<< use Moose -metaclass => 'Foo' >> now does alias resolution, just like
239C<-traits> (and the C<metaclass> and C<traits> options to C<has>).
240
27f2f43f 241Added two functions C<meta_class_alias> and C<meta_attribute_alias> to
242L<Moose::Util>, to simplify aliasing metaclasses and metatraits. This is
243a wrapper around the old
244
245 package Moose::Meta::Class::Custom::Trait::FooTrait;
246 sub register_implementation { 'My::Meta::Trait' }
247
248way of doing this.
249
4831e2de 250=head1 Version 0.84
251
9f52cce5 252When an attribute generates I<no> accessors, we now warn. This is to help
253users who forget the C<is> option. If you really do not want any accessors,
3de02fd8 254you can use C<< is => 'bare' >>. You can maintain back compat with older
255versions of Moose by using something like:
256
257 ($Moose::VERSION >= 0.84 ? is => 'bare' : ())
9f52cce5 258
259When an accessor overwrites an existing method, we now warn. To work around
260this warning (if you really must have this behavior), you can explicitly
261remove the method before creating it as an accessor:
262
263 sub foo {}
264
265 __PACKAGE__->meta->remove_method('foo');
266
267 has foo => (
268 is => 'ro',
269 );
270
271When an unknown option is passed to C<has>, we now warn. You can silence
272the warning by fixing your code. :)
273
4831e2de 274The C<Role> type has been deprecated. On its own, it was useless,
275since it just checked C<< $object->can('does') >>. If you were using
276it as a parent type, just call C<role_type('Role::Name')> to create an
277appropriate type instead.
278
7d6b451f 279=head1 Version 0.78
280
281C<use Moose::Exporter;> now imports C<strict> and C<warnings> into packages
282that use it.
283
c3fdacda 284=head1 Version 0.77
285
286C<DEMOLISHALL> and C<DEMOLISH> now receive an argument indicating whether or
287not we are in global destruction.
288
00c61603 289=head1 Version 0.76
290
9f0b3b64 291Type constraints no longer run coercions for a value that already matches the
292constraint. This may affect some (arguably buggy) edge case coercions that
293rely on side effects in the C<via> clause.
294
f869fc4a 295=head1 Version 0.75
296
297L<Moose::Exporter> now accepts the C<-metaclass> option for easily
298overriding the metaclass (without L<metaclass>). This works for classes
299and roles.
300
39ab7714 301=head1 Version 0.74
302
85cf0647 303Added a C<duck_type> sugar function to L<Moose::Util::TypeConstraints>
304to make integration with non-Moose classes easier. It simply checks if
305C<< $obj->can() >> a list of methods.
39ab7714 306
612fd754 307A number of methods (mostly inherited from L<Class::MOP>) have been
308renamed with a leading underscore to indicate their internal-ness. The
309old method names will still work for a while, but will warn that the
310method has been renamed. In a few cases, the method will be removed
311entirely in the future. This may affect MooseX authors who were using
312these methods.
313
600f7f85 314=head1 Version 0.73
315
0f13f53c 316Calling C<subtype> with a name as the only argument now throws an
600f7f85 317exception. If you want an anonymous subtype do:
318
319 my $subtype = subtype as 'Foo';
320
0f13f53c 321This is related to the changes in version 0.71_01.
600f7f85 322
501db4e6 323The C<is_needed> method in L<Moose::Meta::Method::Destructor> is now
324only usable as a class method. Previously, it worked as a class or
325object method, with a different internal implementation for each
326version.
327
328The internals of making a class immutable changed a lot in Class::MOP
3290.78_02, and Moose's internals have changed along with it. The
330external C<< $metaclass->make_immutable >> method still works the same
331way.
332
600f7f85 333=head1 Version 0.72
334
0f13f53c 335A mutable class accepted C<< Foo->new(undef) >> without complaint,
336while an immutable class would blow up with an unhelpful error. Now,
337in both cases we throw a helpful error instead.
600f7f85 338
0f13f53c 339This "feature" was originally added to allow for cases such as this:
600f7f85 340
341 my $args;
0f13f53c 342
343 if ( something() ) {
344 $args = {...};
600f7f85 345 }
0f13f53c 346
600f7f85 347 return My::Class->new($args);
348
0f13f53c 349But we decided this is a bad idea and a little too magical, because it
350can easily mask real errors.
600f7f85 351
352=head1 Version 0.71_01
353
0f13f53c 354Calling C<type> or C<subtype> without the sugar helpers (C<as>,
355C<where>, C<message>) is now deprecated.
356
357As a side effect, this meant we ended up using Perl prototypes on
358C<as>, and code like this will no longer work:
600f7f85 359
360 use Moose::Util::TypeConstraints;
361 use Declare::Constraints::Simple -All;
0f13f53c 362
363 subtype 'ArrayOfInts'
600f7f85 364 => as 'ArrayRef'
365 => IsArrayRef(IsInt);
366
367Instead it must be changed to this:
368
0f13f53c 369 subtype(
370 'ArrayOfInts' => {
371 as => 'ArrayRef',
372 where => IsArrayRef(IsInt)
373 }
600f7f85 374 );
375
0f13f53c 376If you want to maintain backwards compat with older versions of Moose,
377you must explicitly test Moose's C<VERSION>:
600f7f85 378
0f13f53c 379 if ( Moose->VERSION < 0.71_01 ) {
380 subtype 'ArrayOfInts'
600f7f85 381 => as 'ArrayRef'
382 => IsArrayRef(IsInt);
383 }
384 else {
0f13f53c 385 subtype(
386 'ArrayOfInts' => {
387 as => 'ArrayRef',
388 where => IsArrayRef(IsInt)
389 }
600f7f85 390 );
391 }
392
393=head1 Version 0.70
394
0f13f53c 395We no longer pass the meta-attribute object as a final argument to
396triggers. This actually changed for inlined code a while back, but the
397non-inlined version and the docs were still out of date.
398
399If by some chance you actually used this feature, the workaround is
400simple. You fetch the attribute object from out of the C<$self>
401that is passed as the first argument to trigger, like so:
402
403 has 'foo' => (
404 is => 'ro',
405 isa => 'Any',
406 trigger => sub {
407 my ( $self, $value ) = @_;
408 my $attr = $self->meta->find_attribute_by_name('foo');
409
410 # ...
411 }
412 );
600f7f85 413
414=head1 Version 0.66
415
0f13f53c 416If you created a subtype and passed a parent that Moose didn't know
417about, it simply ignored the parent. Now it automatically creates the
418parent as a class type. This may not be what you want, but is less
419broken than before.
600f7f85 420
0f13f53c 421You could declare a name with subtype such as "Foo!Bar". Moose would
422accept this allowed, but if you used it in a parameterized type such
423as "ArrayRef[Foo!Bar]" it wouldn't work. We now do some vetting on
424names created via the sugar functions, so that they can only contain
425alphanumerics, ":", and ".".
600f7f85 426
427=head1 Version 0.65
428
429Methods created via an attribute can now fulfill a C<requires>
0f13f53c 430declaration for a role. Honestly we don't know why Stevan didn't make
431this work originally, he was just insane or something.
600f7f85 432
0f13f53c 433Stack traces from inlined code will now report the line and file as
434being in your class, as opposed to in Moose guts.
600f7f85 435
436=head1 Version 0.62_02
437
0f13f53c 438When a class does not provide all of a role's required methods, the
439error thrown now mentions all of the missing methods, as opposed to
440just the first missing method.
600f7f85 441
0f13f53c 442Moose will no longer inline a constructor for your class unless it
5e26e3f2 443inherits its constructor from Moose::Object, and will warn when it
444doesn't inline. If you want to force inlining anyway, pass
b84f64da 445C<< replace_constructor => 1 >> to C<make_immutable>.
0f13f53c 446
447If you want to get rid of the warning, pass C<< inline_constructor =>
fbf7ba85 4480 >>.
600f7f85 449
450=head1 Version 0.62
451
0f13f53c 452Removed the (deprecated) C<make_immutable> keyword.
600f7f85 453
454Removing an attribute from a class now also removes delegation
0f13f53c 455(C<handles>) methods installed for that attribute. This is correct
600f7f85 456behavior, but if you were wrongly relying on it you might get bit.
457
458=head1 Version 0.58
459
0f13f53c 460Roles now add methods by calling C<add_method>, not
461C<alias_method>. They make sure to always provide a method object,
462which will be cloned internally. This means that it is now possible to
463track the source of a method provided by a role, and even follow its
464history through intermediate roles. This means that methods added by
465a role now show up when looking at a class's method list/map.
466
467Parameter and Union args are now sorted, this makes Int|Str the same
468constraint as Str|Int. Also, incoming type constraint strings are
469normalized to remove all whitespace differences. This is mostly for
470internals and should not affect outside code.
471
472L<Moose::Exporter> will no longer remove a subroutine that the
473exporting package re-exports. Moose re-exports the Carp::confess
474function, among others. The reasoning is that we cannot know whether
475you have also explicitly imported those functions for your own use, so
476we err on the safe side and always keep them.
600f7f85 477
478=head1 Version 0.56
479
0f13f53c 480C<Moose::init_meta> should now be called as a method.
600f7f85 481
0f13f53c 482New modules for extension writers, L<Moose::Exporter> and
483L<Moose::Util::MetaRole>.
600f7f85 484
485=head1 Version 0.55_01
486
487Implemented metaclass traits (and wrote a recipe for it):
488
489 use Moose -traits => 'Foo'
490
491This should make writing small Moose extensions a little
492easier.
493
494=head1 Version 0.55
495
496Fixed C<coerce> to accept anon types just like C<subtype> can.
497So that you can do:
498
499 coerce $some_anon_type => from 'Str' => via { ... };
500
501=head1 Version 0.51
502
52da380a 503Added C<BUILDARGS>, a new step in C<< Moose::Object->new() >>.
600f7f85 504
505=head1 Version 0.49
506
0f13f53c 507Fixed how the C<< is => (ro|rw) >> works with custom defined
508C<reader>, C<writer> and C<accessor> options. See the below table for
600f7f85 509details:
510
511 is => ro, writer => _foo # turns into (reader => foo, writer => _foo)
512 is => rw, writer => _foo # turns into (reader => foo, writer => _foo)
513 is => rw, accessor => _foo # turns into (accessor => _foo)
514 is => ro, accessor => _foo # error, accesor is rw
515
516=head1 Version 0.45
517
0f13f53c 518The C<before/around/after> method modifiers now support regexp
519matching of method names. NOTE: this only works for classes, it is
520currently not supported in roles, but, ... patches welcome.
600f7f85 521
0f13f53c 522The C<has> keyword for roles now accepts the same array ref form that
523L<Moose>.pm does for classes.
600f7f85 524
0f13f53c 525A trigger on a read-only attribute is no longer an error, as it's
526useful to trigger off of the constructor.
600f7f85 527
0f13f53c 528Subtypes of parameterizable types now are parameterizable types
529themselves.
600f7f85 530
531=head1 Version 0.44
532
0f13f53c 533Fixed issue where C<DEMOLISHALL> was eating the value in C<$@>, and so
534not working correctly. It still kind of eats them, but so does vanilla
535perl.
600f7f85 536
537=head1 Version 0.41
538
0f13f53c 539Inherited attributes may now be extended without restriction on the
600f7f85 540type ('isa', 'does').
541
0f13f53c 542The entire set of Moose::Meta::TypeConstraint::* classes were
543refactored in this release. If you were relying on their internals you
544should test your code carefully.
600f7f85 545
546=head1 Version 0.40
547
0f13f53c 548Documenting the use of '+name' with attributes that come from recently
549composed roles. It makes sense, people are using it, and so why not
550just officially support it.
600f7f85 551
0f13f53c 552The C<< Moose::Meta::Class->create >> method now supports roles.
600f7f85 553
86b96832 554It is now possible to make anonymous enum types by passing C<enum> an
555array reference instead of the C<< enum $name => @values >>.
600f7f85 556
557=head1 Version 0.37
558
0f13f53c 559Added the C<make_immutable> keyword as a shortcut to calling
560C<make_immutable> on the meta object. This eventually got removed!
600f7f85 561
0f13f53c 562Made C<< init_arg => undef >> work in Moose. This means "do not accept
600f7f85 563a constructor parameter for this attribute".
564
0f13f53c 565Type errors now use the provided message. Prior to this release they
566didn't.
600f7f85 567
568=head1 Version 0.34
569
570Moose is now a postmodern object system :)
571
0f13f53c 572The Role system was completely refactored. It is 100% backwards
573compat, but the internals were totally changed. If you relied on the
574internals then you are advised to test carefully.
600f7f85 575
576Added method exclusion and aliasing for Roles in this release.
577
0f13f53c 578Added the L<Moose::Util::TypeConstraints::OptimizedConstraints>
579module.
600f7f85 580
0f13f53c 581Passing a list of values to an accessor (which is only expecting one
582value) used to be silently ignored, now it throws an error.
600f7f85 583
584=head1 Version 0.26
585
0f13f53c 586Added parameterized types and did a pretty heavy refactoring of the
587type constraint system.
600f7f85 588
0f13f53c 589Better framework extendability and better support for "making your own
590Moose".
600f7f85 591
592=head1 Version 0.25 or before
593
0f13f53c 594Honestly, you shouldn't be using versions of Moose that are this old,
595so many bug fixes and speed improvements have been made you would be
596crazy to not upgrade.
600f7f85 597
0f13f53c 598Also, I am tired of going through the Changelog so I am stopping here,
599if anyone would like to continue this please feel free.
600f7f85 600
601=head1 AUTHOR
602
603Stevan Little E<lt>stevan@iinteractive.comE<gt>
604
605=head1 COPYRIGHT AND LICENSE
606
607Copyright 2009 by Infinity Interactive, Inc.
608
609L<http://www.iinteractive.com>
610
611This library is free software; you can redistribute it and/or modify
612it under the same terms as Perl itself.
613
0f13f53c 614=cut