Object::InsideOut, I don't get it
gargle
created: 2006-03-05 06:39:31

Maybe some of you could shed some light, I'm having the following problem:

TryOut.pm
package TryOut;

use strict;
use warnings;

{
    use Object::InsideOut;
    my @data :Field( 'Standard' => 'data', 'Permission' => 'private');
    
}
main.pl
#!/usr/bin/perl

use strict;
use warnings;
use TryOut;

my $obj = TryOut->new();

When I run main.pl I get:

OIO::Internal error: Failure creating accessor for class 'TryOut'
Error: OIO::Method error: Can't call private method 'TryOut->get_data' from class 'Object::InsideOut'
Package: Object::InsideOut
File: /usr/local/share/perl/5.8.8/Object/InsideOut.pm
...

Is this normal behaviour? The docs of Object::InsideOut give:

my @data :Field( 'Standard' => 'data', 'Permission' => 'private');

as an example...

--
if ( 1 ) { $postman->ring() for (1..2); }
Re: Object::InsideOut, I don't get it
created: 2006-03-05 12:05:23
Two observations:
  1. You are missing sub new just before the beginning '{' in TryOut.pm.
  2. You need a "1;" at the end of TryOut.pm

Hope that helps!


@ARGV=split//,"/:L"; map{print substr crypt($_,ord pop),2,3}qw"PerlyouC READPIPE provides"
Re^2: Object::InsideOut, I don't get it
created: 2006-03-05 12:18:44
You are missing sub new just before the beginning '{' in TryOut.pm
Uhm, no, that's nonsense. See the Object::InsideOut docs please.

There _is_ a bug with the "Standard" attribute, but I haven't been able to put my finger on it just yet.

my @data :Field('Accessor' => 'data'); does generate a data accessor.

Adding the Permission=>'private' field results in

OIO::Method error: Can't call private method 'TryOut->data' from class 'main'
Package: main
File: object-insideout
Line: 19
So that works as expected. I suspect the "Standard" attribute doesn't actually work as documented. Maybe time for a bug report :)
#!/usr/bin/perl
use strict;
use warnings;

package TryOut;
use strict;
use warnings;
{
    use Object::InsideOut;
    my @data :Field('Accessor' => 'data', Permission=>'private');
}

1;

package main;

my $obj = TryOut->new();
$obj->data(42);
print $obj->data;

__END__
Re^3: Object::InsideOut, I don't get it
xdg
created: 2006-03-05 13:56:57
There _is_ a bug with the "Standard" attribute, but I haven't been able to put my finger on it just yet

I was surprised to see this bug so dug through the code a bit. The accessor generation is really woolly code, but as best as I can tell, the bug starts around line 1838, where the get accessors are defined -- it looks like the PRIVATE checks are added to code for later evaluation before the actually beginning of the declaration of the accessor -- so the check is called during the eval of the accessor code and thus fails during compilation.

Please do file this bug -- jdhedden is very responsive about bug fixes.

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Re^4: Object::InsideOut, I don't get it
created: 2006-03-05 21:10:30
Thanks for finding this. I'll upload a fixed version to CPAN right away.

Remember: There's always one more bug.
Re^2: Object::InsideOut, I don't get it
xdg
created: 2006-03-05 14:01:00

The brace style is particular to Object::InsideOut and not typical. There's additional commentary about it at AnnoCPAN.

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Re: Object::InsideOut, I don't get it
created: 2006-03-06 02:32:59
Well I just LOVE open source :) CPAN already reports the bug is fixed! Big thanks everyone, thanks jdhedden :)

perlmonks.org content © perlmonks.org and Anonymous Monk, gargle, jdhedden, liverpole, rhesa, xdg

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03