More POD typos (RT#77453)
[gitmo/Class-C3.git] / lib / Class / C3.pm
index 2af5370..3551a1e 100644 (file)
@@ -4,7 +4,7 @@ package Class::C3;
 use strict;
 use warnings;
 
-our $VERSION = '0.23';
+our $VERSION = '0.24';
 
 our $C3_IN_CORE;
 our $C3_XS;
@@ -14,17 +14,27 @@ BEGIN {
         $C3_IN_CORE = 1;
         require mro;
     }
-    else {
-        eval "require Class::C3::XS";
-        my $error = $@;
-        if(!$error) {
-            $C3_XS = 1;
-        }
-        else {
+    elsif($C3_XS or not defined $C3_XS) {
+        my $error = do {
+            local $@;
+            eval { require Class::C3::XS };
+            $@;
+        };
+
+        if ($error) {
             die $error if $error !~ /\blocate\b/;
+
+            if ($C3_XS) {
+                require Carp;
+                Carp::croak( "XS explicitly requested but Class::C3::XS is not available" );
+            }
+
             require Algorithm::C3;
             require Class::C3::next;
         }
+        else {
+            $C3_XS = 1;
+        }
     }
 }
 
@@ -34,7 +44,7 @@ BEGIN {
 # this:
 #
 #   $MRO{$class} = {
-#      MRO => [ <class precendence list> ],
+#      MRO => [ <class precedence list> ],
 #      methods => {
 #          orig => <original location of method>,
 #          code => \&<ref to original method>
@@ -223,7 +233,7 @@ __END__
 
 =head1 NAME
 
-Class::C3 - A pragma to use the C3 method resolution order algortihm
+Class::C3 - A pragma to use the C3 method resolution order algorithm
 
 =head1 SYNOPSIS
 
@@ -280,13 +290,13 @@ to using this implementation on older perls.
 
 C3 is the name of an algorithm which aims to provide a sane method resolution order under multiple
 inheritance. It was first introduced in the langauge Dylan (see links in the L<SEE ALSO> section),
-and then later adopted as the prefered MRO (Method Resolution Order) for the new-style classes in
+and then later adopted as the preferred MRO (Method Resolution Order) for the new-style classes in
 Python 2.3. Most recently it has been adopted as the 'canonical' MRO for Perl 6 classes, and the
 default MRO for Parrot objects as well.
 
 =head2 How does C3 work.
 
-C3 works by always preserving local precendence ordering. This essentially means that no class will
+C3 works by always preserving local precedence ordering. This essentially means that no class will
 appear before any of its subclasses. Take the classic diamond inheritance pattern for instance:
 
      <A>
@@ -340,7 +350,7 @@ Given a C<$class> this will return an array of class names in the proper C3 meth
 
 =item B<initialize>
 
-This B<must be called> to initalize the C3 method dispatch tables, this module B<will not work> if
+This B<must be called> to initialize the C3 method dispatch tables, this module B<will not work> if
 you do not do this. It is advised to do this as soon as possible B<after> loading any classes which
 use C3. Here is a quick code example:
 
@@ -445,7 +455,7 @@ But there are still caveats, so here goes ...
 
 =item Use of C<SUPER::>.
 
-The idea of C<SUPER::> under multiple inheritance is ambigious, and generally not recomended anyway.
+The idea of C<SUPER::> under multiple inheritance is ambiguous, and generally not recomended anyway.
 However, its use in conjuntion with this module is very much not recommended, and in fact very
 discouraged. The recommended approach is to instead use the supplied C<next::method> feature, see
 more details on its usage above.
@@ -497,7 +507,7 @@ If your software is meant to work on earlier Perls, use L<Class::C3> as document
 
 =head1 Class::C3::XS
 
-This module will load L<Class::C3::XS> if it's installed and you are running on a Perl version older than 5.9.5.  Installing this is recommended when possible, as it results in significant performance improvements (but unlike the 5.9.5+ core support, it still has all of the same caveats as L<Class::C3>).
+This module will load L<Class::C3::XS> if it's installed and you are running on a Perl version older than 5.9.5.  The optional module will be automatically installed for you if a C compiler is available, as it results in significant performance improvements (but unlike the 5.9.5+ core support, it still has all of the same caveats as L<Class::C3>).
 
 =head1 CODE COVERAGE