NAME
Type::API::Constraint::Inlinable - allows a string of code to be generated to check a given variable
INTERFACE
Implementations of Type::API::Constraint::Inlinable MUST also implement Type::API::Constraint.
Implementations MUST provide the following methods:
$constraint->can_be_inlined
-
Returns a boolean indicating whether inlining support is available for this type constraint.
$constraint->inline_check($variable_name)
-
$variable_name
will be a string such as'$_'
or'$_[0]'
. Should return a string of code that may be evaluated to determine the pass/failure of the value in the given variable. The string MUST NOT includereturn
,goto
or other flow control keywords that would make it unsuitable for inlining into a larger function.
There is not currently any mechanism to request that the string of code in a particular programming language, nor a mechanism for the implementation to indicate what language it has generated. However, the implementations that have been investigated have returned Perl 5 code. Nevertheless, this is an area for further investigation.
Implementations MAY
advertise that they support this interface by returning true for $constraint->DOES("Type::API::Constraint::Inlinable")
.
SEE ALSO
Implementations
The following CPAN classes are known to implement Type::API::Constraint::Inlinable:
Specio::Constraint::Simple (and several other classes in the Specio distribution)
Type::Tiny (and its subclasses)
The following CPAN classes implement this interface with a minor difference; the inline_check
method is called _inline_check
instead. Tools wishing to make use of this interface should consider supporting this variation.
Moose::Meta::TypeConstraint (and its subclasses)
AUTHOR
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCE
This software is copyright (c) 2013 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.