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