Dave Mitchell wrote: > Yes, but my point is that serialization modules will often not do what the > user really intended, and using the canonical type doesn't fix that: it > just shuffles around the cases when it does and doesn't DWIM. > > I think if it's important that something gets serialised in a particular > format, then in some way the programmer needs to tell the serialiser what > that format should be. Ideally, yes, and that what some XML-RPC modules do: they expect you to specify the type for each value. However, that's not always possible or practical. That's the case when serializing structures with Storable, JSON or Sereal. Also, one the problems is that, because the SV was morphed behind the scene, the serialization goes wrong: $ perl -MJSON::XS -E '$v=42; say encode_json{v=>$v}; say "$v"; say encode_json{v=>$v}' {"v":42} 42 {"v":"42"} From the user's point of view, $v was given an integer, never touched, but when serialized, it magically and incorrectly becomes a string. This surprises the newbies as well and the experienced users. The really annoying part being that you need to coerce at the very boundaries between your code and the serializer (provided the serializer doesn't mess up anything on its own) and avoid any interpolation or concatenation with a string, for example for debugging purpose. -- Sébastien Aperghis-Tramoni Close the world, txEn eht nepO.Thread Previous | Thread Next