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