Specio

 view release on metacpan or  search on metacpan

lib/Specio.pm  view on Meta::CPAN

so you can safely use short type names.

Unlike MooseX::Types, types are strings, so there is no possibility of
colliding with existing class or subroutine names.

=item * No type auto-creation

Types are always retrieved using the C<t()> subroutine. If you pass an unknown
name to this subroutine it dies. This is different from Moose and
MooseX::Types, which assume that unknown names are class names.

=item * Anon types are explicit

With L<Moose> and L<MooseX::Types>, you use the same subroutine, C<subtype()>,
to declare both named and anonymous types. With Specio, you use C<declare()>
for named types and C<anon()> for anonymous types.

=item * Class and object types are separate

Moose and MooseX::Types have C<class_type> and C<duck_type>. The former type
requires an object, while the latter accepts a class name or object.

With Specio, the distinction between accepting an object versus object or class
is explicit. There are six declaration helpers, C<object_can_type>,
C<object_does_type>, C<object_isa_type>, C<any_can_type>, C<any_does_type>, and
C<any_isa_type>.

=item * Overloading support is baked in

Perl's overloading is quite broken but ignoring it makes Moose's type system
frustrating to use in many cases.

=item * Types can either have a constraint or inline generator, not both

Moose and MooseX::Types types can be defined with a subroutine reference as the
constraint, an inline generator subroutine, or both. This is purely for
backwards compatibility, and it makes the internals more complicated than they
need to be.

With Specio, a constraint can have I<either> a subroutine reference or an
inline generator, not both.

=item * Coercions can be inlined

I simply never got around to implementing this in Moose.

=item * No crazy coercion features

Moose has some bizarre (and mostly) undocumented features relating to coercions
and parameterizable types. This is a misfeature.

=back

=head1 OPTIONAL PREREQS

There are several optional prereqs that if installed will make this
distribution better in some way.

=over 4

=item * L<Ref::Util>

Installing this will speed up a number of type checks for built-in types.

=item * L<XString>

If this is installed it will be loaded instead of the L<B> module if you have
Perl 5.10 or greater. This module is much more memory efficient than loading
all of L<B>.

=item * L<Sub::Util> or L<Sub::Name>

If one of these is installed then stack traces that end up in Specio code will
have much better subroutine names for any frames.

=back

=head1 WHY THE NAME?

This distro was originally called "Type", but that's an awfully generic top
level namespace. Specio is Latin for for "look at" and "spec" is the root for
the word "species". It's short, relatively easy to type, and not used by any
other distro.

=head1 LONG-TERM PLANS

Eventually I'd like to see this distro replace Moose's internal type system,
which would also make MooseX::Types obsolete.

=head1 SUPPORT

Bugs may be submitted at L<https://github.com/houseabsolute/Specio/issues>.

=head1 SOURCE

The source code repository for Specio can be found at L<https://github.com/houseabsolute/Specio>.

=head1 DONATIONS

If you'd like to thank me for the work I've done on this module, please
consider making a "donation" to me via PayPal. I spend a lot of free time
creating free software, and would appreciate any support you'd care to offer.

Please note that B<I am not suggesting that you must do this> in order for me
to continue working on this particular software. I will continue to do so,
inasmuch as I have in the past, for as long as it interests me.

Similarly, a donation made in this way will probably not make me work on this
software much more, unless I get so many donations that I can consider working
on free software full time (let's all have a chuckle at that together).

To donate, log into PayPal and send money to autarch@urth.org, or use the
button at L<https://www.urth.org/fs-donation.html>.

=head1 AUTHOR

Dave Rolsky <autarch@urth.org>

=head1 CONTRIBUTORS

=for stopwords Chris White cpansprout Graham Knop Karen Etheridge Vitaly Lipatov

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.358 second using v1.00-cache-1.14-grep--cpan-9b3982acd67 )