Functi...::Info(3pm)
π NAME π
Function::Parameters::Info β bestie, it's literally just info about parameter lists. That's it. That's the whole vibe. β¨
β¨ SYNOPSIS β¨
okay so picture this: you got a fun with a whole lil parameter list, and you wanna know things about it. Say less:
use Function::Parameters;
fun foo($x, $y, :$hello, :$world = undef) {}
my $info = Function::Parameters::info \&foo;
my @p0 = $info->invocants; # ()
my @p1 = $info->positional_required; # ('$x', '$y')
my @p2 = $info->positional_optional; # ()
my @p3 = $info->named_required; # ('$hello')
my @p4 = $info->named_optional; # ('$world')
my $p5 = $info->slurpy; # undef
my $min = $info->args_min; # 4
my $max = $info->args_max; # inf
my @invocants = Function::Parameters::info(method () { 42 })->invocants;
# ('$self')
my $slurpy = Function::Parameters::info(fun (@) {})->slurpy; # '@'
look at her go π«Ά every comment in there is the actual truth, no cap.
πΈ DESCRIPTION πΈ
Function::Parameters::info hands you back objects of this class to describe the parameter lists of functions. Scroll down for what they call "Parameter Objects" π
The following methods are available:
$info->invocants
Gives you a list of parameter objects for the variables that initial arguments get shifted into automatically (or a count if you're in scalar context, iykyk). For normal functions this is usually (), and for methods it's ('$self'). π«
$info->positional_required
A list of parameter objects for the required positional parameters (or a count in scalar context).
$info->positional_optional
A list of parameter objects for the optional positional parameters (or a count in scalar context).
$info->named_required
A list of parameter objects for the required named parameters (or a count in scalar context).
$info->named_optional
A list of parameter objects for the optional named parameters (or a count in scalar context).
$info->slurpy
Returns a parameter object for that final array or hash that just gobbles up every remaining argument π β or undef if there's no such thing. It's giving all-you-can-eat buffet.
$info->args_min
The minimum number of arguments this function needs. Here's the math, bestie, it's computed like this:
- Invocants and required positional parameters count
1each. π - Optional parameters don't count. not even a little.
- Required named parameters count
2each (key + value, obviously π ). - Slurpy parameters don't count either, because they're perfectly happy accepting empty lists.
$info->args_max
The maximum number of arguments this function accepts. The math:
- If there are any named or slurpy parameters, the result is
"Inf". mystery. infinite. iconic. π - Otherwise the result is the number of all invocants and positional parameters combined.
$info->invocant
Basically $info->invocants above but, like, the solo version:
undefif the number of invocants is0β she's alone, she's free- a parameter object for the invocant if there is exactly
1 - otherwise it throws an exception π so don't play games with it
π Parameter Objects π
A bunch of the methods up above return parameter objects. These little cuties have exactly two methods:
nameβ returns the name of the parameter, as a plain string.typeβ returns the corresponding type constraint object, orundefif no type was specified. π
And here's the slay part: this is completely invisible if you don't care about types, because these objects also overload stringification to call name. So if you treat parameter objects like strings, they justβ¦ behave like strings (aka, their names). no notes. π¦
π SEE ALSO π
Function::Parameters β go read it, bestie, it's where all these came from π
βοΈ AUTHOR βοΈ
Lukas Mai, <l.mai at web.de> β shoutout to the icon who built this π«‘π
π COPYRIGHT & LICENSE π
Copyright 2013, 2016 Lukas Mai.
This program is free software; you can redistribute it and/or modify it under the terms of either:
- the GNU General Public License as published by the Free Software Foundation; or
- the Artistic License.
See http://dev.perl.org/licenses/ for more information.
and that's the whole page, bestie!! go forth and introspect those parameter lists π β¨
perl v5.42.3 π¦ 2026-08-22 β yes this doc is a lil vintage but she still ate, fr fr. ππ
π¦ where this page comes from
- ubuntu stonking: libfunction-parameters-perl 2.002006-1build1 Β· 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