Method...difiers(3pm)
π Method::Signatures::Modifiers π
okay so bestie, welcome to Method::Signatures::Modifiers, a lil module that lives in the User Contributed Perl Documentation corner of your system. she's a 3pm page and she's here to let you use Method::Signatures from inside MooseX::Declare. yes. that's the whole vibe. π
β¨ NAME β¨
Method::Signatures::Modifiers β use Method::Signatures from within MooseX::Declare.
periodt.
πΈ SYNOPSIS πΈ
use MooseX::Declare;
use Method::Signatures::Modifiers;
class Foo
{
method bar (Int $thing) {
# this method is declared with Method::Signatures instead of MooseX::Method::Signatures
}
}
# -- OR --
use MooseX::Declare;
class My::Declare extends MooseX::Declare
{
use Method::Signatures::Modifiers;
}
# ... later ...
use My::Declare;
class Fizz
{
method baz (Int $thing) {
# this method also declared with Method::Signatures instead of MooseX::Method::Signatures
}
}
like, look at her go π¦ two whole ways to do the thing and both of them ate.
π DESCRIPTION π
so the whole point: this module lets you use Method::Signatures from within MooseX::Declare β and not just for the "method" keyword, but for every single method modifier too: "before", "after", "around", "override", and "augment". the whole squad. π
normally, method signatures inside MooseX::Declare come from MooseX::Method::Signatures. swapping in Method::Signatures instead gives you a few very real advantages:
MooseX::Method::Signatureshas a known bug with Perl 5.12.x which does not plagueMethod::Signatures.Method::Signaturesmay provide substantially better performance when calling methods, depending on your circumstances.Method::Signatureserror messages are somewhat easier to read (and can be overridden more easily).
BUT. and this is a big but, bestie π β Method::Signatures cannot be considered a drop-in replacement for MooseX::Method::Signatures. specifically, the following features of MooseX::Method::Signatures are not available to you (or work differently) if you substitute Method::Signatures:
π Types for Invocants
MooseX::Method::Signatures allows code such as this:
method foo (ClassName $class: Int $bar) {
}
Method::Signatures does not allow you to specify a type for the invocant, so your code would change to:
method foo ($class: Int $bar) {
}
so sad, so tragic, no typed invocant for you π₯²
π Parameter Aliasing (Labels)
MooseX::Method::Signatures allows code like this:
# call this as $obj->foo(bar => $baz)
method foo (Int :bar($baz)) {
}
this feature is not currently planned for Method::Signatures. it's giving "we don't do that here" π
π Placeholders
MooseX::Method::Signatures allows code like this:
method foo (Int $bar, $, Int $baz) {
# second parameter not available as a variable here
}
this feature is also not currently planned for Method::Signatures.
however, note that if the parameter you want to ignore is at the end:
method foo (Int $bar, Int $baz, $) {
# third parameter not available as a variable here
}
then you could write that in Method::Signatures using the "yada yada" pseudo-parameter:
method foo (Int $bar, Int $baz, ...) {
# third (or greater) parameter(s) not available here
}
the ... really said "and the rest of y'all, idk her" β¨
π Traits
in MooseX::Method::Signatures, "does" is a synonym for "is". Method::Signatures does not honor this. nope. not happening.
Method::Signatures supports several traits that MooseX::Method::Signatures does not.
and flip side: MooseX::Method::Signatures supports the "coerce" trait. Method::Signatures does not currently support this, although it is a planned feature for a future release, potentially using the "does coerce" syntax. manifesting it for future us π―οΈ
β οΈ BUGS, CAVEATS and NOTES β οΈ
note that although this module causes all calls to MooseX::Method::Signatures from within MooseX::Declare to be completely replaced by calls to Method::Signatures (or calls to Method::Signatures::Modifiers), MooseX::Method::Signatures is still loaded by MooseX::Declare. it's just never used. like, she's at the party but nobody's talking to her π
the"compile_at_BEGIN"flag toMethod::Signaturesis ignored byMethod::Signatures::Modifiers. this is because parsing at compile-time can cause method modifiers to be added before the methods they are modifying are composed into the Moose classes. parsing of methods at run-time is compatible withMooseX::Method::Signatures.
like literally do not come for that flag, she's not invited π«
π«Ά THANKS π«Ά
this code was written by Buddy Burden (barefootcoder). absolute legend, no cap π
the import code for replacing MooseX::Method::Signatures is based on a suggestion from Nick Perez. thank you bestie, we love a collaborative queen π
π LICENSE π
Copyright 2011 by Michael G Schwern <schwern@pobox.com>.
this program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
see http://www.perl.com/perl/misc/Artistic.html
π SEE ALSO π
MooseX::Declare, Method::Signatures, MooseX::Method::Signatures.
and that's the whole page babes π this was Method::Signatures::Modifiers, a perl v5.36.0 situation, last touched 2023-08-20, straight out of the User Contributed Perl Documentation. now go forth and declare your methods, you gorgeous thing πΈβ¨
π¦ where this page comes from
- debian trixie: libmethod-signatures-perl 20170211-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmethod-signatures-perl 20170211-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmethod-signatures-perl 20170211-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmethod-signatures-perl 20170211-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms