1Moose::Manual::Delta(3)User Contributed Perl DocumentatioMnoose::Manual::Delta(3)
2
3
4

NAME

6       Moose::Manual::Delta - Important Changes in Moose
7

DESCRIPTION

9       This documents any important or noteworthy changes in Moose, with a
10       focus on backwards. This does duplicate data from the Changes file, but
11       aims to provide more details and when possible workarounds.
12
13       Besides helping keep up with changes, you can also use this document
14       for finding the lowest version of Moose that supported a given feature.
15       If you encounter a problem and have a solution but don't see it
16       documented here, or think we missed an important feature, please send
17       us a patch.
18

1.09

20       All deprecated features now warn
21           Previously, deprecation mostly consisted of simply saying "X is
22           deprecated" in the Changes file. We were not very consistent about
23           actually warning. Now, all deprecated features still present in
24           Moose actually give a warning. The warning is issued once per
25           calling package. See Moose::Deprecated for more details.
26
27       You cannot pass "coerce => 1" unless the attribute's type constraint
28       has a coercion
29           Previously, this was accepted, and it sort of worked, except that
30           if you attempted to set the attribute after the object was created,
31           you would get a runtime error.
32
33           Now you will get a warning when you attempt to define the
34           attribute.
35
36       "no Moose", "no Moose::Role", and "no Moose::Exporter" no longer
37       unimport strict and warnings
38           This change was made in 1.05, and has now been reverted. We don't
39           know if the user has explicitly loaded strict or warnings on their
40           own, and unimporting them is just broken in that case.
41
42       Reversed logic when defining which options can be changed
43           Moose::Meta::Attribute now allows all options to be changed in an
44           overridden attribute. The previous behaviour required each option
45           to be whitelisted using the "legal_options_for_inheritance" method.
46           This method has been removed, and there is a new method,
47           "illegal_options_for_inheritance", which can now be used to prevent
48           certain options from being changeable.
49
50           In addition, we only throw an error if the illegal option is
51           actually changed. If the superclass didn't specify this option at
52           all when defining the attribute, the subclass version can still add
53           it as an option.
54
55           Example of overriding this in an attribute trait:
56
57             package Bar::Meta::Attribute;
58             use Moose::Role;
59
60             has 'my_illegal_option' => (
61                 isa => 'CodeRef',
62                 is  => 'rw',
63             );
64
65             around illegal_options_for_inheritance => sub {
66                 return ( shift->(@_), qw/my_illegal_option/ );
67             };
68

1.05

70       "BUILD" in Moose::Object methods are now called when calling
71       "new_object"
72           Previously, "BUILD" methods would only be called from
73           "Moose::Object::new", but now they are also called when
74           constructing an object via "Moose::Meta::Class::new_object".
75           "BUILD" methods are an inherent part of the object construction
76           process, and this should make "$meta->new_object" actually usable
77           without forcing people to use "$meta->name->new".
78
79       "no Moose", "no Moose::Role", and "no Moose::Exporter" now unimport
80       strict and warnings
81           In the interest of having "no Moose" clean up everything that "use
82           Moose" does in the calling scope, "no Moose" (as well as all other
83           Moose::Exporter-using modules) now unimports strict and warnings.
84
85       Metaclass compatibility checking and fixing should be much more robust
86           The metaclass compatibility checking and fixing algorithms have
87           been completely rewritten, in both Class::MOP and Moose. This
88           should resolve many confusing errors when dealing with non-Moose
89           inheritance and with custom metaclasses for things like attributes,
90           constructors, etc. For correct code, the only thing that should
91           require a change is that custom error metaclasses must now inherit
92           from Moose::Error::Default.
93

1.02

95       Moose::Meta::TypeConstraint::Class is_subtype_of behavior
96           Earlier versions of is_subtype_of would incorrectly return true
97           when called with itself, its own TC name or its class name as an
98           argument. (i.e. $foo_tc->is_subtype_of('Foo') == 1) This behavior
99           was a caused by "isa" being checked before the class name. The old
100           behavior can be accessed with is_type_of
101

1.00

103       Moose::Meta::Attribute::Native::Trait::Code no longer creates reader
104       methods by default
105           Earlier versions of Moose::Meta::Attribute::Native::Trait::Code
106           created read-only accessors for the attributes it's been applied
107           to, even if you didn't ask for it with "is => 'ro'". This incorrect
108           behaviour has now been fixed.
109

0.95

111       Moose::Util add_method_modifier behavior
112           add_method_modifier (and subsequently the sugar functions
113           Moose::before, Moose::after, and Moose::around) can now accept
114           arrayrefs, with the same behavior as lists. Types other than
115           arrayref and regexp result in an error.
116

0.93_01 and 0.94

118       Moose::Util::MetaRole API has changed
119           The "apply_metaclass_roles" function is now called
120           "apply_metaroles". The way arguments are supplied has been changed
121           to force you to distinguish between metaroles applied to
122           Moose::Meta::Class (and helpers) versus Moose::Meta::Role.
123
124           The old API still works, but will warn in a future release, and
125           eventually be removed.
126
127       Moose::Meta::Role has real attributes
128           The attributes returned by Moose::Meta::Role are now instances of
129           the Moose::Meta::Role::Attribute class, instead of bare hash
130           references.
131
132       "no Moose" now removes "blessed" and "confess"
133           Moose is now smart enough to know exactly what it exported, even
134           when it re-exports functions from other packages. When you unimport
135           Moose, it will remove these functions from your namespace unless
136           you also imported them directly from their respective packages.
137
138           If you have a "no Moose" in your code before you call "blessed" or
139           "confess", your code will break. You can either move the "no Moose"
140           call later in your code, or explicitly import the relevant
141           functions from the packages that provide them.
142
143       Moose::Exporter is smarter about unimporting re-exports
144           The change above comes from a general improvement to
145           Moose::Exporter. It will now unimport any function it exports, even
146           if that function is a re-export from another package.
147
148       Attributes in roles can no longer override class attributes with "+foo"
149           Previously, this worked more or less accidentally, because role
150           attributes weren't objects. This was never documented, but a few
151           MooseX modules took advantage of this.
152
153       The composition_class_roles attribute in Moose::Meta::Role is now a
154       method
155           This was done to make it possible for roles to alter the the list
156           of composition class roles by applying a method modifiers.
157           Previously, this was an attribute and MooseX modules override it.
158           Since that no longer works, this was made a method.
159
160           This should be an attribute, so this may switch back to being an
161           attribute in the future if we can figure out how to make this work.
162

0.93

164       Calling $object->new() is no longer deprecated
165           We decided to undeprecate this. Now it just works.
166
167       Both "get_method_map" and "get_attribute_map" is deprecated
168           These metaclass methods were never meant to be public, and they are
169           both now deprecated. The work around if you still need the
170           functionality they provided is to iterate over the list of names
171           manually.
172
173               my %fields = map { $_ => $meta->get_attribute($_) } $meta->get_attribute_list;
174
175           This was actually a change in Class::MOP, but this version of Moose
176           requires a version of Class::MOP that includes said change.
177

0.90

179       Added Native delegation for Code refs
180           See Moose::Meta::Attribute::Native::Trait::Code for details.
181
182       Calling $object->new() is deprecated
183           Moose has long supported this, but it's never really been
184           documented, and we don't think this is a good practice. If you want
185           to construct an object from an existing object, you should provide
186           some sort of alternate constructor like "$object->clone".
187
188           Calling "$object->new" now issues a warning, and will be an error
189           in a future release.
190
191       Moose no longer warns if you call "make_immutable" for a class with
192       mutable ancestors
193           While in theory this is a good thing to warn about, we found so
194           many exceptions to this that doing this properly became quite
195           problematic.
196

0.89_02

198       New Native delegation methods from List::Util and List::MoreUtils
199           In particular, we now have "reduce", "shuffle", "uniq", and
200           "natatime".
201
202       The Moose::Exporter with_caller feature is now deprecated
203           Use "with_meta" instead. The "with_caller" option will start
204           warning in a future release.
205
206       Moose now warns if you call "make_immutable" for a class with mutable
207       ancestors
208           This is dangerous because modifying a class after a subclass has
209           been immutabilized will lead to incorrect results in the subclass,
210           due to inlining, caching, etc. This occasionally happens
211           accidentally, when a class loads one of its subclasses in the
212           middle of its class definition, so pointing out that this may cause
213           issues should be helpful. Metaclasses (classes that inherit from
214           Class::MOP::Object) are currently exempt from this check, since at
215           the moment we aren't very consistent about which metaclasses we
216           immutabilize.
217
218       "enum" and "duck_type" now take arrayrefs for all forms
219           Previously, calling these functions with a list would take the
220           first element of the list as the type constraint name, and use the
221           remainder as the enum values or method names. This makes the
222           interface inconsistent with the anon-type forms of these functions
223           (which must take an arrayref), and a free-form list where the first
224           value is sometimes special is hard to validate (and harder to give
225           reasonable error messages for). These functions have been changed
226           to take arrayrefs in all their forms - so, "enum 'My::Type' =>
227           [qw(foo bar)]" is now the preferred way to create an enum type
228           constraint. The old syntax still works for now, but it will
229           hopefully be deprecated and removed in a future release.
230

0.89_01

232       Moose::Meta::Attribute::Native has been moved into the Moose core from
233       MooseX::AttributeHelpers.  Major changes include:
234
235       "traits", not "metaclass"
236           Method providers are only available via traits.
237
238       "handles", not "provides" or "curries"
239           The "provides" syntax was like core Moose "handles => HASHREF"
240           syntax, but with the keys and values reversed.  This was confusing,
241           and AttributeHelpers now uses "handles => HASHREF" in a way that
242           should be intuitive to anyone already familiar with how it is used
243           for other attributes.
244
245           The "curries" functionality provided by AttributeHelpers has been
246           generalized to apply to all cases of "handles => HASHREF", though
247           not every piece of functionality has been ported (currying with a
248           CODEREF is not supported).
249
250       "empty" is now "is_empty", and means empty, not non-empty
251           Previously, the "empty" method provided by Arrays and Hashes
252           returned true if the attribute was not empty (no elements).  Now it
253           returns true if the attribute is empty. It was also renamed to
254           "is_empty", to reflect this.
255
256       "find" was renamed to "first", and "first" and "last" were removed
257           List::Util refers to the functionality that we used to provide
258           under "find" as first, so that will likely be more familiar (and
259           will fit in better if we decide to add more List::Util functions).
260           "first" and "last" were removed, since their functionality is
261           easily duplicated with curries of "get".
262
263       Helpers that take a coderef of one argument now use $_
264           Subroutines passed as the first argument to "first", "map", and
265           "grep" now receive their argument in $_ rather than as a parameter
266           to the subroutine.  Helpers that take a coderef of two or more
267           arguments remain using the argument list (there are technical
268           limitations to using $a and $b like "sort" does).
269
270           See Moose::Meta::Attribute::Native for the new documentation.
271
272       The "alias" and "excludes" role parameters have been renamed to
273       "-alias" and "-excludes". The old names still work, but new code should
274       use the new names, and eventually the old ones will be deprecated and
275       removed.
276

0.89

278       "use Moose -metaclass => 'Foo'" now does alias resolution, just like
279       "-traits" (and the "metaclass" and "traits" options to "has").
280
281       Added two functions "meta_class_alias" and "meta_attribute_alias" to
282       Moose::Util, to simplify aliasing metaclasses and metatraits. This is a
283       wrapper around the old
284
285         package Moose::Meta::Class::Custom::Trait::FooTrait;
286         sub register_implementation { 'My::Meta::Trait' }
287
288       way of doing this.
289

0.84

291       When an attribute generates no accessors, we now warn. This is to help
292       users who forget the "is" option. If you really do not want any
293       accessors, you can use "is => 'bare'". You can maintain back compat
294       with older versions of Moose by using something like:
295
296           ($Moose::VERSION >= 0.84 ? is => 'bare' : ())
297
298       When an accessor overwrites an existing method, we now warn. To work
299       around this warning (if you really must have this behavior), you can
300       explicitly remove the method before creating it as an accessor:
301
302           sub foo {}
303
304           __PACKAGE__->meta->remove_method('foo');
305
306           has foo => (
307               is => 'ro',
308           );
309
310       When an unknown option is passed to "has", we now warn. You can silence
311       the warning by fixing your code. :)
312
313       The "Role" type has been deprecated. On its own, it was useless, since
314       it just checked "$object->can('does')". If you were using it as a
315       parent type, just call "role_type('Role::Name')" to create an
316       appropriate type instead.
317

0.78

319       "use Moose::Exporter;" now imports "strict" and "warnings" into
320       packages that use it.
321

0.77

323       "DEMOLISHALL" and "DEMOLISH" now receive an argument indicating whether
324       or not we are in global destruction.
325

0.76

327       Type constraints no longer run coercions for a value that already
328       matches the constraint.  This may affect some (arguably buggy) edge
329       case coercions that rely on side effects in the "via" clause.
330

0.75

332       Moose::Exporter now accepts the "-metaclass" option for easily
333       overriding the metaclass (without metaclass). This works for classes
334       and roles.
335

0.74

337       Added a "duck_type" sugar function to Moose::Util::TypeConstraints to
338       make integration with non-Moose classes easier. It simply checks if
339       "$obj->can()" a list of methods.
340
341       A number of methods (mostly inherited from Class::MOP) have been
342       renamed with a leading underscore to indicate their internal-ness. The
343       old method names will still work for a while, but will warn that the
344       method has been renamed. In a few cases, the method will be removed
345       entirely in the future. This may affect MooseX authors who were using
346       these methods.
347

