Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Add copyright and license. POD cleanup. Mention Moose::Role.
Browse files Browse the repository at this point in the history
  • Loading branch information
schwern committed Jan 22, 2010
1 parent 900c9d5 commit 2dd25b7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
- Slightly better error message when trying to use a mixin and you're
not of the right class.

Documentation:
* Add copyright and license


0.06 Wed Apr 18 10:08:59 PDT 2007
Documentation:
* Documented the behavior of SUPER
Expand Down
35 changes: 31 additions & 4 deletions lib/mixin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ The idea is to solve the same sets of problems which MI solves without
the problems of MI. For all practical purposes you can think of a
mixin as multiple inheritance without the actual inheritance.
Mixins are a band-aid for the problems of MI. A better solution is to use traits (called "Roles" in Perl 6), which are like mixins on steroids. Class::Trait implements this.
Mixins are a band-aid for the problems of MI. A better solution is to
use traits (called "Roles" in Perl 6), which are like mixins on
steroids. Class::Trait implements this.
=head2 Using a mixin class
Expand Down Expand Up @@ -70,7 +72,9 @@ See L<mixin::with>.
=head2 Mixins, Inheritance and SUPER
A class which uses a mixin I<does not> inherit from it. However, through some clever trickery, C<SUPER> continues to work. Here's an example.
A class which uses a mixin I<does not> inherit from it. However,
through some clever trickery, C<SUPER> continues to work. Here's an
example.
{
package Parent;
Expand Down Expand Up @@ -100,9 +104,17 @@ A class which uses a mixin I<does not> inherit from it. However, through some c
print join " ", Child->foo; # Parent Middle Child
This will print C<Parent Middle Child>. You'll note that this is the same result if Child inherited from Middle and Middle from Parent. Its also the same result if Child multiply inherited from Middle and Parent but I<NOT> if it inherited from Parent then Middle. The advantage of mixins vs multiple inheritance is such ambiguities do not exist.
This will print C<Parent Middle Child>. You'll note that this is the
same result if Child inherited from Middle and Middle from Parent.
Its also the same result if Child multiply inherited from Middle and
Parent but I<NOT> if it inherited from Parent then Middle. The
advantage of mixins vs multiple inheritance is such ambiguities do not
exist.
Note that even though both the Child and Middle define foo() the Middle mixin does not overwrite Child's foo(). A mixin does not simply export its methods into the mixer and thus does not blow over existing methods.
Note that even though both the Child and Middle define foo() the
Middle mixin does not overwrite Child's foo(). A mixin does not
simply export its methods into the mixer and thus does not blow over
existing methods.
=cut

Expand Down Expand Up @@ -182,15 +194,30 @@ sub _croak {
A mixin will not warn if the mixin and the user define the same method.
=head1 AUTHOR
Michael G Schwern E<lt>[email protected]E<gt>
=head1 LICENSE
Copyright 2002-2010 by Michael G Schwern
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
L<http://dev.perl.org/licenses/>
=head1 SEE ALSO
L<Class::Trait> - mixin.pm is a gateway drug to traits
L<Class::C3> - another band-aid on multiple inheritance
L<Moose::Role> - Moose's implementation of traits/roles.
=cut

1;

0 comments on commit 2dd25b7

Please sign in to comment.