ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Types-Serialiser/Serialiser.pm
(Generate patch)

Comparing Types-Serialiser/Serialiser.pm (file contents):
Revision 1.1 by root, Sun Oct 27 19:49:33 2013 UTC vs.
Revision 1.2 by root, Sun Oct 27 20:01:08 2013 UTC

14different implementations so they become interoperable between each other. 14different implementations so they become interoperable between each other.
15 15
16=cut 16=cut
17 17
18package Types::Serialiser; 18package Types::Serialiser;
19
20use common::sense;
21 19
22our $VERSION = 0.01; 20our $VERSION = 0.01;
23 21
24=head1 SIMPLE SCALAR CONSTANTS 22=head1 SIMPLE SCALAR CONSTANTS
25 23
122 120
123package Types::Serialiser::Error; 121package Types::Serialiser::Error;
124 122
125sub error { 123sub error {
126 require Carp; 124 require Carp;
127 Carp::croak ("caught attempt to use Types::Serialiser::error value"); 125 Carp::croak ("caught attempt to use the Types::Serialiser::error value");
128}; 126};
129 127
130use overload 128use overload
131 "0+" => \&error, 129 "0+" => \&error,
132 "++" => \&error, 130 "++" => \&error,
133 "--" => \&error, 131 "--" => \&error,
134 fallback => 1; 132 fallback => 1;
133
134=head1 NOTES FOR XS USERS
135
136The recommended way to detect whether a scalar is one of these objects
137is to check whether the stash is the C<Types::Serialiser::Boolean> or
138C<Types::Serialiser::Error> stash, and then follow the scalar reference to
139see if it's C<1> (true), C<0> (false) or C<undef> (error).
140
141While it is possible to use an isa test, directly comparing stash pointers
142is faster and guaranteed to work.
135 143
136=head1 BUGS 144=head1 BUGS
137 145
138The use of L<overload> makes this module much heavier than it should be 146The use of L<overload> makes this module much heavier than it should be
139(on my system, this module: 4kB RSS, overload: 260kB RSS). 147(on my system, this module: 4kB RSS, overload: 260kB RSS).

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines