Blame README

Packit 4c8e34
NAME
Packit 4c8e34
    MRO::Compat - mro::* interface compatibility for Perls < 5.9.5
Packit 4c8e34
Packit 4c8e34
SYNOPSIS
Packit 4c8e34
       package PPP;      use base qw/Exporter/;
Packit 4c8e34
       package X;        use base qw/PPP/;
Packit 4c8e34
       package Y;        use base qw/PPP/;
Packit 4c8e34
       package Z;        use base qw/PPP/;
Packit 4c8e34
Packit 4c8e34
       package FooClass; use base qw/X Y Z/;
Packit 4c8e34
Packit 4c8e34
       package main;
Packit 4c8e34
       use MRO::Compat;
Packit 4c8e34
       my $linear = mro::get_linear_isa('FooClass');
Packit 4c8e34
       print join(q{, }, @$linear);
Packit 4c8e34
Packit 4c8e34
       # Prints: FooClass, X, PPP, Exporter, Y, Z
Packit 4c8e34
Packit 4c8e34
DESCRIPTION
Packit 4c8e34
    The "mro" namespace provides several utilities for dealing with method
Packit 4c8e34
    resolution order and method caching in general in Perl 5.9.5 and higher.
Packit 4c8e34
Packit 4c8e34
    This module provides those interfaces for earlier versions of Perl (back
Packit 4c8e34
    to 5.6.0 anyways).
Packit 4c8e34
Packit 4c8e34
    It is a harmless no-op to use this module on 5.9.5+. That is to say,
Packit 4c8e34
    code which properly uses MRO::Compat will work unmodified on both older
Packit 4c8e34
    Perls and 5.9.5+.
Packit 4c8e34
Packit 4c8e34
    If you're writing a piece of software that would like to use the parts
Packit 4c8e34
    of 5.9.5+'s mro:: interfaces that are supported here, and you want
Packit 4c8e34
    compatibility with older Perls, this is the module for you.
Packit 4c8e34
Packit 4c8e34
    Some parts of this code will work better and/or faster with
Packit 4c8e34
    Class::C3::XS installed (which is an optional prereq of Class::C3, which
Packit 4c8e34
    is in turn a prereq of this package), but it's not a requirement.
Packit 4c8e34
Packit 4c8e34
    This module never exports any functions. All calls must be fully
Packit 4c8e34
    qualified with the "mro::" prefix.
Packit 4c8e34
Packit 4c8e34
    The interface documentation here serves only as a quick reference of
Packit 4c8e34
    what the function basically does, and what differences between
Packit 4c8e34
    MRO::Compat and 5.9.5+ one should look out for. The main docs in 5.9.5's
Packit 4c8e34
    mro are the real interface docs, and contain a lot of other useful
Packit 4c8e34
    information.
Packit 4c8e34
Packit 4c8e34
Functions
Packit 4c8e34
  mro::get_linear_isa($classname[, $type])
Packit 4c8e34
    Returns an arrayref which is the linearized "ISA" of the given class.
Packit 4c8e34
    Uses whichever MRO is currently in effect for that class by default, or
Packit 4c8e34
    the given MRO (either "c3" or "dfs" if specified as $type).
Packit 4c8e34
Packit 4c8e34
    The linearized ISA of a class is a single ordered list of all of the
Packit 4c8e34
    classes that would be visited in the process of resolving a method on
Packit 4c8e34
    the given class, starting with itself. It does not include any duplicate
Packit 4c8e34
    entries.
