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