I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2008-07-11 13:32:48-07 by jerome
Deep cloning OIO object containing other OIO objects
Deep cloning an OIO object that contains other OIO objects seems problematic. I would have been fine with the behavior described in the doc ("Note that cloning does not clone internally held objects. For example, if $foo contains a reference to $bar, a clone of $foo will also contain a reference to $bar; not a clone of $bar") but I suspect that's not what's happening here. The code below returns the error "Modification of a read-only value attempted at /u/jroussin/perl/lib/Object/InsideOut/Util.pm line 379". After adding a few debug statements in Util.pm I see that the internally held OIO objects are recognized as SCALAR references and processed as such. That doesn't seem right? The error occurs during blessing of the newly created scalar reference (into class Element in the example below).
package Container; { use Object::InsideOut; my @elements :Field :Name(elements); sub _init :Init { my $self = shift; $elements[$$self] = {}; } sub set_element { my ($self,$element) = @_; $elements[$$self]->{$element->get_key} = $element; } } package Element; { use Object::InsideOut; my @key :Field :Name(key) :Arg(key) :Get(get_key); } my $c = Container->new; my $e = Element->new(key => 1); $c->set_element($e); my $cc = $c->clone(1);
Direct Responses: 8275 | Write a response
Posted on 2008-07-11 16:55:16-07 by jdhedden in response to 8274
Re: Deep cloning OIO object containing other OIO objects
Thanks for this bug report. I'll be uploading a fixed version shortly.
Direct Responses: 8276 | Write a response
Posted on 2008-07-11 17:53:35-07 by jerome in response to 8275
Re: Deep cloning OIO object containing other OIO objects
Jerry, thanks for the quick response. Looking at your code some more, I wonder if the doc is even right when it says that objects aren't going to be cloned during deep cloning. It looks to me like Scalar::Util::reftype is going to return HASH for most Perl objects? Should the doc be updated? Jerome
Direct Responses: 8278 | Write a response
Posted on 2008-07-11 18:15:59-07 by jdhedden in response to 8276
Re: Deep cloning OIO object containing other OIO objects
I want OIO to work as the docs state. Version 3.45 should do just that. Thanks again.
Direct Responses: Write a response