MixinF...::NEXT(3pm)

πŸ“¦
version 0.92 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

✨ NAME ✨

Class::MixinFactory::NEXT β€” superclass method redispatch, but make it mixin πŸ’…

So basically this page is from the MixinF...::NEXT bit of the Perl docs (User Contributed Perl Documentation, no cap), and it's all about letting your mixin classes yell "NEXT!!" down the inheritance tree without actually inheriting from anything. Iconic behavior honestly.


🌸 SYNOPSIS 🌸

use Class::MixinFactory::NEXT;

package My::BaseClass;
sub foo { return "Foo Bar" }

package My::Logging;
sub foo { warn "Calling foo"; (shift)->NEXT('foo', @_) }

package My::MixedClass;
@ISA = ( 'My::Logging', 'My::BaseClass', 'Class::MixinFactory::NEXT'; );

package main;
print My::MixedClass->foo();

Like… look at her go. My::Logging just hops into the chain, does its little warn, and then hands the mic off with NEXT. The base class never even knew she was there. Main character energy fr fr. πŸŽ€


πŸ’– DESCRIPTION πŸ’–

Okay so bestie, here's the tea β˜• β€” this is enhanced superclass method dispatch for use inside mixin class methods. It lets mixin classes redispatch to other classes in the inheritance tree without themselves inheriting from anything. That's the whole point, and it ate. πŸ”₯

πŸ¦‹ Public Methods πŸ¦‹

This package defines exactly one method, and her name is NEXT.

$callee->NEXT( $method, @args );

What she does: she searches the inheritance tree of the callee until she finds the package from which NEXT is being called, and then she keeps searching until she hits the next class which can perform the named method.

And here's the part that's giving ✨special✨ β€” unlike SUPER, this method will backtrack down the inheritance tree to find implementations later in the search path, even if they are on a separate branch. SUPER could never, ngl. 🫢


🌈 SEE ALSO 🌈

  • This class is automatically included by Class::MixinFactory. You don't gotta do a thing.
  • It's similar to the functionality provided by NEXT::ACTUAL, except without using AUTOLOAD. For a more generalized approach to this issue, see NEXT.
  • For distribution, installation, support, copyright and license information, see Class::MixinFactory::ReadMe. That's where the boring-but-important receipts live, iykyk. πŸ’œ

okay that's the whole page bestie, you're so smart now, go forth and redispatch responsibly πŸ‘‘

this lil gem shipped as perl v5.36.0 and the docs are dated 2022-10-22, from the MixinF...::NEXT(3pm) page πŸ’– mwah, bye!! πŸ’…

πŸ“¦ where this page comes from