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