Build Status

NAME

Sub::Multi::Tiny - Multisubs/multimethods (multiple dispatch) yet another way!

SYNOPSIS

{
    package main::my_multi;     # We're making main::my_multi()
    use Sub::Multi::Tiny qw($foo $bar);     # All possible params

    sub first :M($foo, $bar) { # sub's name will be ignored
        return $foo ** $bar;
    }

    sub second :M($foo) {
        return $foo + 42;
    }

}

# Back in package main, my_multi() is created just before the run phase.
say my_multi("a scalar", "and some more");  # -> "first"
say my_multi("just a scalar");              # -> "second"

Limitation: At present, dispatch is solely by arity, and only one candidate can have each arity. This limitation will be removed in the future.

DESCRIPTION

Sub::Multi::Tiny is a library for making multisubs, aka multimethods, aka multiple-dispatch subroutines.

TODO explain: if sub MakeDispatcher() exists in the package, it will be called to create the dispatcher.

DEBUGGING

For extra debug output, set "$VERBOSE" in Sub::Multi::Tiny to a positive integer. This has to be set at compile time to have any effect. For example, before creating any multisubs, do:

use Sub::Multi::Tiny::Util '*VERBOSE';
BEGIN { $VERBOSE = 2; }

RATIONALE / SEE ALSO

TODO explain why yet another module!

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Sub::Multi::Tiny

You can also look for information at:

BUGS

This isn't Damian code ;) .

AUTHOR

Chris White cxw@cpan.org

LICENSE

Copyright (C) 2019 Chris White cxw@cpan.org

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