msgpack-perl icon indicating copy to clipboard operation
msgpack-perl copied to clipboard

Switch to Types::Serialiser booleans

Open aferreira opened this issue 8 years ago • 5 comments

This change promotes type compatibility with other CPAN serialization modules like JSON.

This is another take at https://github.com/msgpack/msgpack-perl/issues/17 – see also https://github.com/msgpack/msgpack-perl/pull/34

BREAKING CHANGE: removes stringification of true() to "true" and false() to "false". As the packages Data::MessagePack::Boolean and Types::Serialiser::Boolean are aliased, it is not safe to include this controverse coertion (different modules may have different ideas on what is a useful stringification of booleans). The "bool" and "num" (0+) overloads should work as before.

aferreira avatar Aug 04 '17 23:08 aferreira

@aferreira How does this compare to https://github.com/msgpack/msgpack-perl/pull/34?

FGasper avatar Sep 26 '17 14:09 FGasper

@FGasper I took a lazier route to achieve interoperability – namely instead of also supporting Types::Serialiser::Boolean, the proposed change makes "Data::MessagePack::Boolean" and "Types::Serialiser::Boolean" the same for Perl. So the assertions below will hold.

A consequence of this approach is that the required change was simpler – no need for patches to XS code or adding explanation on the tolerance of Types::Serialiser::Boolean to documentation.

use Test::More;
use Data::MessagePack::Boolean;
use Types::Serialiser;

ok(Data::MessagePack->true->isa('Data::MessagePack::Boolean'));  # old stuff
ok(Data::MessagePack->true->isa('Types::Serialiser::Boolean'));
ok(Data::MessagePack->false->isa('Data::MessagePack::Boolean'));  # old stuff
ok(Data::MessagePack->false->isa('Types::Serialiser::Boolean'));

ok(Types::Serialiser::true()->isa('Types::Serialiser::Boolean')); # old stuff
ok(Types::Serialiser::true()->isa('Data::MessagePack::Boolean'));
ok(Types::Serialiser::false()->isa('Types::Serialiser::Boolean')); # old stuff
ok(Types::Serialiser::false()->isa('Data::MessagePack::Boolean'));

done_testing;

aferreira avatar Sep 26 '17 16:09 aferreira

To my knowledge #34 doesn’t include any breaking changes, so I’d think that would still be a preferable solution—notwithstanding my own bias. :)

Anyway, I think it’s moot until someone else assumes stewardship of the module.

FGasper avatar Sep 26 '17 17:09 FGasper

In the meantime there is a (very ugly) workaround solution here:

https://metacpan.org/source/FELIPE/Net-WAMP-0.01/lib/Net/WAMP/Serialization/msgpack.pm

FGasper avatar Sep 26 '17 17:09 FGasper

Thanks. Given that the owner is unresponsive, any ideas on what would be the next steps to get the PR merged to master and released to CPAN?

foobargeez avatar Sep 26 '17 21:09 foobargeez