Skip Menu |
 

This queue is for tickets about the MooseX-InsideOut CPAN distribution.

Report information
The Basics
Id: 36169
Status: rejected
Priority: 0/
Queue: MooseX-InsideOut

People
Owner: hdp [...] cpan.org
Requestors: tfrayner [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: inside-out data incapsulation question
Date: Sun, 25 May 2008 10:46:40 +0100
To: bug-MooseX-InsideOut [...] rt.cpan.org
From: "Tim Rayner" <tfrayner [...] gmail.com>
Hi, Apologies if I've misunderstood your code, but are the objects created when using this package strictly inside-out? It appears that the internal attribute store is still based around a hashref of attributes (stored in a class attribute hashref, but that's not the problem): $__attr{refaddr $instance}->{$slot_name}; whereas (it is my understanding that) a typical inside-out class would normally store attributes like this: $__attr{$slot_name}->{refaddr $instance}; This would then encapsulate the data better, preventing subclasses from interfering with the superclasses attributes. Below is a short code snippet to illustrate the problem; this code prints out "test", indicating that the superclass Foo attribute "bar" has been overwritten by the corresponding subclass Baz attribute: #################### package Foo; use MooseX::InsideOut; has "bar" => (is => "rw"); sub get_val { my $self=shift; return $self->bar; } package Baz; use MooseX::InsideOut; extends "Foo"; has "bar" => (is => "rw"); package main; my $f=Baz->new(bar=>"test"); print $f->get_val; ##################### Many thanks, Tim
Download (untitled) / with headers
text/plain 779b
On Sun May 25 05:47:07 2008, tfrayner@gmail.com wrote: Show quoted text
> Apologies if I've misunderstood your code, but are the objects created
when Show quoted text
> using this package strictly inside-out? It appears that the internal > attribute store is still based around a hashref of attributes (stored in a > class attribute hashref, but that's not the problem):
There's no reason to tie the behavior you're talking about to the internal storage of the instance; write an attribute metaclass for it instead. Attribute accesses in the superclass would still find the subclass' accessor, because that's how Perl method lookup works. (Also, your example of a 'typical inside-out class' wouldn't change anything; you need to add a lookup based on the class that defines the attribute.) Anyway, not a bug.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.