comment about why we explicitly clear @ISA
[gitmo/Moose.git] / lib / Moose / Manual / Delta.pod
CommitLineData
daa0fd7d 1package Moose::Manual::Delta;
2
3# ABSTRACT: Important Changes in Moose
600f7f85 4
daa0fd7d 5__END__
600f7f85 6
daa0fd7d 7=pod
600f7f85 8
9=head1 DESCRIPTION
10
0f13f53c 11This documents any important or noteworthy changes in Moose, with a
bc68d61c 12focus on things that affect backwards compatibility. This does duplicate data
13from the F<Changes> file, but aims to provide more details and when possible
14workarounds.
0f13f53c 15
16Besides helping keep up with changes, you can also use this document
17for finding the lowest version of Moose that supported a given
18feature. If you encounter a problem and have a solution but don't see
19it documented here, or think we missed an important feature, please
20send us a patch.
600f7f85 21
5e116ff5 22=head1 2.0500
23
24=item All the Cookbook recipes have been renamed
25
26We've given them all descriptive names, rather than numbers. This makes it
27easier to talk about them, and eliminates the need to renumber recipes in
28order to reorder them or delete one.
29
b1ea210b 30=head1 2.0300
31
32=over 4
33
b5e5aaef 34=item The parent of a union type is its components' nearest common ancestor
35
36Previously, union types considered all of their component types their parent
5d3a1dd1 37types. This was incorrect because parent types are defined as types that must
38be satisfied in order for the child type to be satisfied, but in a union,
39validating as any parent type will validate against the entire union. This has
40been changed to find the nearest common ancestor for all of its components. For
41example, a union of "Int|ArrayRef[Int]" now has a parent of "Defined".
b5e5aaef 42
3d4960c3 43=item Union types consider all members in the C<is_subtype_of> and C<is_a_type_of> methods
44
5d3a1dd1 45Previously, a union type would report itself as being of a subtype of a type if
46I<any> of its member types were subtypes of that type. This was incorrect
47because any value that passes a subtype constraint must also pass a parent
48constraint. This has changed so that I<all> of its member types must be a
49subtype of the specified type.
3d4960c3 50
ddbae99e 51=item Enum types now work with just one value
52
53Previously, an C<enum> type needed to have two or more values. Nobody knew
54why, so we fixed it.
55
04dacf19 56=item Methods defined in UNIVERSAL now appear in the MOP
57
58Any method introspection methods that look at methods from parent classes now
59find methods defined in UNIVERSAL. This includes methods like C<<
60$class->get_all_methods >> and C<< $class->find_method_by_name >>.
61
62This also means that you can now apply method modifiers to these methods.
63
b1ea210b 64=item Hand-optimized type constraint code causes a deprecation warning
65
66If you provide an optimized sub ref for a type constraint, this now causes a
67deprecation warning. Typically, this comes from passing an C<optimize_as>
68parameter to C<subtype>, but it could also happen if you create a
69L<Moose::Meta::TypeConstraint> object directly.
70
71Use the inlining feature (C<inline_as>) added in 2.0100 instead.
72
2f124a3e 73=item C<Class::Load::load_class> and C<is_class_loaded> have been removed
74
75The C<Class::MOP::load_class> and C<Class::MOP::is_class_loaded> subroutines
76are no longer documented, and will cause a deprecation warning in the
77future. Moose now uses L<Class::Load> to provide this functionality, and you
78should do so as well.
79
2aae65a7 80=back
81
82=head1 2.0205
83
84=over 4
85
7d7d2bef 86=item Array and Hash native traits provide a C<shallow_clone> method
87
88The Array and Hash native traits now provide a "shallow_clone" method, which
89will return a reference to a new container with the same contents as the
90attribute's reference.
91
b1ea210b 92=back
93
63cbe0f6 94=head1 2.0100
7142d232 95
96=over 4
97
98=item Hand-optimized type constraint code is deprecated in favor of inlining
99
100Moose allows you to provide a hand-optimized version of a type constraint's
101subroutine reference. This version allows type constraints to generate inline
102code, and you should use this inlining instead of providing a hand-optimized
103subroutine reference.
104
105This affects the C<optimize_as> sub exported by
106L<Moose::Util::TypeConstraints>. Use C<inline_as> instead.
107
3bd65f1b 108This will start warning in the 2.0300 release.
7142d232 109
1c3b1ed1 110=back
111
50698b2a 112=head1 2.0002
113
114=over 4
115
116=item More useful type constraint error messages
117
118If you have L<Devel::PartialDump> version 0.14 or higher installed, Moose's
119type constraint error messages will use it to display the invalid value, rather
120than just displaying it directly. This will generally be much more useful. For
121instance, instead of this:
122
123 Attribute (foo) does not pass the type constraint because: Validation failed for 'ArrayRef[Int]' with value ARRAY(0x275eed8)
124
125the error message will instead look like
126
127 Attribute (foo) does not pass the type constraint because: Validation failed for 'ArrayRef[Int]' with value [ "a" ]
128
129Note that L<Devel::PartialDump> can't be made a direct dependency at the
130moment, because it uses Moose itself, but we're considering options to make
131this easier.
132
133=back
134
6adb18d8 135=head1 2.0000
13eb2af6 136
137=over 4
138
139=item Roles have their own default attribute metaclass
140
141Previously, when a role was applied to a class, it would use the attribute
142metaclass defined in the class when copying over the attributes in the role.
143This was wrong, because for instance, using L<MooseX::FollowPBP> in the class
144would end up renaming all of the accessors generated by the role, some of which
145may be being called in the role, causing it to break. Roles now keep track of
146their own attribute metaclass to use by default when being applied to a class
147(defaulting to Moose::Meta::Attribute). This is modifiable using
148L<Moose::Util::MetaRole> by passing the C<applied_attribute> key to the
149C<role_metaroles> option, as in:
150
151 Moose::Util::MetaRole::apply_metaroles(
152 for => __PACKAGE__,
153 class_metaroles => {
154 attribute => ['My::Meta::Role::Attribute'],
155 },
156 role_metaroles => {
157 applied_attribute => ['My::Meta::Role::Attribute'],
158 },
159 );
160
6adb18d8 161=item Class::MOP has been folded into the Moose dist
162
163Moose and Class::MOP are tightly related enough that they have always had to be
164kept pretty closely in step in terms of versions. Making them into a single
165dist should simplify the upgrade process for users, as it should no longer be
166possible to upgrade one without the other and potentially cause issues. No
167functionality has changed, and this should be entirely transparent.
168
169=item Moose's conflict checking is more robust and useful
170
171There are two parts to this. The most useful one right now is that Moose will
172ship with a C<moose-outdated> script, which can be run at any point to list the
173modules which are installed that conflict with the installed version of Moose.
174After upgrading Moose, running C<moose-outdated | cpanm> should be sufficient
175to ensure that all of the Moose extensions you use will continue to work.
176
177The other part is that Moose's C<META.json> file will also specify the
1b387fd1 178conflicts under the C<x_conflicts> key. We are working with the Perl tool chain
6adb18d8 179developers to try to get conflicts support added to CPAN clients, and if/when
180that happens, the metadata already exists, and so the conflict checking will
181become automatic.
182
14bda293 183=item Most deprecated APIs/features are slated for removal in Moose 2.0200
184
185Most of the deprecated APIs and features in Moose will start throwing an error
186in Moose 2.0200. Some of the features will go away entirely, and some will
187simply throw an error.
188
189The things on the chopping block are:
190
191=over 8
192
193=item * Old public methods in Class::MOP and Moose
194
195This includes things like C<< Class::MOP::Class->get_attribute_map >>, C<<
196Class::MOP::Class->construct_instance >>, and many others. These were
bc68d61c 197deprecated in L<Class::MOP> 0.80_01, released on April 5, 2009.
14bda293 198
199These methods will be removed entirely in Moose 2.0200.
200
201=item * Old public functions in Class::MOP
202
203This include C<Class::MOP::subname>, C<Class::MOP::in_global_destruction>, and
204the C<Class::MOP::HAS_ISAREV> constant. The first two were deprecated in 0.84,
205and the last in 0.80. Class::MOP 0.84 was released on May 12, 2009.
206
207These functions will be removed entirely in Moose 2.0200.
208
209=item * The C<alias> and C<excludes> option for role composition
210
211These were renamed to C<-alias> and C<-excludes> in Moose 0.89, released on
212August 13, 2009.
213
214Passing these will throw an error in Moose 2.0200.
215
216=item * The old L<Moose::Util::MetaRole> API
217
218This include the C<apply_metaclass_roles()> function, as well as passing the
219C<for_class> or any key ending in C<_roles> to C<apply_metaroles()>. This was
220deprecated in Moose 0.93_01, released on January 4, 2010.
221
222These will all throw an error in Moose 2.0200.
223
224=item * Passing plain lists to C<type()> or C<subtype()>
225
226The old API for these functions allowed you to pass a plain list of parameter,
227rather than a list of hash references (which is what C<as()>, C<where>,
228etc. return). This was deprecated in Moose 0.71_01, released on February 22,
2292009.
230
231This will throw an error in Moose 2.0200.
232
233=item * The Role subtype
234
235This subtype was deprecated in Moose 0.84, released on June 26, 2009.
236
237This will be removed entirely in Moose 2.0200.
238
239=back
240
8ab76136 241=back
242
243=head1 1.21
244
245=over 4
246
d4985a66 247=item * New release policy
248
249As of the 2.0 release, Moose now has an official release and support policy,
250documented in L<Moose::Manual::Support>. All API changes will now go through a
251deprecation cycle of at least one year, after which the deprecated API can be
252removed. Deprecations and removals will only happen in major releases.
253
9db7bbff 254In between major releases, we will still make minor releases to add new
d4985a66 255features, fix bugs, update documentation, etc.
256
13eb2af6 257=back
258
9796131f 259=head1 1.16
260
261=over 4
262
263=item Configurable stacktraces
264
265Classes which use the L<Moose::Error::Default> error class can now have
266stacktraces disabled by setting the C<MOOSE_ERROR_STYLE> env var to C<croak>.
267This is experimental, fairly incomplete, and won't work in all cases (because
268Moose's error system in general is all of these things), but this should allow
269for reducing at least some of the verbosity in most cases.
270
271=back
272
adff0aa1 273=head1 1.15
d6ce97b9 274
275=over 4
276
adff0aa1 277=item Native Delegations
d6ce97b9 278
279In previous versions of Moose, the Native delegations were created as
280closures. The generated code was often quite slow compared to doing the same
281thing by hand. For example, the Array's push delegation ended up doing
282something like this:
283
284 push @{ $self->$reader() }, @_;
285
286If the attribute was created without a reader, the C<$reader> sub reference
287followed a very slow code path. Even with a reader, this is still slower than
288it needs to be.
289
290Native delegations are now generated as inline code, just like other
291accessors, so we can access the slot directly.
292
293In addition, native traits now do proper constraint checking in all cases. In
294particular, constraint checking has been improved for array and hash
295references. Previously, only the I<contained> type (the C<Str> in
296C<HashRef[Str]>) would be checked when a new value was added to the
297collection. However, if there was a constraint that applied to the whole
298value, this was never checked.
299
300In addition, coercions are now called on the whole value.
301
27719606 302The delegation methods now do more argument checking. All of the methods check
303that a valid number of arguments were passed to the method. In addition, the
304delegation methods check that the arguments are sane (array indexes, hash
305keys, numbers, etc.) when applicable. We have tried to emulate the behavior of
306Perl builtins as much as possible.
307
d6ce97b9 308Finally, triggers are called whenever the value of the attribute is changed by
309a Native delegation.
310
c99ddeb7 311These changes are only likely to break code in a few cases.
312
ca8d6244 313The inlining code may or may not preserve the original reference when changes
c99ddeb7 314are made. In some cases, methods which change the value may replace it
315entirely. This will break tied values.
316
317If you have a typed arrayref or hashref attribute where the type enforces a
318constraint on the whole collection, this constraint will now be checked. It's
319possible that code which previously ran without errors will now cause the
320constraint to fail. However, presumably this is a good thing ;)
d6ce97b9 321
27719606 322If you are passing invalid arguments to a delegation which were previously
ca8d6244 323being ignored, these calls will now fail.
27719606 324
c99ddeb7 325If your code relied on the trigger only being called for a regular writer,
326that may cause problems.
d6ce97b9 327
328As always, you are encouraged to test before deploying the latest version of
329Moose to production.
330
c787d26e 331=item Defaults is and default for String, Counter, and Bool
332
d21ebae8 333A few native traits (String, Counter, Bool) provide default values of "is" and
c787d26e 334"default" when you created an attribute. Allowing them to provide these values
335is now deprecated. Supply the value yourself when creating the attribute.
336
a2084f68 337=item The C<meta> method
338
339Moose and Class::MOP have been cleaned up internally enough to make the
340C<meta> method that you get by default optional. C<use Moose> and
341C<use Moose::Role> now can take an additional C<-meta_name> option, which
342tells Moose what name to use when installing the C<meta> method. Passing
343C<undef> to this option suppresses generation of the C<meta> method
344entirely. This should be useful for users of modules which also use a C<meta>
345method or function, such as L<Curses> or L<Rose::DB::Object>.
346
d6ce97b9 347=back
348
aee0741b 349=head1 1.09
350
7dacb294 351=over 4
352
4c7d1018 353=item All deprecated features now warn
354
355Previously, deprecation mostly consisted of simply saying "X is deprecated" in
356the Changes file. We were not very consistent about actually warning. Now, all
357deprecated features still present in Moose actually give a warning. The
358warning is issued once per calling package. See L<Moose::Deprecated> for more
359details.
360
2b54d2a6 361=item You cannot pass C<< coerce => 1 >> unless the attribute's type constraint has a coercion
362
363Previously, this was accepted, and it sort of worked, except that if you
364attempted to set the attribute after the object was created, you would get a
365runtime error.
366
aa6da652 367Now you will get a warning when you attempt to define the attribute.
2b54d2a6 368
aee0741b 369=item C<no Moose>, C<no Moose::Role>, and C<no Moose::Exporter> no longer unimport strict and warnings
370
371This change was made in 1.05, and has now been reverted. We don't know if the
dee8c866 372user has explicitly loaded strict or warnings on their own, and unimporting
373them is just broken in that case.
aee0741b 374
59caebc4 375=item Reversed logic when defining which options can be changed
7782e1da 376
da7efd4c 377L<Moose::Meta::Attribute> now allows all options to be changed in an
378overridden attribute. The previous behaviour required each option to be
379whitelisted using the C<legal_options_for_inheritance> method. This method has
380been removed, and there is a new method, C<illegal_options_for_inheritance>,
381which can now be used to prevent certain options from being changeable.
7782e1da 382
da7efd4c 383In addition, we only throw an error if the illegal option is actually
384changed. If the superclass didn't specify this option at all when defining the
385attribute, the subclass version can still add it as an option.
dede9732 386
387Example of overriding this in an attribute trait:
7782e1da 388
dede9732 389 package Bar::Meta::Attribute;
390 use Moose::Role;
7782e1da 391
392 has 'my_illegal_option' => (
da7efd4c 393 isa => 'CodeRef',
394 is => 'rw',
7782e1da 395 );
396
397 around illegal_options_for_inheritance => sub {
da7efd4c 398 return ( shift->(@_), qw/my_illegal_option/ );
7782e1da 399 };
400
7dacb294 401=back
402
e462f6f3 403=head1 1.05
404
a19ae3d7 405=over 4
406
407=item L<Moose::Object/BUILD> methods are now called when calling C<new_object>
408
409Previously, C<BUILD> methods would only be called from C<Moose::Object::new>,
410but now they are also called when constructing an object via
411C<Moose::Meta::Class::new_object>. C<BUILD> methods are an inherent part of the
412object construction process, and this should make C<< $meta->new_object >>
413actually usable without forcing people to use C<< $meta->name->new >>.
414
2fee26f1 415=item C<no Moose>, C<no Moose::Role>, and C<no Moose::Exporter> now unimport strict and warnings
416
417In the interest of having C<no Moose> clean up everything that C<use Moose>
418does in the calling scope, C<no Moose> (as well as all other
419L<Moose::Exporter>-using modules) now unimports strict and warnings.
420
f46a74bf 421=item Metaclass compatibility checking and fixing should be much more robust
422
423The L<metaclass compatibility|Moose/METACLASS COMPATIBILITY AND MOOSE> checking
424and fixing algorithms have been completely rewritten, in both Class::MOP and
425Moose. This should resolve many confusing errors when dealing with non-Moose
426inheritance and with custom metaclasses for things like attributes,
918b5cef 427constructors, etc. For correct code, the only thing that should require a
428change is that custom error metaclasses must now inherit from
429L<Moose::Error::Default>.
f46a74bf 430
a19ae3d7 431=back
432
8ff79890 433=head1 1.02
434
435=over 4
436
437=item Moose::Meta::TypeConstraint::Class is_subtype_of behavior
438
439Earlier versions of L<is_subtype_of|Moose::Meta::TypeConstraint::Class/is_subtype_of>
440would incorrectly return true when called with itself, its own TC name or
441its class name as an argument. (i.e. $foo_tc->is_subtype_of('Foo') == 1) This
442behavior was a caused by C<isa> being checked before the class name. The old
443behavior can be accessed with L<is_type_of|Moose::Meta::TypeConstraint::Class/is_type_of>
444
445=back
446
12885414 447=head1 1.00
448
449=over 4
450
451=item Moose::Meta::Attribute::Native::Trait::Code no longer creates reader methods by default
452
453Earlier versions of L<Moose::Meta::Attribute::Native::Trait::Code> created
454read-only accessors for the attributes it's been applied to, even if you didn't
455ask for it with C<< is => 'ro' >>. This incorrect behaviour has now been fixed.
456
457=back
458
775666aa 459=head1 0.95
460
461=over 4
462
463=item Moose::Util add_method_modifier behavior
464
465add_method_modifier (and subsequently the sugar functions Moose::before,
466Moose::after, and Moose::around) can now accept arrayrefs, with the same
467behavior as lists. Types other than arrayref and regexp result in an error.
468
469=back
470
5b7b27e2 471=head1 0.93_01 and 0.94
472
473=over 4
474
f785aad8 475=item Moose::Util::MetaRole API has changed
476
477The C<apply_metaclass_roles> function is now called C<apply_metaroles>. The
478way arguments are supplied has been changed to force you to distinguish
479between metaroles applied to L<Moose::Meta::Class> (and helpers) versus
480L<Moose::Meta::Role>.
481
482The old API still works, but will warn in a future release, and eventually be
483removed.
484
485=item Moose::Meta::Role has real attributes
486
487The attributes returned by L<Moose::Meta::Role> are now instances of the
488L<Moose::Meta::Role::Attribute> class, instead of bare hash references.
489
5b7b27e2 490=item "no Moose" now removes C<blessed> and C<confess>
491
492Moose is now smart enough to know exactly what it exported, even when it
493re-exports functions from other packages. When you unimport Moose, it will
494remove these functions from your namespace unless you I<also> imported them
495directly from their respective packages.
496
497If you have a C<no Moose> in your code I<before> you call C<blessed> or
498C<confess>, your code will break. You can either move the C<no Moose> call
499later in your code, or explicitly import the relevant functions from the
500packages that provide them.
501
502=item L<Moose::Exporter> is smarter about unimporting re-exports
503
504The change above comes from a general improvement to L<Moose::Exporter>. It
505will now unimport any function it exports, even if that function is a
506re-export from another package.
507
f427b505 508=item Attributes in roles can no longer override class attributes with "+foo"
509
510Previously, this worked more or less accidentally, because role attributes
511weren't objects. This was never documented, but a few MooseX modules took
512advantage of this.
513
514=item The composition_class_roles attribute in L<Moose::Meta::Role> is now a method
515
516This was done to make it possible for roles to alter the the list of
517composition class roles by applying a method modifiers. Previously, this was
518an attribute and MooseX modules override it. Since that no longer works, this
519was made a method.
520
521This I<should> be an attribute, so this may switch back to being an attribute
522in the future if we can figure out how to make this work.
523
5b7b27e2 524=back
525
c378a61a 526=head1 0.93
527
528=over 4
529
530=item Calling $object->new() is no longer deprecated
531
76c89056 532We decided to undeprecate this. Now it just works.
c378a61a 533
d99ec58b 534=item Both C<get_method_map> and C<get_attribute_map> is deprecated
fa6da135 535
d99ec58b 536These metaclass methods were never meant to be public, and they are both now
537deprecated. The work around if you still need the functionality they provided
538is to iterate over the list of names manually.
fa6da135 539
540 my %fields = map { $_ => $meta->get_attribute($_) } $meta->get_attribute_list;
541
d99ec58b 542This was actually a change in L<Class::MOP>, but this version of Moose
543requires a version of L<Class::MOP> that includes said change.
544
c378a61a 545=back
546
b98ef150 547=head1 0.90
871f82f8 548
c985327a 549=over 4
550
93ef4ba1 551=item Added Native delegation for Code refs
552
553See L<Moose::Meta::Attribute::Native::Trait::Code> for details.
554
3f5ff7d0 555=item Calling $object->new() is deprecated
556
557Moose has long supported this, but it's never really been documented, and we
558don't think this is a good practice. If you want to construct an object from
559an existing object, you should provide some sort of alternate constructor like
560C<< $object->clone >>.
561
562Calling C<< $object->new >> now issues a warning, and will be an error in a
563future release.
564
19e60fdd 565=item Moose no longer warns if you call C<make_immutable> for a class with mutable ancestors
566
567While in theory this is a good thing to warn about, we found so many
568exceptions to this that doing this properly became quite problematic.
569
93ef4ba1 570=back
571
def57e8d 572=head1 0.89_02
93ef4ba1 573
574=over 4
4f0d4488 575
871f82f8 576=item New Native delegation methods from L<List::Util> and L<List::MoreUtils>
577
578In particular, we now have C<reduce>, C<shuffle>, C<uniq>, and C<natatime>.
579
3023f1e4 580=item The Moose::Exporter with_caller feature is now deprecated
581
582Use C<with_meta> instead. The C<with_caller> option will start warning in a
583future release.
584
9b9a5a07 585=item Moose now warns if you call C<make_immutable> for a class with mutable ancestors
586
587This is dangerous because modifying a class after a subclass has been
90b20bd6 588immutabilized will lead to incorrect results in the subclass, due to inlining,
9b9a5a07 589caching, etc. This occasionally happens accidentally, when a class loads one
590of its subclasses in the middle of its class definition, so pointing out that
591this may cause issues should be helpful. Metaclasses (classes that inherit
592from L<Class::MOP::Object>) are currently exempt from this check, since at the
90b20bd6 593moment we aren't very consistent about which metaclasses we immutabilize.
9b9a5a07 594
bce5d4a5 595=item C<enum> and C<duck_type> now take arrayrefs for all forms
596
597Previously, calling these functions with a list would take the first element of
598the list as the type constraint name, and use the remainder as the enum values
599or method names. This makes the interface inconsistent with the anon-type forms
600of these functions (which must take an arrayref), and a free-form list where
601the first value is sometimes special is hard to validate (and harder to give
602reasonable error messages for). These functions have been changed to take
603arrayrefs in all their forms - so, C<< enum 'My::Type' => [qw(foo bar)] >> is
604now the preferred way to create an enum type constraint. The old syntax still
605works for now, but it will hopefully be deprecated and removed in a future
606release.
607
871f82f8 608=back
609
def57e8d 610=head1 0.89_01
a3d98218 611
af44c00c 612L<Moose::Meta::Attribute::Native> has been moved into the Moose core from
a3d98218 613L<MooseX::AttributeHelpers>. Major changes include:
614
ebaaa391 615=over 4
a3d98218 616
617=item C<traits>, not C<metaclass>
618
93ced2bd 619Method providers are only available via traits.
a3d98218 620
621=item C<handles>, not C<provides> or C<curries>
622
93ced2bd 623The C<provides> syntax was like core Moose C<< handles => HASHREF >>
624syntax, but with the keys and values reversed. This was confusing,
625and AttributeHelpers now uses C<< handles => HASHREF >> in a way that
626should be intuitive to anyone already familiar with how it is used for
627other attributes.
a3d98218 628
93ced2bd 629The C<curries> functionality provided by AttributeHelpers has been
630generalized to apply to all cases of C<< handles => HASHREF >>, though
631not every piece of functionality has been ported (currying with a
632CODEREF is not supported).
a3d98218 633
1853a27e 634=item C<empty> is now C<is_empty>, and means empty, not non-empty
af44c00c 635
636Previously, the C<empty> method provided by Arrays and Hashes returned true if
637the attribute was B<not> empty (no elements). Now it returns true if the
1853a27e 638attribute B<is> empty. It was also renamed to C<is_empty>, to reflect this.
af44c00c 639
9a14bd29 640=item C<find> was renamed to C<first>, and C<first> and C<last> were removed
28b96142 641
642L<List::Util> refers to the functionality that we used to provide under C<find>
643as L<first|List::Util/first>, so that will likely be more familiar (and will
9a14bd29 644fit in better if we decide to add more List::Util functions). C<first> and
645C<last> were removed, since their functionality is easily duplicated with
646curries of C<get>.
28b96142 647
648=item Helpers that take a coderef of one argument now use C<$_>
649
650Subroutines passed as the first argument to C<first>, C<map>, and C<grep> now
651receive their argument in C<$_> rather than as a parameter to the subroutine.
652Helpers that take a coderef of two or more arguments remain using the argument
653list (there are technical limitations to using C<$a> and C<$b> like C<sort>
654does).
655
af44c00c 656See L<Moose::Meta::Attribute::Native> for the new documentation.
a3d98218 657
ebaaa391 658=back
659
85e2b15a 660The C<alias> and C<excludes> role parameters have been renamed to C<-alias>
661and C<-excludes>. The old names still work, but new code should use the new
662names, and eventually the old ones will be deprecated and removed.
663
def57e8d 664=head1 0.89
4ada9618 665
8a8856de 666C<< use Moose -metaclass => 'Foo' >> now does alias resolution, just like
667C<-traits> (and the C<metaclass> and C<traits> options to C<has>).
668
27f2f43f 669Added two functions C<meta_class_alias> and C<meta_attribute_alias> to
670L<Moose::Util>, to simplify aliasing metaclasses and metatraits. This is
671a wrapper around the old
672
673 package Moose::Meta::Class::Custom::Trait::FooTrait;
674 sub register_implementation { 'My::Meta::Trait' }
675
676way of doing this.
677
def57e8d 678=head1 0.84
4831e2de 679
9f52cce5 680When an attribute generates I<no> accessors, we now warn. This is to help
681users who forget the C<is> option. If you really do not want any accessors,
3de02fd8 682you can use C<< is => 'bare' >>. You can maintain back compat with older
683versions of Moose by using something like:
684
685 ($Moose::VERSION >= 0.84 ? is => 'bare' : ())
9f52cce5 686
687When an accessor overwrites an existing method, we now warn. To work around
688this warning (if you really must have this behavior), you can explicitly
689remove the method before creating it as an accessor:
690
691 sub foo {}
692
693 __PACKAGE__->meta->remove_method('foo');
694
695 has foo => (
696 is => 'ro',
697 );
698
699When an unknown option is passed to C<has>, we now warn. You can silence
700the warning by fixing your code. :)
701
4831e2de 702The C<Role> type has been deprecated. On its own, it was useless,
703since it just checked C<< $object->can('does') >>. If you were using
704it as a parent type, just call C<role_type('Role::Name')> to create an
705appropriate type instead.
706
def57e8d 707=head1 0.78
7d6b451f 708
709C<use Moose::Exporter;> now imports C<strict> and C<warnings> into packages
710that use it.
711
def57e8d 712=head1 0.77
c3fdacda 713
714C<DEMOLISHALL> and C<DEMOLISH> now receive an argument indicating whether or
715not we are in global destruction.
716
def57e8d 717=head1 0.76
00c61603 718
9f0b3b64 719Type constraints no longer run coercions for a value that already matches the
720constraint. This may affect some (arguably buggy) edge case coercions that
721rely on side effects in the C<via> clause.
722
def57e8d 723=head1 0.75
f869fc4a 724
725L<Moose::Exporter> now accepts the C<-metaclass> option for easily
726overriding the metaclass (without L<metaclass>). This works for classes
727and roles.
728
def57e8d 729=head1 0.74
39ab7714 730
85cf0647 731Added a C<duck_type> sugar function to L<Moose::Util::TypeConstraints>
732to make integration with non-Moose classes easier. It simply checks if
733C<< $obj->can() >> a list of methods.
39ab7714 734
612fd754 735A number of methods (mostly inherited from L<Class::MOP>) have been
736renamed with a leading underscore to indicate their internal-ness. The
737old method names will still work for a while, but will warn that the
738method has been renamed. In a few cases, the method will be removed
739entirely in the future. This may affect MooseX authors who were using
740these methods.
741
def57e8d 742=head1 0.73
600f7f85 743
0f13f53c 744Calling C<subtype> with a name as the only argument now throws an
600f7f85 745exception. If you want an anonymous subtype do:
746
747 my $subtype = subtype as 'Foo';
748
0f13f53c 749This is related to the changes in version 0.71_01.
600f7f85 750
501db4e6 751The C<is_needed> method in L<Moose::Meta::Method::Destructor> is now
752only usable as a class method. Previously, it worked as a class or
753object method, with a different internal implementation for each
754version.
755
756The internals of making a class immutable changed a lot in Class::MOP
7570.78_02, and Moose's internals have changed along with it. The
758external C<< $metaclass->make_immutable >> method still works the same
759way.
760
def57e8d 761=head1 0.72
600f7f85 762
0f13f53c 763A mutable class accepted C<< Foo->new(undef) >> without complaint,
764while an immutable class would blow up with an unhelpful error. Now,
765in both cases we throw a helpful error instead.
600f7f85 766
0f13f53c 767This "feature" was originally added to allow for cases such as this:
600f7f85 768
769 my $args;
0f13f53c 770
771 if ( something() ) {
772 $args = {...};
600f7f85 773 }
0f13f53c 774
600f7f85 775 return My::Class->new($args);
776
0f13f53c 777But we decided this is a bad idea and a little too magical, because it
778can easily mask real errors.
600f7f85 779
def57e8d 780=head1 0.71_01
600f7f85 781
0f13f53c 782Calling C<type> or C<subtype> without the sugar helpers (C<as>,
783C<where>, C<message>) is now deprecated.
784
785As a side effect, this meant we ended up using Perl prototypes on
786C<as>, and code like this will no longer work:
600f7f85 787
788 use Moose::Util::TypeConstraints;
789 use Declare::Constraints::Simple -All;
0f13f53c 790
791 subtype 'ArrayOfInts'
600f7f85 792 => as 'ArrayRef'
793 => IsArrayRef(IsInt);
794
795Instead it must be changed to this:
796
0f13f53c 797 subtype(
798 'ArrayOfInts' => {
799 as => 'ArrayRef',
800 where => IsArrayRef(IsInt)
801 }
600f7f85 802 );
803
0f13f53c 804If you want to maintain backwards compat with older versions of Moose,
805you must explicitly test Moose's C<VERSION>:
600f7f85 806
0f13f53c 807 if ( Moose->VERSION < 0.71_01 ) {
808 subtype 'ArrayOfInts'
600f7f85 809 => as 'ArrayRef'
810 => IsArrayRef(IsInt);
811 }
812 else {
0f13f53c 813 subtype(
814 'ArrayOfInts' => {
815 as => 'ArrayRef',
816 where => IsArrayRef(IsInt)
817 }
600f7f85 818 );
819 }
820
def57e8d 821=head1 0.70
600f7f85 822
0f13f53c 823We no longer pass the meta-attribute object as a final argument to
824triggers. This actually changed for inlined code a while back, but the
825non-inlined version and the docs were still out of date.
826
827If by some chance you actually used this feature, the workaround is
828simple. You fetch the attribute object from out of the C<$self>
829that is passed as the first argument to trigger, like so:
830
831 has 'foo' => (
832 is => 'ro',
833 isa => 'Any',
834 trigger => sub {
835 my ( $self, $value ) = @_;
836 my $attr = $self->meta->find_attribute_by_name('foo');
837
838 # ...
839 }
840 );
600f7f85 841
def57e8d 842=head1 0.66
600f7f85 843
0f13f53c 844If you created a subtype and passed a parent that Moose didn't know
845about, it simply ignored the parent. Now it automatically creates the
846parent as a class type. This may not be what you want, but is less
847broken than before.
600f7f85 848
0f13f53c 849You could declare a name with subtype such as "Foo!Bar". Moose would
850accept this allowed, but if you used it in a parameterized type such
851as "ArrayRef[Foo!Bar]" it wouldn't work. We now do some vetting on
852names created via the sugar functions, so that they can only contain
853alphanumerics, ":", and ".".
600f7f85 854
def57e8d 855=head1 0.65
600f7f85 856
857Methods created via an attribute can now fulfill a C<requires>
0f13f53c 858declaration for a role. Honestly we don't know why Stevan didn't make
859this work originally, he was just insane or something.
600f7f85 860
0f13f53c 861Stack traces from inlined code will now report the line and file as
862being in your class, as opposed to in Moose guts.
600f7f85 863
def57e8d 864=head1 0.62_02
600f7f85 865
0f13f53c 866When a class does not provide all of a role's required methods, the
867error thrown now mentions all of the missing methods, as opposed to
868just the first missing method.
600f7f85 869
0f13f53c 870Moose will no longer inline a constructor for your class unless it
5e26e3f2 871inherits its constructor from Moose::Object, and will warn when it
872doesn't inline. If you want to force inlining anyway, pass
b84f64da 873C<< replace_constructor => 1 >> to C<make_immutable>.
0f13f53c 874
875If you want to get rid of the warning, pass C<< inline_constructor =>
fbf7ba85 8760 >>.
600f7f85 877
def57e8d 878=head1 0.62
600f7f85 879
0f13f53c 880Removed the (deprecated) C<make_immutable> keyword.
600f7f85 881
882Removing an attribute from a class now also removes delegation
0f13f53c 883(C<handles>) methods installed for that attribute. This is correct
600f7f85 884behavior, but if you were wrongly relying on it you might get bit.
885
def57e8d 886=head1 0.58
600f7f85 887
0f13f53c 888Roles now add methods by calling C<add_method>, not
889C<alias_method>. They make sure to always provide a method object,
890which will be cloned internally. This means that it is now possible to
891track the source of a method provided by a role, and even follow its
892history through intermediate roles. This means that methods added by
893a role now show up when looking at a class's method list/map.
894
895Parameter and Union args are now sorted, this makes Int|Str the same
896constraint as Str|Int. Also, incoming type constraint strings are
897normalized to remove all whitespace differences. This is mostly for
898internals and should not affect outside code.
899
900L<Moose::Exporter> will no longer remove a subroutine that the
901exporting package re-exports. Moose re-exports the Carp::confess
902function, among others. The reasoning is that we cannot know whether
903you have also explicitly imported those functions for your own use, so
904we err on the safe side and always keep them.
600f7f85 905
def57e8d 906=head1 0.56
600f7f85 907
0f13f53c 908C<Moose::init_meta> should now be called as a method.
600f7f85 909
0f13f53c 910New modules for extension writers, L<Moose::Exporter> and
911L<Moose::Util::MetaRole>.
600f7f85 912
def57e8d 913=head1 0.55_01
600f7f85 914
915Implemented metaclass traits (and wrote a recipe for it):
916
917 use Moose -traits => 'Foo'
918
919This should make writing small Moose extensions a little
920easier.
921
def57e8d 922=head1 0.55
600f7f85 923
924Fixed C<coerce> to accept anon types just like C<subtype> can.
925So that you can do:
926
927 coerce $some_anon_type => from 'Str' => via { ... };
928
def57e8d 929=head1 0.51
600f7f85 930
52da380a 931Added C<BUILDARGS>, a new step in C<< Moose::Object->new() >>.
600f7f85 932
def57e8d 933=head1 0.49
600f7f85 934
0f13f53c 935Fixed how the C<< is => (ro|rw) >> works with custom defined
936C<reader>, C<writer> and C<accessor> options. See the below table for
600f7f85 937details:
938
939 is => ro, writer => _foo # turns into (reader => foo, writer => _foo)
940 is => rw, writer => _foo # turns into (reader => foo, writer => _foo)
941 is => rw, accessor => _foo # turns into (accessor => _foo)
942 is => ro, accessor => _foo # error, accesor is rw
943
def57e8d 944=head1 0.45
600f7f85 945
0f13f53c 946The C<before/around/after> method modifiers now support regexp
947matching of method names. NOTE: this only works for classes, it is
948currently not supported in roles, but, ... patches welcome.
600f7f85 949
0f13f53c 950The C<has> keyword for roles now accepts the same array ref form that
951L<Moose>.pm does for classes.
600f7f85 952
0f13f53c 953A trigger on a read-only attribute is no longer an error, as it's
954useful to trigger off of the constructor.
600f7f85 955
0f13f53c 956Subtypes of parameterizable types now are parameterizable types
957themselves.
600f7f85 958
def57e8d 959=head1 0.44
600f7f85 960
0f13f53c 961Fixed issue where C<DEMOLISHALL> was eating the value in C<$@>, and so
962not working correctly. It still kind of eats them, but so does vanilla
963perl.
600f7f85 964
def57e8d 965=head1 0.41
600f7f85 966
0f13f53c 967Inherited attributes may now be extended without restriction on the
600f7f85 968type ('isa', 'does').
969
0f13f53c 970The entire set of Moose::Meta::TypeConstraint::* classes were
971refactored in this release. If you were relying on their internals you
972should test your code carefully.
600f7f85 973
def57e8d 974=head1 0.40
600f7f85 975
0f13f53c 976Documenting the use of '+name' with attributes that come from recently
977composed roles. It makes sense, people are using it, and so why not
978just officially support it.
600f7f85 979
0f13f53c 980The C<< Moose::Meta::Class->create >> method now supports roles.
600f7f85 981
86b96832 982It is now possible to make anonymous enum types by passing C<enum> an
983array reference instead of the C<< enum $name => @values >>.
600f7f85 984
def57e8d 985=head1 0.37
600f7f85 986
0f13f53c 987Added the C<make_immutable> keyword as a shortcut to calling
988C<make_immutable> on the meta object. This eventually got removed!
600f7f85 989
0f13f53c 990Made C<< init_arg => undef >> work in Moose. This means "do not accept
600f7f85 991a constructor parameter for this attribute".
992
0f13f53c 993Type errors now use the provided message. Prior to this release they
994didn't.
600f7f85 995
def57e8d 996=head1 0.34
600f7f85 997
998Moose is now a postmodern object system :)
999
0f13f53c 1000The Role system was completely refactored. It is 100% backwards
1001compat, but the internals were totally changed. If you relied on the
1002internals then you are advised to test carefully.
600f7f85 1003
1004Added method exclusion and aliasing for Roles in this release.
1005
0f13f53c 1006Added the L<Moose::Util::TypeConstraints::OptimizedConstraints>
1007module.
600f7f85 1008
0f13f53c 1009Passing a list of values to an accessor (which is only expecting one
1010value) used to be silently ignored, now it throws an error.
600f7f85 1011
def57e8d 1012=head1 0.26
600f7f85 1013
0f13f53c 1014Added parameterized types and did a pretty heavy refactoring of the
1015type constraint system.
600f7f85 1016
7bb4be82 1017Better framework extensibility and better support for "making your own
0f13f53c 1018Moose".
600f7f85 1019
def57e8d 1020=head1 0.25 or before
600f7f85 1021
0f13f53c 1022Honestly, you shouldn't be using versions of Moose that are this old,
1023so many bug fixes and speed improvements have been made you would be
1024crazy to not upgrade.
600f7f85 1025
0f13f53c 1026Also, I am tired of going through the Changelog so I am stopping here,
1027if anyone would like to continue this please feel free.
600f7f85 1028
0f13f53c 1029=cut