Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^10: Executing functions from another process

by BrowserUk (Patriarch)
on Jan 24, 2014 at 16:29 UTC ( [id://1071962]=note: print w/replies, xml ) Need Help??


in reply to Re^9: Executing functions from another process
in thread Executing functions from another process

So it sounds like dump+eval does not create a true copy of the data structure.

None that I am aware of will retain knowledge that one scalar in the structure is a reference to another scalar in that same structure.

Ie. If you have this structure (which is different to what you showed, but may be what you intended):

$a = 'one'; $b = 'two'; @d = ( $a, $b, \$b );;

Then neither Storable:

use Storable qw[ freeze thaw ];; $x = freeze \@d;; $y = thaw $x;; pp $y;; ["one", "two", \"two"] ${ $y->[2] } = 'three';; pp $y;; ["one", "two", \"three"]

Nor Clone successfully capture that scalar reference relationship:

use Clone qw[ clone ];; $x = clone \@d;; pp $x;; ["one", "two", \"two"] ${ $x->[2] } = 'three';; pp $x;; ["one", "two", \"three"]

You could say that was a bug -- and I'd probably agree with you -- but it is a long standing one that it would appear that no one has till now seen as a problem. Which is another way of saying it is unlikely to be fixed -- or even accepted as a bug -- any time soon.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^11: Executing functions from another process
by Corion (Patriarch) on Jan 24, 2014 at 16:41 UTC

    I think that Sereal might retain aliases properly. The spec at least has a type for a proper alias, and I think I remember hearing in a talk about Sereal that it does retain that. Also, Data::Dump::Stream, by demerphq might also properly retain aliases.

      The spec at least has a type for a proper alias

      Hm. Wouldn't REFP be more appropriate? (In that the described problem is a dereferencable, reference rather than an alias.)

      That said, Storable & Clone (and even Dump) handle references to arrays and hashes, including ensuring that multiple embedded references to the same array or hash retain that property once thawed. It is a bit strange that they don't handle scalar references correctly.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1071962]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-18 17:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found