--- Types-Serialiser/Serialiser.pm 2013/10/28 21:52:22 1.5 +++ Types-Serialiser/Serialiser.pm 2013/10/29 13:08:35 1.6 @@ -19,7 +19,7 @@ use common::sense; # required to suppress annoying warnings -our $VERSION = 0.02; +our $VERSION = 0.03; =head1 SIMPLE SCALAR CONSTANTS @@ -103,9 +103,24 @@ # for historical reasons, and to avoid extra dependencies in JSON::PP, # we alias *Types::Serialiser::Boolean with JSON::PP::Boolean. package JSON::PP::Boolean; + *Types::Serialiser::Boolean:: = *JSON::PP::Boolean::; } +{ + # this must done before blessing to work around bugs + # in perl < 5.18 (it seems to be fixed in 5.18). + package Types::Serialiser::BooleanBase; + + use overload + "0+" => sub { ${$_[0]} }, + "++" => sub { $_[0] = ${$_[0]} + 1 }, + "--" => sub { $_[0] = ${$_[0]} - 1 }, + fallback => 1; + + @Types::Serialiser::Boolean::ISA = Types::Serialiser::BooleanBase::; +} + our $true = do { bless \(my $dummy = 1), Types::Serialiser::Boolean:: }; our $false = do { bless \(my $dummy = 0), Types::Serialiser::Boolean:: }; our $error = do { bless \(my $dummy ), Types::Serialiser::Error:: }; @@ -119,16 +134,6 @@ sub is_false ($) { !$_[0] && UNIVERSAL::isa $_[0], Types::Serialiser::Boolean:: } sub is_error ($) { UNIVERSAL::isa $_[0], Types::Serialiser::Error:: } -package Types::Serialiser::BooleanBase; - -use overload - "0+" => sub { ${$_[0]} }, - "++" => sub { $_[0] = ${$_[0]} + 1 }, - "--" => sub { $_[0] = ${$_[0]} - 1 }, - fallback => 1; - -@Types::Serialiser::Boolean::ISA = Types::Serialiser::BooleanBase::; - package Types::Serialiser::Error; sub error {