{
    "content": [
        {
            "type": "text",
            "text": "# PERLMROAPI(1) (man)\n\n**Summary:** perlmroapi - Perl method resolution plugin interface\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **DESCRIPTION** (34 lines)\n- **Callbacks** (14 lines)\n- **Caching** (15 lines)\n- **Examples** (3 lines)\n- **AUTHORS** (7 lines)\n\n## Full Content\n\n### NAME\n\nperlmroapi - Perl method resolution plugin interface\n\n### DESCRIPTION\n\nAs 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\n### Callbacks\n\nThe \"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 the parent classes in order.\nThe names of the classes should be the result of calling \"HvENAME()\" on the stash. In those\ncases 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\nyour return value, then return a pointer to it without changing the reference count.\n\n### Caching\n\nComputing 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\n### Examples\n\nFor examples of MRO implementations, see \"Smrogetlinearisac3()\" and the \"BOOT:\" section\nof ext/mro/mro.xs, and \"Smrogetlinearisadfs()\" in mrocore.c\n\n### AUTHORS\n\nThe 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\n\n\nperl v5.34.0                                 2025-07-25                                PERLMROAPI(1)\n\n"
        }
    ],
    "structuredContent": {
        "command": "PERLMROAPI",
        "section": "1",
        "mode": "man",
        "summary": "perlmroapi - Perl method resolution plugin interface",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 34,
                "subsections": []
            },
            {
                "name": "Callbacks",
                "lines": 14,
                "subsections": []
            },
            {
                "name": "Caching",
                "lines": 15,
                "subsections": []
            },
            {
                "name": "Examples",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 7,
                "subsections": []
            }
        ]
    }
}