Packit 4c8e34
Packit 4c8e34
    Note that "UNIVERSAL" (and any members of "UNIVERSAL"'s MRO) are not
Packit 4c8e34
    part of the MRO of a class, even though all classes implicitly inherit
Packit 4c8e34
    methods from "UNIVERSAL" and its parents.
Packit 4c8e34
Packit 4c8e34
  mro::import
Packit 4c8e34
    This allows the "use mro 'dfs'" and "use mro 'c3'" syntaxes, providing
Packit 4c8e34
    you "use MRO::Compat" first. Please see the "USING C3" section for
Packit 4c8e34
    additional details.
Packit 4c8e34
Packit 4c8e34
  mro::set_mro($classname, $type)
Packit 4c8e34
    Sets the mro of $classname to one of the types "dfs" or "c3". Please see
Packit 4c8e34
    the "USING C3" section for additional details.
Packit 4c8e34
Packit 4c8e34
  mro::get_mro($classname)
Packit 4c8e34
    Returns the MRO of the given class (either "c3" or "dfs").
Packit 4c8e34
Packit 4c8e34
    It considers any Class::C3-using class to have C3 MRO even before
Packit 4c8e34
    Class::C3::initialize() is called.
Packit 4c8e34
Packit 4c8e34
  mro::get_isarev($classname)
Packit 4c8e34
    Returns an arrayref of classes who are subclasses of the given
Packit 4c8e34
    classname. In other words, classes in whose @ISA hierarchy we appear, no
Packit 4c8e34
    matter how indirectly.
Packit 4c8e34
Packit 4c8e34
    This is much slower on pre-5.9.5 Perls with MRO::Compat than it is on
Packit 4c8e34
    5.9.5+, as it has to search the entire package namespace.
Packit 4c8e34
Packit 4c8e34
  mro::is_universal($classname)
Packit 4c8e34
    Returns a boolean status indicating whether or not the given classname
Packit 4c8e34
    is either "UNIVERSAL" itself, or one of "UNIVERSAL"'s parents by @ISA
Packit 4c8e34
    inheritance.
Packit 4c8e34
Packit 4c8e34
    Any class for which this function returns true is "universal" in the
Packit 4c8e34
    sense that all classes potentially inherit methods from it.
Packit 4c8e34
Packit 4c8e34
  mro::invalidate_all_method_caches
Packit 4c8e34
    Increments "PL_sub_generation", which invalidates method caching in all
Packit 4c8e34
    packages.
Packit 4c8e34
Packit 4c8e34
    Please note that this is rarely necessary, unless you are dealing with a
Packit 4c8e34
    situation which is known to confuse Perl's method caching.
Packit 4c8e34
Packit 4c8e34
  mro::method_changed_in($classname)
Packit 4c8e34
    Invalidates the method cache of any classes dependent on the given
Packit 4c8e34
    class. In MRO::Compat on pre-5.9.5 Perls, this is an alias for
Packit 4c8e34
    "mro::invalidate_all_method_caches" above, as pre-5.9.5 Perls have no
Packit 4c8e34
    other way to do this. It will still enforce the requirement that you
Packit 4c8e34
    pass it a classname, for compatibility.
Packit 4c8e34
Packit 4c8e34
    Please note that this is rarely necessary, unless you are dealing with a
Packit 4c8e34
    situation which is known to confuse Perl's method caching.
Packit 4c8e34
Packit 4c8e34
  mro::get_pkg_gen($classname)
Packit 4c8e34
    Returns an integer which is incremented every time a local method of or
Packit 4c8e34
    the @ISA of the given package changes on Perl 5.9.5+. On earlier Perls
Packit 4c8e34
    with this MRO::Compat module, it will probably increment a lot more
Packit 4c8e34
    often than necessary.
Packit 4c8e34
Packit 4c8e34
USING C3
Packit 4c8e34
    While this module makes the 5.9.5+ syntaxes "use mro 'c3'" and
Packit 4c8e34
    "mro::set_mro("Foo", 'c3')" available on older Perls, it does so merely
Packit 4c8e34
    by passing off the work to Class::C3.
Packit 4c8e34
Packit 4c8e34
    It does not remove the need for you to call "Class::C3::initialize()",
Packit 4c8e34
    "Class::C3::reinitialize()", and/or "Class::C3::uninitialize()" at the
Packit 4c8e34
    appropriate times as documented in the Class::C3 docs. These three
Packit 4c8e34
    functions are always provided by MRO::Compat, either via Class::C3
Packit 4c8e34
    itself on older Perls, or directly as no-ops on 5.9.5+.
Packit 4c8e34
Packit 4c8e34
SEE ALSO
Packit 4c8e34
    Class::C3
Packit 4c8e34
Packit 4c8e34
    mro
Packit 4c8e34
Packit 4c8e34
AUTHOR
Packit 4c8e34
    Brandon L. Black, <blblack@gmail.com>
Packit 4c8e34
Packit 4c8e34
COPYRIGHT AND LICENSE
Packit 4c8e34
    Copyright 2007-2008 Brandon L. Black <blblack@gmail.com>
Packit 4c8e34
Packit 4c8e34
    This library is free software; you can redistribute it and/or modify it
Packit 4c8e34
    under the same terms as Perl itself.
Packit 4c8e34