{
    "mode": "man",
    "parameter": "perlmroapi",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/perlmroapi/1/json",
    "generated": "2026-10-04T13:18:20Z",
    "sections": {
        "NAME": {
            "content": "perlmroapi - Perl method resolution plugin interface\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "As of Perl 5.10.1 there is a new interface for plugging and using method resolution orders\nother than the default (linear depth first search).  The C3 method resolution order added in\n5.10.0 has been re-implemented as a plugin, without changing its Perl-space interface.\n\nEach plugin should register itself by providing the following structure\n\nstruct mroalg {\nAV *(*resolve)(pTHX HV *stash, U32 level);\nconst char *name;\nU16 length;\nU16 kflags;\nU32 hash;\n};\n\nand calling \"Perlmroregister\":\n\nPerlmroregister(aTHX &mymroalg);\n\nresolve\nPointer to the linearisation function, described below.\n\nname\nName of the MRO, either in ISO-8859-1 or UTF-8.\n\nlength\nLength of the name.\n\nkflags\nIf  the  name  is given in UTF-8, set this to \"HVhekUTF8\". The value is passed direct as\nthe parameter kflags to hvcommon().\n\nhash\nA precomputed hash value for the MRO's name, or 0.\n",
            "subsections": []
        },
        "Callbacks": {
            "content": "The \"resolve\" function is called to generate a linearised ISA for the given stash, using this\nMRO. It is called with a pointer to the stash, and a level of 0. The core always  sets  level\nto  0 when it calls your function - the parameter is provided to allow your implementation to\ntrack depth if it needs to recurse.\n\nThe function should return a reference to an array containing string SVs giving the names  of\nparent  classes  in order. The names of the classes should be the result of calling HvENAME()\non the stash. In those cases where HvENAME() returns null, HvNAME() should be used instead.\n\nThe caller is responsible for incrementing the reference count of the array  returned  if  it\nwants  to  keep  the structure. Hence, if you have created a temporary value that you keep no\npointer to, sv2mortal() to ensure that it is disposed of correctly. If you have cached  your\nreturn value, then return a pointer to it without changing the reference count.\n",
            "subsections": []
        },
        "Caching": {
            "content": "Computing  MROs can be expensive. The implementation provides a cache, in which you can store\na single \"SV *\", or anything that can be cast to \"SV *\", such as \"AV *\". To read your private\nvalue, use the macro MROGETPRIVATEDATA(), passing it the  \"mrometa\"  structure  from  the\nstash, and a pointer to your \"mroalg\" structure:\n\nmeta = HvMROMETA(stash);\nprivatesv = MROGETPRIVATEDATA(meta, &mymroalg);\n\nTo set your private value, call Perlmrosetprivatedata():\n\nPerlmrosetprivatedata(aTHX meta, &c3alg, privatesv);\n\nThe  private  data  cache will take ownership of a reference to privatesv, much the same way\nthat hvstore() takes ownership of a reference to the value that you pass it.\n",
            "subsections": []
        },
        "Examples": {
            "content": "For examples of MRO implementations, see Smrogetlinearisac3() and the \"BOOT:\" section of\next/mro/mro.xs, and Smrogetlinearisadfs() in mrocore.c\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "The implementation of the C3 MRO and switchable MROs within the  perl  core  was  written  by\nBrandon  L  Black.  Nicholas  Clark  created  the  pluggable  interface, refactored Brandon's\nimplementation to work with it, and wrote this document.\n\nperl v5.38.2                                 2026-08-18                                PERLMROAPI(1)",
            "subsections": []
        }
    },
    "summary": "perlmroapi - Perl method resolution plugin interface",
    "flags": [],
    "examples": [],
    "see_also": []
}