Class::...verload(3)

πŸ‘‘ Class::MOP::Overload β€” the Overload Meta Object πŸ’…

okay bestie, we're in Class::...verload(3) territory, aka the User Contributed Perl Documentation corner of the perl man pages, and this one is version 2.4000. she's giving meta-object realness and honestly? obsessed. πŸ¦‹


✨ NAME ✨

Class::MOP::Overload β€” the Overload Meta Object. that's it, that's the name, no notes. πŸ’–


🌸 VERSION 🌸

version 2.4000 β€” periodt, that's the version, don't come for me. ✨


πŸŽ€ SYNOPSIS πŸŽ€

here's the vibe check, literally copy-paste energy:

my $meta     = Class->meta;
my $overload = $meta->get_overloaded_operator('+');

if ( $overload->has_method_name ) {
    print 'Method for + is ', $overload->method_name, "\n";
}
else {
    print 'Overloading for + is implemented by ',
        $overload->coderef_name, " sub\n";
}

so you grab your meta, you grab the overload for '+', and then you check: does she have a method name? then print it. no? then it's a coderef situation and we print that instead. iconic branching tbh 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

This class provides meta information for overloading in classes and roles.

like. it's the ✨lore✨ behind your overloads. that's the whole job. she ate. πŸ’…


🌈 INHERITANCE 🌈

Class::MOP::Overload is a subclass of Class::MOP::Object.

family tree moment, we love a lineage. πŸ‘‘


πŸ’œ METHODS πŸ’œ

🌟 Class::MOP::Overload->new(%options)

This method creates a new Class::MOP::Overload object. It accepts a number of options:

  • operator β€” This is a string that matches an operator known by the overload module, such as "" or "+". This is required. no operator, no overload, sorry bestie. 😭
  • method_name β€” The name of the method which implements the overloading. Note that this does not need to actually correspond to a real method, since it's okay to declare a not-yet-implemented overloading. Either this or the coderef option must be passed. (manifesting a method that doesn't exist yet? valid. we've all been there.)
  • method β€” A Class::MOP::Method object for the method which implements the overloading. This is optional. πŸ™ˆ
  • coderef β€” A coderef which implements the overloading. Either this or the method_name option must be passed. it's giving "pick a lane, either of these works". πŸŽ€
  • coderef_package β€” The package where the coderef was defined. This is required if coderef is passed. don't skip this one. fr fr.
  • coderef_name β€” The name of the coderef. This can be "__ANON__". This is required if coderef is passed. yes you can literally name her "__ANON__", she's mysterious like that. 🧚
  • associated_metaclass β€” A Class::MOP::Module object for the associated class or role. This is optional. ✨

πŸ’– $overload->operator

Returns the operator for this overload object. the main character of the whole situation tbh.

πŸ’– $overload->method_name

Returns the method name that implements overloading, if it has one.

πŸ’– $overload->has_method_name

Returns true if the object has a method name. vibe check: passed βœ…

πŸ’– $overload->method

Returns the Class::MOP::Method that implements overloading, if it has one.

πŸ’– $overload->has_method

Returns true if the object has a method. βœ…

πŸ’– $overload->coderef

Returns the coderef that implements overloading, if it has one.

πŸ’– $overload->has_coderef

Returns true if the object has a coderef. βœ…

πŸ’– $overload->coderef_package

Returns the package for the coderef that implements overloading, if it has one.

πŸ’– $overload->has_coderef

Returns true if the object has a coderef package.

ok not me noticing the page lists has_coderef twice β€” once for the coderef, once for the coderef package. that's what the original says and I'm not about to edit her, she's doing her best. πŸ’€

πŸ’– $overload->coderef_name

Returns the sub name for the coderef that implements overloading, if it has one.

πŸ’– $overload->has_coderef_name

Returns true if the object has a coderef name. βœ…

πŸ’– $overload->is_anonymous

Returns true if the overloading is implemented by an anonymous coderef. no name, no identity, just vibes. πŸ•΅οΈ

πŸ’– $overload->associated_metaclass

Returns the Class::MOP::Module (class or role) that is associated with the overload object.

πŸ’– $overload->clone

Clones the overloading object, setting original_overload in the process. copy-paste but make it meta. 🧬

πŸ’– $overload->original_overload

For cloned objects, this returns the Class::MOP::Overload object from which they were cloned. This can be used to determine the source of an overloading in a class that came from a role, for example. it's giving "who's your mother" energy and honestly we respect it. 🫢


πŸ‘‘ AUTHORS πŸ‘‘

the literal legends, the founding mothers and fathers of this whole thing:

  • Stevan Little <stevan@cpan.org>
  • Dave Rolsky <autarch@urth.org>
  • Jesse Luehrs <doy@cpan.org>
  • Shawn M Moore <sartak@cpan.org>
  • Χ™Χ•Χ‘Χœ Χ§Χ•Χ’'מן (Yuval Kogman) <nothingmuch@woobling.org>
  • Karen Etheridge <ether@cpan.org>
  • Florian Ragwitz <rafl@debian.org>
  • Hans Dieter Pearcey <hdp@cpan.org>
  • Chris Prather <chris@prather.org>
  • Matt S Trout <mstrout@cpan.org>

give them their flowers πŸ’βœ¨


This software is copyright (c) 2006 by Infinity Interactive, Inc.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

free software, free girl summer, slay. πŸŒˆπŸ’–


and that's the whole page bestie!! πŸ’… this was perl v5.42.0, dated 2025-07-25, from the User Contributed Perl Documentation collection, and you absolutely understood all of it. no cap. mwah. πŸ˜˜πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from