On Fri, Nov 06, 2009 at 12:04:34AM -0800, Ovid wrote:
> ----- Original Message ----
> 
> > From: Jesse Luehrs <d...@tozt.net>
> 
> > Hmmm, maybe we need a more intelligent check then. I do think that
> > overwriting an existing accessor like this shouldn't be allowed... it
> > implies functionality that really isn't possible.
> 
> Well, Moose already allows some pretty dubious things with accessors.  
> Consider the following:
> 
>     {
>         package One;
>         use Moose;
> 
>         has counter => ( is => 'rw', isa => 'Int', default => 1 );
> 
>         sub inc_counter {
>             my $self = shift;
>             $self->counter( $self->counter + 1 );
>         }
>     }
>     {
>         package Two;
>         use Moose;
>         extends 'One';
>         has '+counter' => ( isa => 'Bool' );
>     }
>     my $two = Two->new;
>     say $two->counter;
>     $two->inc_counter;
> 
> That's a runtime bug which probably shouldn't be there, but Moose doesn't 
> really have a way of detecting that.  Being able to change your 'isa' is 
> arguably worse than being able to add a trigger :)

What's the issue here? This dies for me, saying that '2' isn't a valid
Bool, which is what i'd expect it to do.

-doy

Reply via email to