0.73

349       Calling "subtype" with a name as the only argument now throws an
350       exception. If you want an anonymous subtype do:
351
352           my $subtype = subtype as 'Foo';
353
354       This is related to the changes in version 0.71_01.
355
356       The "is_needed" method in Moose::Meta::Method::Destructor is now only
357       usable as a class method. Previously, it worked as a class or object
358       method, with a different internal implementation for each version.
359
360       The internals of making a class immutable changed a lot in Class::MOP
361       0.78_02, and Moose's internals have changed along with it. The external
362       "$metaclass->make_immutable" method still works the same way.
363

0.72

365       A mutable class accepted "Foo->new(undef)" without complaint, while an
366       immutable class would blow up with an unhelpful error. Now, in both
367       cases we throw a helpful error instead.
368
369       This "feature" was originally added to allow for cases such as this:
370
371         my $args;
372
373         if ( something() ) {
374             $args = {...};
375         }
376
377         return My::Class->new($args);
378
379       But we decided this is a bad idea and a little too magical, because it
380       can easily mask real errors.
381

0.71_01

383       Calling "type" or "subtype" without the sugar helpers ("as", "where",
384       "message") is now deprecated.
385
386       As a side effect, this meant we ended up using Perl prototypes on "as",
387       and code like this will no longer work:
388
389         use Moose::Util::TypeConstraints;
390         use Declare::Constraints::Simple -All;
391
392         subtype 'ArrayOfInts'
393             => as 'ArrayRef'
394             => IsArrayRef(IsInt);
395
396       Instead it must be changed to this:
397
398         subtype(
399             'ArrayOfInts' => {
400                 as    => 'ArrayRef',
401                 where => IsArrayRef(IsInt)
402             }
403         );
404
405       If you want to maintain backwards compat with older versions of Moose,
406       you must explicitly test Moose's "VERSION":
407
408         if ( Moose->VERSION < 0.71_01 ) {
409             subtype 'ArrayOfInts'
410                 => as 'ArrayRef'
411                 => IsArrayRef(IsInt);
412         }
413         else {
414             subtype(
415                 'ArrayOfInts' => {
416                     as    => 'ArrayRef',
417                     where => IsArrayRef(IsInt)
418                 }
419             );
420         }
421

0.70

423       We no longer pass the meta-attribute object as a final argument to
424       triggers. This actually changed for inlined code a while back, but the
425       non-inlined version and the docs were still out of date.
426
427       If by some chance you actually used this feature, the workaround is
428       simple. You fetch the attribute object from out of the $self that is
429       passed as the first argument to trigger, like so:
430
431         has 'foo' => (
432             is      => 'ro',
433             isa     => 'Any',
434             trigger => sub {
435                 my ( $self, $value ) = @_;
436                 my $attr = $self->meta->find_attribute_by_name('foo');
437
438                 # ...
439             }
440         );
441

0.66

443       If you created a subtype and passed a parent that Moose didn't know
444       about, it simply ignored the parent. Now it automatically creates the
445       parent as a class type. This may not be what you want, but is less
446       broken than before.
447
448       You could declare a name with subtype such as "Foo!Bar". Moose would
449       accept this allowed, but if you used it in a parameterized type such as
450       "ArrayRef[Foo!Bar]" it wouldn't work. We now do some vetting on names
451       created via the sugar functions, so that they can only contain
452       alphanumerics, ":", and ".".
453

0.65

455       Methods created via an attribute can now fulfill a "requires"
456       declaration for a role. Honestly we don't know why Stevan didn't make
457       this work originally, he was just insane or something.
458
459       Stack traces from inlined code will now report the line and file as
460       being in your class, as opposed to in Moose guts.
461

0.62_02

463       When a class does not provide all of a role's required methods, the
464       error thrown now mentions all of the missing methods, as opposed to
465       just the first missing method.
466
467       Moose will no longer inline a constructor for your class unless it
468       inherits its constructor from Moose::Object, and will warn when it
469       doesn't inline. If you want to force inlining anyway, pass
470       "replace_constructor => 1" to "make_immutable".
471
472       If you want to get rid of the warning, pass "inline_constructor => 0".
473

0.62

475       Removed the (deprecated) "make_immutable" keyword.
476
477       Removing an attribute from a class now also removes delegation
478       ("handles") methods installed for that attribute. This is correct
479       behavior, but if you were wrongly relying on it you might get bit.
480

0.58

482       Roles now add methods by calling "add_method", not "alias_method". They
483       make sure to always provide a method object, which will be cloned
484       internally. This means that it is now possible to track the source of a
485       method provided by a role, and even follow its history through
486       intermediate roles.  This means that methods added by a role now show
487       up when looking at a class's method list/map.
488
489       Parameter and Union args are now sorted, this makes Int|Str the same
490       constraint as Str|Int. Also, incoming type constraint strings are
491       normalized to remove all whitespace differences. This is mostly for
492       internals and should not affect outside code.
493
494       Moose::Exporter will no longer remove a subroutine that the exporting
495       package re-exports. Moose re-exports the Carp::confess function, among
496       others. The reasoning is that we cannot know whether you have also
497       explicitly imported those functions for your own use, so we err on the
498       safe side and always keep them.
499

0.56

501       "Moose::init_meta" should now be called as a method.
502
503       New modules for extension writers, Moose::Exporter and
504       Moose::Util::MetaRole.
505

0.55_01

507       Implemented metaclass traits (and wrote a recipe for it):
508
509         use Moose -traits => 'Foo'
510
511       This should make writing small Moose extensions a little easier.
512

0.55

514       Fixed "coerce" to accept anon types just like "subtype" can.  So that
515       you can do:
516
517         coerce $some_anon_type => from 'Str' => via { ... };
518

0.51

520       Added "BUILDARGS", a new step in "Moose::Object->new()".
521

0.49

523       Fixed how the "is => (ro|rw)" works with custom defined "reader",
524       "writer" and "accessor" options. See the below table for details:
525
526         is => ro, writer => _foo    # turns into (reader => foo, writer => _foo)
527         is => rw, writer => _foo    # turns into (reader => foo, writer => _foo)
528         is => rw, accessor => _foo  # turns into (accessor => _foo)
529         is => ro, accessor => _foo  # error, accesor is rw
530

0.45

532       The "before/around/after" method modifiers now support regexp matching
533       of method names. NOTE: this only works for classes, it is currently not
534       supported in roles, but, ... patches welcome.
535
536       The "has" keyword for roles now accepts the same array ref form that
537       Moose.pm does for classes.
538
539       A trigger on a read-only attribute is no longer an error, as it's
540       useful to trigger off of the constructor.
541
542       Subtypes of parameterizable types now are parameterizable types
543       themselves.
544

0.44

546       Fixed issue where "DEMOLISHALL" was eating the value in $@, and so not
547       working correctly. It still kind of eats them, but so does vanilla
548       perl.
549

0.41

551       Inherited attributes may now be extended without restriction on the
552       type ('isa', 'does').
553
554       The entire set of Moose::Meta::TypeConstraint::* classes were
555       refactored in this release. If you were relying on their internals you
556       should test your code carefully.
557

0.40

559       Documenting the use of '+name' with attributes that come from recently
560       composed roles. It makes sense, people are using it, and so why not
561       just officially support it.
562
563       The "Moose::Meta::Class->create" method now supports roles.
564
565       It is now possible to make anonymous enum types by passing "enum" an
566       array reference instead of the "enum $name => @values".
567

0.37

569       Added the "make_immutable" keyword as a shortcut to calling
570       "make_immutable" on the meta object. This eventually got removed!
571
572       Made "init_arg => undef" work in Moose. This means "do not accept a
573       constructor parameter for this attribute".
574
575       Type errors now use the provided message. Prior to this release they
576       didn't.
577

0.34

579       Moose is now a postmodern object system :)
580
581       The Role system was completely refactored. It is 100% backwards compat,
582       but the internals were totally changed. If you relied on the internals
583       then you are advised to test carefully.
584
585       Added method exclusion and aliasing for Roles in this release.
586
587       Added the Moose::Util::TypeConstraints::OptimizedConstraints module.
588
589       Passing a list of values to an accessor (which is only expecting one
590       value) used to be silently ignored, now it throws an error.
591

0.26

593       Added parameterized types and did a pretty heavy refactoring of the
594       type constraint system.
595
596       Better framework extendability and better support for "making your own
597       Moose".
598

0.25 or before

600       Honestly, you shouldn't be using versions of Moose that are this old,
601       so many bug fixes and speed improvements have been made you would be
602       crazy to not upgrade.
603
604       Also, I am tired of going through the Changelog so I am stopping here,
605       if anyone would like to continue this please feel free.
606

AUTHOR

608       Stevan Little <stevan@iinteractive.com>
609
611       Copyright 2009 by Infinity Interactive, Inc.
612
613       <http://www.iinteractive.com>
614
615       This library is free software; you can redistribute it and/or modify it
616       under the same terms as Perl itself.
617
618
619
620perl v5.12.2                      2010-08-28           Moose::Manual::Delta(3)
Impressum