29/11/2004 01:47:33, Michael G Schwern <[EMAIL PROTECTED]> wrote:

>On Sun, Nov 28, 2004 at 11:17:40PM +0000, Nigel Sandever wrote:
>> This is the same bug/limitation of threads::shared I reported in perlbug #
30702.
>> 
>> Then, it was essentially dismissed as being "working as designed":
>
>If so then the design sucks.
>

I agree.

>
>I would like to know what it is that I'm doing "wrong" in Test::Builder.
>

I don't think that you are doing anything wrong. I have *never* seen share() 
return a reference to a hash or an array that had contents. That is to say, 
whenever you pass a reference to a hash or any array that hash something in it, 
to share(), it *always* empties it. 

perl -Mthreads -Mthreads::shared -wle"print %{ &share( {a=>1,b=>2}) },'?';"
?

Try any variation you like on that, it will always return a reference to an 
empty hash or array. Scalars retain any pre-sharing value they might have.

This is 'by design'.

The only way to share a complex datastricture is to share a reference to an 
empty one, and then copy the contents of your original into that. If any of the 
values are hash or array references, then you maust likewise, share a reference 
to an empty container of the appropriate type, and copy the contents of the 
original into the shared container. Recurse till done.


>
>I doubt it is working as designed as sometimes the share() works and
>sometimes it doesn't.  And I'm not even using any terribly complex data 
>structures.
>
>
>-- 
>Michael G Schwern        [EMAIL PROTECTED]  http://www.pobox.com/~schwern/
>HA HA HA  You're all so rediculous!  But thanks for the money!
>
>
njs.


Reply via email to