Sub-Multi-Tiny
view release on metacpan or search on metacpan
use APackageThatImportsMakeDispatcherIntoMainFoo;
}
As a shortcut, you can specify a dispatcher on the `use` line. For example:
use Sub::Multi::Tiny qw(D:Foo $var);
will use dispatcher `Sub::Multi::Tiny::Dispatcher::Foo`. Any name with a
double-colon will be used as a full package name. E.g., `D:Bar::Quux` will
use dispatcher `Bar::Quux`. If `Foo` does not include a double-colon,
`Sub::Multi::Tiny::Dispatcher::` will be prepended.
# DEBUGGING
For extra debug output, set ["$VERBOSE" in Sub::Multi::Tiny::Util](https://metacpan.org/pod/Sub%3A%3AMulti%3A%3ATiny%3A%3AUtil#VERBOSE) 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
- To be able to use multisubs in pre-5.14 Perls with only built-in
language facilities. This will help me make my own modules backward
compatible with those Perls.
- To learn how it's done! :)
# SEE ALSO
I looked at these but decided not to use them for the following reasons:
- [Class::Multimethods](https://metacpan.org/pod/Class%3A%3AMultimethods)
I wanted a syntax that used normal `sub` definitions as much as possible.
Also, I was a bit concerned by LPALMER's experience that it "does what you
don't want sometimes without saying a word"
(["Semantics" in Class::Multimethods::Pure](https://metacpan.org/pod/Class%3A%3AMultimethods%3A%3APure#Semantics)).
Other than that, I think this looks pretty decent (but haven't tried it).
- [Class::Multimethods::Pure](https://metacpan.org/pod/Class%3A%3AMultimethods%3A%3APure)
Same desire for `sub` syntax. Additionally, the last update was in 2007,
and the maintainer hasn't uploaded anything since. Other than that, I think
this also looks like a decent option (but haven't tried it).
- [Dios](https://metacpan.org/pod/Dios)
This is a full object system, which I do not need in my use case.
- [Logic](https://metacpan.org/pod/Logic)
This one is fairly clean, but uses a source filter. I have not had much
experience with source filters, so am reluctant.
- [Kavorka::Manual::MultiSubs](https://metacpan.org/pod/Kavorka%3A%3AManual%3A%3AMultiSubs) (and [Moops](https://metacpan.org/pod/Moops))
Requires Perl 5.14+.
- [MooseX::MultiMethods](https://metacpan.org/pod/MooseX%3A%3AMultiMethods)
I am not ready to move to full [Moose](https://metacpan.org/pod/Moose)!
- [MooseX::Params](https://metacpan.org/pod/MooseX%3A%3AParams)
As above.
- [Sub::Multi](https://metacpan.org/pod/Sub%3A%3AMulti)
The original inspiration for this module, whence this module's name.
`Sub::Multi` uses coderefs, and I wanted a syntax that used normal
`sub` definitions as much as possible.
- [Sub::SmartMatch](https://metacpan.org/pod/Sub%3A%3ASmartMatch)
This one looks very interesting, but I haven't used smartmatch enough
to be fully comfortable with it.
# SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Sub::Multi::Tiny
You can also look for information at:
- GitHub: The project's main repository and issue tracker
[https://github.com/cxw42/Sub-Multi-Tiny](https://github.com/cxw42/Sub-Multi-Tiny)
- MetaCPAN
[Sub::Multi::Tiny](https://metacpan.org/pod/Sub%3A%3AMulti%3A%3ATiny)
- This distribution
See the tests in the `t/` directory distributed with this software
for usage examples.
# BUGS
- It's not as tiny as I thought it would be!
- 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.
( run in 0.754 second using v1.01-cache-2.11-cpan-39bf76dae61 )