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

Re: share() bug? ( [perl #30702] )

by liz (Monsignor)
on Jul 15, 2004 at 20:40 UTC ( [id://374821]=note: print w/replies, xml ) Need Help??


in reply to share() bug? ( [perl #30702] )

It's not a bug. It's a side effect of using tie() for shared arrays and hashes.

Observe:

use threads; use threads::shared qw(share); my @foo :shared = (1,2,3); # same as: share( @foo ); @foo = (1,2,3) my @bar = (1,2,3); share( @bar ); print "foo = @foo, tied foo = ".(tied @foo)."\n"; print "bar = @bar, tied bar = ".(tied @bar)."\n"; __END__ foo = 1 2 3, tied foo = threads::shared::tie=SCALAR(0x82b714) bar = , tied bar = threads::shared::tie=SCALAR(0x80a270)

Shared arrays, as shared hashes, are implemented using tie(), as can be observed from the output of the tied() function.

And losing / hiding the original value of something, is a known side-effect of tie(), as far as I know.

So there's no easy solution, I'm afraid. Fixing tie() to keep the original value, may be in order, but may also break a lot of programs.

Fixing threads.pm and threads::shared to not use tie() would be best, but not something we're going to see in the 5.8 life cycle of Perl.

I think that's basically the dilemma.

Liz

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-18 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found