{"id":7100,"date":"2022-12-20T19:35:16","date_gmt":"2022-12-20T22:35:16","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/mrocompat-man3\/"},"modified":"2022-12-20T19:35:16","modified_gmt":"2022-12-20T22:35:16","slug":"mrocompat-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/mrocompat-man3\/","title":{"rendered":"MRO::Compat (man3)"},"content":{"rendered":"<h1 align=\"center\">MRO::Compat<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#Functions\">Functions<\/a><br \/> <a href=\"#USING C3\">USING C3<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#AUTHOR\">AUTHOR<\/a><br \/> <a href=\"#COPYRIGHT AND LICENSE\">COPYRIGHT AND LICENSE<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">MRO::Compat \u2212 mro::* interface compatibility for Perls < 5.9.5<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">package PPP; use base qw\/Exporter\/; <br \/> package X; use base qw\/PPP\/; <br \/> package Y; use base qw\/PPP\/; <br \/> package Z; use base qw\/PPP\/; <br \/> package FooClass; use base qw\/X Y Z\/; <br \/> package main; <br \/> use MRO::Compat; <br \/> my $linear = mro::get_linear_isa(&#8216;FooClass&#8217;); <br \/> print join(q{, }, @$linear); <br \/> # Prints: FooClass, X, PPP, Exporter, Y, Z<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The &#8220;mro&#8221; namespace provides several utilities for dealing with method resolution order and method caching in general in Perl 5.9.5 and higher.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This module provides those interfaces for earlier versions of Perl (back to 5.6.0 anyways).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">It is a harmless no-op to use this module on 5.9.5+. That is to say, code which properly uses MRO::Compat will work unmodified on both older Perls and 5.9.5+.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If you\u2019re writing a piece of software that would like to use the parts of 5.9.5+\u2019s mro:: interfaces that are supported here, and you want compatibility with older Perls, this is the module for you.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Some parts of this code will work better and\/or faster with Class::C3::XS installed (which is an optional prereq of Class::C3, which is in turn a prereq of this package), but it\u2019s not a requirement.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This module never exports any functions. All calls must be fully qualified with the &#8220;mro::&#8221; prefix.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The interface documentation here serves only as a quick reference of what the function basically does, and what differences between MRO::Compat and 5.9.5+ one should look out for. The main docs in 5.9.5\u2019s mro are the real interface docs, and contain a lot of other useful information.<\/p>\n<h2>Functions <a name=\"Functions\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>mro::get_linear_isa($classname[, $type])<\/b> <br \/> Returns an arrayref which is the linearized &#8221; <small>ISA&#8221;<\/small> of the given class. Uses whichever <small>MRO<\/small> is currently in effect for that class by default, or the given <small>MRO<\/small> (either &#8220;c3&#8221; or &#8220;dfs&#8221; if specified as $type).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The linearized <small>ISA<\/small> of a class is a single ordered list of all of the classes that would be visited in the process of resolving a method on the given class, starting with itself. It does not include any duplicate entries.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Note that &#8220;UNIVERSAL&#8221; (and any members of &#8220;UNIVERSAL&#8221;\u2019s <small>MRO<\/small> ) are not part of the <small>MRO<\/small> of a class, even though all classes implicitly inherit methods from &#8220;UNIVERSAL&#8221; and its parents.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>mro::import<\/b> <br \/> This allows the &#8220;use mro &#8216;dfs'&#8221; and &#8220;use mro &#8216;c3&#8242;&#8221; syntaxes, providing you &#8220;use MRO::Compat&#8221; first. Please see the &#8221; <small>USING C3&#8243;<\/small> section for additional details.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>mro::set_mro($classname, $type)<\/b> <br \/> Sets the mro of $classname to one of the types &#8220;dfs&#8221; or &#8220;c3&#8243;. Please see the &#8221; <small>USING C3&#8243;<\/small> section for additional details.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>mro::get_mro($classname)<\/b> <br \/> Returns the <small>MRO<\/small> of the given class (either &#8220;c3&#8221; or &#8220;dfs&#8221;).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">It considers any Class::C3\u2212using class to have C3 <small>MRO<\/small> even before <b>Class::C3::initialize()<\/b> is called.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>mro::get_isarev($classname)<\/b> <br \/> Returns an arrayref of classes who are subclasses of the given classname. In other words, classes in whose @ISA hierarchy we appear, no matter how indirectly.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This is much slower on pre\u22125.9.5 Perls with MRO::Compat than it is on 5.9.5+, as it has to search the entire package namespace.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>mro::is_universal($classname)<\/b> <br \/> Returns a boolean status indicating whether or not the given classname is either &#8220;UNIVERSAL&#8221; itself, or one of &#8220;UNIVERSAL&#8221;\u2019s parents by @ISA inheritance.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Any class for which this function returns true is &#8220;universal&#8221; in the sense that all classes potentially inherit methods from it.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>mro::invalidate_all_method_caches<\/b> <br \/> Increments &#8220;PL_sub_generation&#8221;, which invalidates method caching in all packages.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Please note that this is rarely necessary, unless you are dealing with a situation which is known to confuse Perl\u2019s method caching.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>mro::method_changed_in($classname)<\/b> <br \/> Invalidates the method cache of any classes dependent on the given class. In MRO::Compat on pre\u22125.9.5 Perls, this is an alias for &#8220;mro::invalidate_all_method_caches&#8221; above, as pre\u22125.9.5 Perls have no other way to do this. It will still enforce the requirement that you pass it a classname, for compatibility.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Please note that this is rarely necessary, unless you are dealing with a situation which is known to confuse Perl\u2019s method caching.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>mro::get_pkg_gen($classname)<\/b> <br \/> Returns an integer which is incremented every time a local method of or the @ISA of the given package changes on Perl 5.9.5+. On earlier Perls with this MRO::Compat module, it will probably increment a lot more often than necessary.<\/p>\n<h2>USING C3 <a name=\"USING C3\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">While this module makes the 5.9.5+ syntaxes &#8220;use mro &#8216;c3&#8242;&#8221; and &#8220;mro::set_mro(&#8220;Foo&#8221;, &#8216;c3&#8217;)&#8221; available on older Perls, it does so merely by passing off the work to Class::C3.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">It does not remove the need for you to call &#8220;Class::C3::initialize()&#8221;, &#8220;Class::C3::reinitialize()&#8221;, and\/or &#8220;Class::C3::uninitialize()&#8221; at the appropriate times as documented in the Class::C3 docs. These three functions are always provided by MRO::Compat, either via Class::C3 itself on older Perls, or directly as no-ops on 5.9.5+.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Class::C3<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">mro<\/p>\n<h2>AUTHOR <a name=\"AUTHOR\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Brandon L. Black, <blblack@gmail.com><\/p>\n<h2>COPYRIGHT AND LICENSE <a name=\"COPYRIGHT AND LICENSE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Copyright 2007\u22122008 Brandon L. Black <blblack@gmail.com><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This library is free software; you can redistribute it and\/or modify it under the same terms as Perl itself.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  MRO::Compat \u2212 mro::* interface compatibility for Perls  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3007,3444],"class_list":["post-7100","post","type-post","status-publish","format-standard","hentry","category-sin-categoria","tag-man3","tag-mrocompat"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7100"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7100\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}