Mailing List Archive

Make $) and $( not IOK?
Hi all,

I’ve noted that the fact that these are IOK confuses serializers into doing things like this:

-----
> perl -MSereal -MData::Dumper -e'$) = "3 2"; print "$)\n"; print Dumper( Sereal::decode_sereal( Sereal::encode_sereal( $) ) ) )'
3 2
$VAR1 = 3;
-----

Note that round-tripping $) through Sereal yields 3, not '3 2'. This is because after $)’s magic is set, the resulting SV is both IOK and POK. Since serialization of a number is often more efficient than of a string, serializers will prefer to notate the numeric value instead of the string. In this case, though, that loses valuable information.

What if, along the lines of what Paul has recently proposed to help serializers achieve reliable string/number typing, $) and $( de-magicked to values that are IOKp, but not IOK? This would allow numeric operations on those values without generating “not a number” warnings, and it would compel Sereal et al. to serialize those values as strings, thus preserving the extra GIDs.

Thoughts?

-Felipe