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 theoverloadmodule, 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 thecoderefoption must be passed. (manifesting a method that doesn't exist yet? valid. we've all been there.)methodβ AClass::MOP::Methodobject for the method which implements the overloading. This is optional. πcoderefβ A coderef which implements the overloading. Either this or themethod_nameoption 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 ifcoderefis passed. don't skip this one. fr fr.coderef_nameβ The name of the coderef. This can be"__ANON__". This is required ifcoderefis passed. yes you can literally name her"__ANON__", she's mysterious like that. π§associated_metaclassβ AClass::MOP::Moduleobject 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 πβ¨
π COPYRIGHT AND LICENSE π
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
- fedora 43: perl-Moose 2.4000-4.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms