in reply to Re^4: Reverting the internals of an IV to their original states
in thread Reverting the internals of an IV to their original states

I think we're all aware of the problem with round-tripping JSON, where it decodes a JSON number as a scalar, then if you use a string operation on it (such as a regex) and write it back out, you get a string instead of a number. And I think we all agree that it's unfortunate, but just a part of the philosophical mismatch between Perl and JavaScript, and not really anything that can be "fixed".

So, I would say that it is generally a problem to have any code that makes assumptions based on the corrent flags of a scalar. Ideally, you should change the XS code's API to expect a string or number rather than guessing, and let the user tell you which type it is. (and I realize this is generally hard for nested data structures.)

  • Comment on Re^5: Reverting the internals of an IV to their original states

Replies are listed 'Best First'.
Re^6: Reverting the internals of an IV to their original states
by syphilis (Archbishop) on Dec 31, 2021 at 01:21 UTC
    I think we're all aware of the problem with round-tripping JSON

    Yes, I've heard of it.
    I think this is a "data serialisers" issue that dave_the_m alluded to in his last post to this thread.
    There's an open perl issue about this, where changes to the way that perl's numeric flags are set/unset is being considered.
    I don't know what, if anything, will come of it ....

    Cheers,
    Rob