manpagez: man pages & more
man perlmroapi(1)
Home | html | info | man
PERLMROAPI(1pm)        Perl Programmers Reference Guide        PERLMROAPI(1pm)


       perlmroapi - Perl method resolution plugin interface


       method resolution orders other than the default (linear depth first

       Each plugin should register itself by providing the following structure

           struct mro_alg {
               const char *name;
               U16 length;
               U16 kflags;
               U32 hash;

       and calling "Perl_mro_register":

           Perl_mro_register(aTHX_ &my_mro_alg);

           Pointer to the linearisation function, described below.


           Length of the name.


           A precomputed hash value for the MRO's name, or 0.


       function - the parameter is provided to allow your implementation to
       track depth if it needs to recurse.

       The function should return a reference to an array containing the

       The caller is responsible for incrementing the reference count of the
       return value, then return a pointer to it without changing the
       reference count.


       Computing MROs can be expensive. The implementation provides a cache,
       in which you can store a single "SV *", or anything that can be cast to
       "SV *", such as "AV *". To read your private value, use the macro
       "MRO_GET_PRIVATE_DATA()", passing it the "mro_meta" structure from the
       stash, and a pointer to your "mro_alg" structure:

           meta = HvMROMETA(stash);
           private_sv = MRO_GET_PRIVATE_DATA(meta, &my_mro_alg);


           Perl_mro_set_private_data(aTHX_ meta, &c3_alg, private_sv);

       The private data cache will take ownership of a reference to
       reference to the value that you pass it.


       For examples of MRO implementations, see "S_mro_get_linear_isa_c3()"
       and the "BOOT:" section of ext/mro/mro.xs, and
       "S_mro_get_linear_isa_dfs()" in mro_core.c


       The implementation of the C3 MRO and switchable MROs within the perl
       core was written by Brandon L Black. Nicholas Clark created the
       pluggable interface, refactored Brandon's implementation to work with
       it, and wrote this document.

perl v5.24.0                      2016-03-01                   PERLMROAPI(1pm)

perl 5.24 - Generated Sun Dec 4 07:52:54 CST 2016
© 2000-2019
Individual documents may contain additional copyright information.