package Function::Parameters::Info;
use v5.14.0;
-
use warnings;
-use Moo;
+our $VERSION = '1.0301';
+
+# If Moo isn't loaded yet but Moose is, avoid pulling in Moo and fall back to Moose
+my ($Moo, $meta_make_immutable);
+BEGIN {
+ if ($INC{'Moose.pm'} && !$INC{'Moo.pm'}) {
+ $Moo = 'Moose';
+ $meta_make_immutable = sub { $_[0]->meta->make_immutable };
+ } else {
+ require Moo;
+ $Moo = 'Moo';
+ $meta_make_immutable = sub {};
+ }
+ $Moo->import;
+}
+
+{
+ package Function::Parameters::Param;
+
+ BEGIN { $Moo->import; }
+ use overload
+ fallback => 1,
+ '""' => sub { $_[0]->name },
+ ;
+
+ has $_ => (is => 'ro') for qw(name type);
-our $VERSION = '0.01';
+ __PACKAGE__->$meta_make_immutable;
+}
my @pn_ro = glob '{positional,named}_{required,optional}';
$r
}
+__PACKAGE__->$meta_make_immutable;
+
'ok'
__END__
as follows: If there is any named or slurpy parameter, the result is C<Inf>.
Otherwise the result is the sum of all invocant and positional parameters.
+=head2 Experimental feature: Types
+
+All the methods described above actually return parameter objects wherever the
+description says "name". These objects have two methods: C<name>, which
+returns the name of the parameter (as a plain string), and C<type>, which
+returns the corresponding type constraint object (or undef if there was no type
+specified).
+
+This should be invisible if you don't use types because the objects also
+L<overload|overload> stringification to call C<name>. That is, if you treat
+parameter objects like strings, they behave like strings (i.e. their names).
+
=head1 SEE ALSO
L<Function::Parameters>
=head1 COPYRIGHT & LICENSE
-Copyright 2012 Lukas Mai.
+Copyright 2013 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