P5-class-multimethods

Jul 20, 2023

Support multimethods and function overloading in Perl

The ClassMultimethod module exports a subroutine &multimethod that can be used to declare other subroutines that are dispatched using a algorithm different from the normal Perl subroutine or method dispatch mechanism.

Normal Perl subroutines are dispatched by finding the appropriately-named subroutine in the current or specified package and calling that. Normal Perl methods are dispatched by attempting to find the appropriately-named subroutine in the package into which the invoking object is blessed or, failing that, recursively searching for it in the packages listed in the appropriate @ISA arrays.

ClassMultimethods multimethods are dispatched quite differently. The dispatch mechanism looks at the classes or types of each argument to the multimethod by calling ref on each and determines the “closest” matching variant of the multimethod, according to the argument types specified in the variants’ definitions see “Finding the “nearest” multimethod” for a definition of “closest”.



Checkout these related ports:
  • Zziplib - Library to provide transparent read access to zipped files
  • Zydis - Fast and lightweight x86/x86-64 disassembler library
  • Zycore-c - Support library with platform independent types, macros, etc for Zydis
  • Zthread - Platform-independent object-oriented C++ threading library
  • Zookeeper - Coordination Service for Distributed Applications
  • Zls - Zig LSP implementation + Zig Language Server
  • Zfp - High throughput library for compressed floating-point arrays
  • Zeal - Offline documentation browser
  • Zapcc - C++ caching compiler based on clang
  • Zanata-platform - Web-based translation platform
  • Zanata-cli - Zanata Java command line client
  • Z88dk - Complete Z80/Z180 development kit
  • Z80ex - ZiLOG Z80 CPU emulator library
  • Z80asm - Assembler for the Z80 microprocessor
  • Z80-asm - Z80 assembly code assembler and disassembler