use XSLoader;
BEGIN {
- our $VERSION = '1.0104';
+ our $VERSION = '1.0202';
XSLoader::load;
}
Moose::Util::TypeConstraints::find_or_create_isa_type_constraint($_[0])
}
+sub _delete_default {
+ my ($href, $key, $default) = @_;
+ exists $href->{$key} ? delete $href->{$key} : $default
+}
+
my @bare_arms = qw(function method);
my %type_map = (
function => {
$clean{attrs} = join ' ', map delete $type{$_} || (), qw(attributes attrs);
_assert_valid_attributes $clean{attrs} if $clean{attrs};
- $clean{default_arguments} =
- exists $type{default_arguments}
- ? !!delete $type{default_arguments}
- : 1
- ;
+ $clean{default_arguments} = _delete_default \%type, 'default_arguments', 1;
+ $clean{named_parameters} = _delete_default \%type, 'named_parameters', 1;
+ $clean{types} = _delete_default \%type, 'types', 1;
- $clean{check_argument_count} = !!delete $type{check_argument_count};
- $clean{invocant} = !!delete $type{invocant};
- $clean{named_parameters} = !!delete $type{named_parameters};
- $clean{types} = !!delete $type{types};
+ $clean{check_argument_count} = _delete_default \%type, 'check_argument_count', 0;
+ $clean{invocant} = _delete_default \%type, 'invocant', 0;
if (my $rt = delete $type{reify_type}) {
ref $rt eq 'CODE' or confess qq{"$rt" doesn't look like a type reifier};
initialization, you can specify the same key multiple times and the last
occurrence wins:
- rectangle(height => 1, width => 2, height => 2, height => 5;
+ rectangle(height => 1, width => 2, height => 2, height => 5);
# same as: rectangle(width => 2, height => 5);
You can combine positional and named parameters as long as the positional
Valid values: code references. The function specified here will be called to
turn type annotations into constraint objects (see
-L</Experimental feature: Types> below).
+L</Experimental feature: Types> below). It will receive two arguments: a string
+containing the type description, and the name of the current package.
The default type reifier is equivalent to:
consisting of identifiers (C<Foo>), unions (C<... | ...>), and parametric types
(C<...[...]>). Example:
- fun foo(Int $n, ArrayRef[String | CodeRef] $cb) { ... }
+ fun foo(Int $n, ArrayRef[Str | CodeRef] $cb) { ... }
If you do this, the type reification function corresponding to the keyword will
be called to turn the type (a string) into a constraint object. The default