More pod fixes
[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
871f82f8 19=head1 Version XX
20
c985327a 21=over 4
22
871f82f8 23=item New Native delegation methods from L<List::Util> and L<List::MoreUtils>
24
25In particular, we now have C<reduce>, C<shuffle>, C<uniq>, and C<natatime>.
26
27=back
28
4ada9618 29=head1 Version 0.89_01
a3d98218 30
af44c00c 31L<Moose::Meta::Attribute::Native> has been moved into the Moose core from
a3d98218 32L<MooseX::AttributeHelpers>. Major changes include:
33
ebaaa391 34=over 4
a3d98218 35
36=item C<traits>, not C<metaclass>
37
93ced2bd 38Method providers are only available via traits.
a3d98218 39
40=item C<handles>, not C<provides> or C<curries>
41
93ced2bd 42The C<provides> syntax was like core Moose C<< handles => HASHREF >>
43syntax, but with the keys and values reversed. This was confusing,
44and AttributeHelpers now uses C<< handles => HASHREF >> in a way that
45should be intuitive to anyone already familiar with how it is used for
46other attributes.
a3d98218 47
93ced2bd 48The C<curries> functionality provided by AttributeHelpers has been
49generalized to apply to all cases of C<< handles => HASHREF >>, though
50not every piece of functionality has been ported (currying with a
51CODEREF is not supported).
a3d98218 52
1853a27e 53=item C<empty> is now C<is_empty>, and means empty, not non-empty
af44c00c 54
55Previously, the C<empty> method provided by Arrays and Hashes returned true if
56the attribute was B<not> empty (no elements). Now it returns true if the
1853a27e 57attribute B<is> empty. It was also renamed to C<is_empty>, to reflect this.
af44c00c 58
9a14bd29 59=item C<find> was renamed to C<first>, and C<first> and C<last> were removed
28b96142 60
61L<List::Util> refers to the functionality that we used to provide under C<find>
62as L<first|List::Util/first>, so that will likely be more familiar (and will
9a14bd29 63fit in better if we decide to add more List::Util functions). C<first> and
64C<last> were removed, since their functionality is easily duplicated with
65curries of C<get>.
28b96142 66
67=item Helpers that take a coderef of one argument now use C<$_>
68
69Subroutines passed as the first argument to C<first>, C<map>, and C<grep> now
70receive their argument in C<$_> rather than as a parameter to the subroutine.
71Helpers that take a coderef of two or more arguments remain using the argument
72list (there are technical limitations to using C<$a> and C<$b> like C<sort>
73does).
74
af44c00c 75See L<Moose::Meta::Attribute::Native> for the new documentation.
a3d98218 76
ebaaa391 77=back
78
4ada9618 79=head1 Version 0.89
80
8a8856de 81C<< use Moose -metaclass => 'Foo' >> now does alias resolution, just like
82C<-traits> (and the C<metaclass> and C<traits> options to C<has>).
83
27f2f43f 84Added two functions C<meta_class_alias> and C<meta_attribute_alias> to
85L<Moose::Util>, to simplify aliasing metaclasses and metatraits. This is
86a wrapper around the old
87
88 package Moose::Meta::Class::Custom::Trait::FooTrait;
89 sub register_implementation { 'My::Meta::Trait' }
90
91way of doing this.
92
c8b8d92f 93The C<alias> and C<excludes> role parameters have been renamed to C<-alias>
94and C<-excludes>. The old names still work, but new code should use the new
95names, and eventually the old ones will be deprecated and removed.
96
4831e2de 97=head1 Version 0.84
98
9f52cce5 99When an attribute generates I<no> accessors, we now warn. This is to help
100users who forget the C<is> option. If you really do not want any accessors,
3de02fd8 101you can use C<< is => 'bare' >>. You can maintain back compat with older
102versions of Moose by using something like:
103
104 ($Moose::VERSION >= 0.84 ? is => 'bare' : ())
9f52cce5 105
106When an accessor overwrites an existing method, we now warn. To work around
107this warning (if you really must have this behavior), you can explicitly
108remove the method before creating it as an accessor:
109
110 sub foo {}
111
112 __PACKAGE__->meta->remove_method('foo');
113
114 has foo => (
115 is => 'ro',
116 );
117
118When an unknown option is passed to C<has>, we now warn. You can silence
119the warning by fixing your code. :)
120
4831e2de 121The C<Role> type has been deprecated. On its own, it was useless,
122since it just checked C<< $object->can('does') >>. If you were using
123it as a parent type, just call C<role_type('Role::Name')> to create an
124appropriate type instead.
125
7d6b451f 126=head1 Version 0.78
127
128C<use Moose::Exporter;> now imports C<strict> and C<warnings> into packages
129that use it.
130
c3fdacda 131=head1 Version 0.77
132
133C<DEMOLISHALL> and C<DEMOLISH> now receive an argument indicating whether or
134not we are in global destruction.
135
00c61603 136=head1 Version 0.76
137
9f0b3b64 138Type constraints no longer run coercions for a value that already matches the
139constraint. This may affect some (arguably buggy) edge case coercions that
140rely on side effects in the C<via> clause.
141
f869fc4a 142=head1 Version 0.75
143
144L<Moose::Exporter> now accepts the C<-metaclass> option for easily
145overriding the metaclass (without L<metaclass>). This works for classes
146and roles.
147
39ab7714 148=head1 Version 0.74
149
85cf0647 150Added a C<duck_type> sugar function to L<Moose::Util::TypeConstraints>
151to make integration with non-Moose classes easier. It simply checks if
152C<< $obj->can() >> a list of methods.
39ab7714 153
612fd754 154A number of methods (mostly inherited from L<Class::MOP>) have been
155renamed with a leading underscore to indicate their internal-ness. The
156old method names will still work for a while, but will warn that the
157method has been renamed. In a few cases, the method will be removed
158entirely in the future. This may affect MooseX authors who were using
159these methods.
160
600f7f85 161=head1 Version 0.73
162
0f13f53c 163Calling C<subtype> with a name as the only argument now throws an
600f7f85 164exception. If you want an anonymous subtype do:
165
166 my $subtype = subtype as 'Foo';
167
0f13f53c 168This is related to the changes in version 0.71_01.
600f7f85 169
501db4e6 170The C<is_needed> method in L<Moose::Meta::Method::Destructor> is now
171only usable as a class method. Previously, it worked as a class or
172object method, with a different internal implementation for each
173version.
174
175The internals of making a class immutable changed a lot in Class::MOP
1760.78_02, and Moose's internals have changed along with it. The
177external C<< $metaclass->make_immutable >> method still works the same
178way.
179
600f7f85 180=head1 Version 0.72
181
0f13f53c 182A mutable class accepted C<< Foo->new(undef) >> without complaint,
183while an immutable class would blow up with an unhelpful error. Now,
184in both cases we throw a helpful error instead.
600f7f85 185
0f13f53c 186This "feature" was originally added to allow for cases such as this:
600f7f85 187
188 my $args;
0f13f53c 189
190 if ( something() ) {
191 $args = {...};
600f7f85 192 }
0f13f53c 193
600f7f85 194 return My::Class->new($args);
195
0f13f53c 196But we decided this is a bad idea and a little too magical, because it
197can easily mask real errors.
600f7f85 198
199=head1 Version 0.71_01
200
0f13f53c 201Calling C<type> or C<subtype> without the sugar helpers (C<as>,
202C<where>, C<message>) is now deprecated.
203
204As a side effect, this meant we ended up using Perl prototypes on
205C<as>, and code like this will no longer work:
600f7f85 206
207 use Moose::Util::TypeConstraints;
208 use Declare::Constraints::Simple -All;
0f13f53c 209
210 subtype 'ArrayOfInts'
600f7f85 211 => as 'ArrayRef'
212 => IsArrayRef(IsInt);
213
214Instead it must be changed to this:
215
0f13f53c 216 subtype(
217 'ArrayOfInts' => {
218 as => 'ArrayRef',
219 where => IsArrayRef(IsInt)
220 }
600f7f85 221 );
222
0f13f53c 223If you want to maintain backwards compat with older versions of Moose,
224you must explicitly test Moose's C<VERSION>:
600f7f85 225
0f13f53c 226 if ( Moose->VERSION < 0.71_01 ) {
227 subtype 'ArrayOfInts'
600f7f85 228 => as 'ArrayRef'
229 => IsArrayRef(IsInt);
230 }
231 else {
0f13f53c 232 subtype(
233 'ArrayOfInts' => {
234 as => 'ArrayRef',
235 where => IsArrayRef(IsInt)
236 }
600f7f85 237 );
238 }
239
240=head1 Version 0.70
241
0f13f53c 242We no longer pass the meta-attribute object as a final argument to
243triggers. This actually changed for inlined code a while back, but the
244non-inlined version and the docs were still out of date.
245
246If by some chance you actually used this feature, the workaround is
247simple. You fetch the attribute object from out of the C<$self>
248that is passed as the first argument to trigger, like so:
249
250 has 'foo' => (
251 is => 'ro',
252 isa => 'Any',
253 trigger => sub {
254 my ( $self, $value ) = @_;
255 my $attr = $self->meta->find_attribute_by_name('foo');
256
257 # ...
258 }
259 );
600f7f85 260
261=head1 Version 0.66
262
0f13f53c 263If you created a subtype and passed a parent that Moose didn't know
264about, it simply ignored the parent. Now it automatically creates the
265parent as a class type. This may not be what you want, but is less
266broken than before.
600f7f85 267
0f13f53c 268You could declare a name with subtype such as "Foo!Bar". Moose would
269accept this allowed, but if you used it in a parameterized type such
270as "ArrayRef[Foo!Bar]" it wouldn't work. We now do some vetting on
271names created via the sugar functions, so that they can only contain
272alphanumerics, ":", and ".".
600f7f85 273
274=head1 Version 0.65
275
276Methods created via an attribute can now fulfill a C<requires>
0f13f53c 277declaration for a role. Honestly we don't know why Stevan didn't make
278this work originally, he was just insane or something.
600f7f85 279
0f13f53c 280Stack traces from inlined code will now report the line and file as
281being in your class, as opposed to in Moose guts.
600f7f85 282
283=head1 Version 0.62_02
284
0f13f53c 285When a class does not provide all of a role's required methods, the
286error thrown now mentions all of the missing methods, as opposed to
287just the first missing method.
600f7f85 288
0f13f53c 289Moose will no longer inline a constructor for your class unless it
5e26e3f2 290inherits its constructor from Moose::Object, and will warn when it
291doesn't inline. If you want to force inlining anyway, pass
b84f64da 292C<< replace_constructor => 1 >> to C<make_immutable>.
0f13f53c 293
294If you want to get rid of the warning, pass C<< inline_constructor =>
fbf7ba85 2950 >>.
600f7f85 296
297=head1 Version 0.62
298
0f13f53c 299Removed the (deprecated) C<make_immutable> keyword.
600f7f85 300
301Removing an attribute from a class now also removes delegation
0f13f53c 302(C<handles>) methods installed for that attribute. This is correct
600f7f85 303behavior, but if you were wrongly relying on it you might get bit.
304
305=head1 Version 0.58
306
0f13f53c 307Roles now add methods by calling C<add_method>, not
308C<alias_method>. They make sure to always provide a method object,
309which will be cloned internally. This means that it is now possible to
310track the source of a method provided by a role, and even follow its
311history through intermediate roles. This means that methods added by
312a role now show up when looking at a class's method list/map.
313
314Parameter and Union args are now sorted, this makes Int|Str the same
315constraint as Str|Int. Also, incoming type constraint strings are
316normalized to remove all whitespace differences. This is mostly for
317internals and should not affect outside code.
318
319L<Moose::Exporter> will no longer remove a subroutine that the
320exporting package re-exports. Moose re-exports the Carp::confess
321function, among others. The reasoning is that we cannot know whether
322you have also explicitly imported those functions for your own use, so
323we err on the safe side and always keep them.
600f7f85 324
325=head1 Version 0.56
326
0f13f53c 327C<Moose::init_meta> should now be called as a method.
600f7f85 328
0f13f53c 329New modules for extension writers, L<Moose::Exporter> and
330L<Moose::Util::MetaRole>.
600f7f85 331
332=head1 Version 0.55_01
333
334Implemented metaclass traits (and wrote a recipe for it):
335
336 use Moose -traits => 'Foo'
337
338This should make writing small Moose extensions a little
339easier.
340
341=head1 Version 0.55
342
343Fixed C<coerce> to accept anon types just like C<subtype> can.
344So that you can do:
345
346 coerce $some_anon_type => from 'Str' => via { ... };
347
348=head1 Version 0.51
349
52da380a 350Added C<BUILDARGS>, a new step in C<< Moose::Object->new() >>.
600f7f85 351
352=head1 Version 0.49
353
0f13f53c 354Fixed how the C<< is => (ro|rw) >> works with custom defined
355C<reader>, C<writer> and C<accessor> options. See the below table for
600f7f85 356details:
357
358 is => ro, writer => _foo # turns into (reader => foo, writer => _foo)
359 is => rw, writer => _foo # turns into (reader => foo, writer => _foo)
360 is => rw, accessor => _foo # turns into (accessor => _foo)
361 is => ro, accessor => _foo # error, accesor is rw
362
363=head1 Version 0.45
364
0f13f53c 365The C<before/around/after> method modifiers now support regexp
366matching of method names. NOTE: this only works for classes, it is
367currently not supported in roles, but, ... patches welcome.
600f7f85 368
0f13f53c 369The C<has> keyword for roles now accepts the same array ref form that
370L<Moose>.pm does for classes.
600f7f85 371
0f13f53c 372A trigger on a read-only attribute is no longer an error, as it's
373useful to trigger off of the constructor.
600f7f85 374
0f13f53c 375Subtypes of parameterizable types now are parameterizable types
376themselves.
600f7f85 377
378=head1 Version 0.44
379
0f13f53c 380Fixed issue where C<DEMOLISHALL> was eating the value in C<$@>, and so
381not working correctly. It still kind of eats them, but so does vanilla
382perl.
600f7f85 383
384=head1 Version 0.41
385
0f13f53c 386Inherited attributes may now be extended without restriction on the
600f7f85 387type ('isa', 'does').
388
0f13f53c 389The entire set of Moose::Meta::TypeConstraint::* classes were
390refactored in this release. If you were relying on their internals you
391should test your code carefully.
600f7f85 392
393=head1 Version 0.40
394
0f13f53c 395Documenting the use of '+name' with attributes that come from recently
396composed roles. It makes sense, people are using it, and so why not
397just officially support it.
600f7f85 398
0f13f53c 399The C<< Moose::Meta::Class->create >> method now supports roles.
600f7f85 400
86b96832 401It is now possible to make anonymous enum types by passing C<enum> an
402array reference instead of the C<< enum $name => @values >>.
600f7f85 403
404=head1 Version 0.37
405
0f13f53c 406Added the C<make_immutable> keyword as a shortcut to calling
407C<make_immutable> on the meta object. This eventually got removed!
600f7f85 408
0f13f53c 409Made C<< init_arg => undef >> work in Moose. This means "do not accept
600f7f85 410a constructor parameter for this attribute".
411
0f13f53c 412Type errors now use the provided message. Prior to this release they
413didn't.
600f7f85 414
415=head1 Version 0.34
416
417Moose is now a postmodern object system :)
418
0f13f53c 419The Role system was completely refactored. It is 100% backwards
420compat, but the internals were totally changed. If you relied on the
421internals then you are advised to test carefully.
600f7f85 422
423Added method exclusion and aliasing for Roles in this release.
424
0f13f53c 425Added the L<Moose::Util::TypeConstraints::OptimizedConstraints>
426module.
600f7f85 427
0f13f53c 428Passing a list of values to an accessor (which is only expecting one
429value) used to be silently ignored, now it throws an error.
600f7f85 430
431=head1 Version 0.26
432
0f13f53c 433Added parameterized types and did a pretty heavy refactoring of the
434type constraint system.
600f7f85 435
0f13f53c 436Better framework extendability and better support for "making your own
437Moose".
600f7f85 438
439=head1 Version 0.25 or before
440
0f13f53c 441Honestly, you shouldn't be using versions of Moose that are this old,
442so many bug fixes and speed improvements have been made you would be
443crazy to not upgrade.
600f7f85 444
0f13f53c 445Also, I am tired of going through the Changelog so I am stopping here,
446if anyone would like to continue this please feel free.
600f7f85 447
448=head1 AUTHOR
449
450Stevan Little E<lt>stevan@iinteractive.comE<gt>
451
452=head1 COPYRIGHT AND LICENSE
453
454Copyright 2009 by Infinity Interactive, Inc.
455
456L<http://www.iinteractive.com>
457
458This library is free software; you can redistribute it and/or modify
459it under the same terms as Perl itself.
460
0f13f53c 461=cut