Hi,

"has" doesn't create an accessor for an attribute. "is" or "accessor" does.

On Wed, Jun 3, 2009 at 8:00 PM, Ovid <[email protected]> wrote:

>
> Could someone please explain to me what I'm doing wrong here?
>
>    #!/usr/bin/env perl
>
>    {
>        package My::Base;
>        use Moose;
>        has some_method => ( default => 'foo' );
>    }
>    {
>        package My::Class;
>        use Moose;
>        extends 'My::Base';
>    }
>    print My::Base->new->some_method;
>    __END__
>    Can't locate object method "some_method" via package "My::Base" at
> inherit.pl line 16.
>
> Changing the some_method attribute to the following makes this go away:
>
>    has some_method => ( is => 'rw', default => 'foo' );
>
> (is => 'ro', default => 'foo') also works.
>
> Is this a bug or have I misunderstood something?  This is Moose 0.79 and
> perl, v5.8.8 built for i486-linux-gnu-thread-multi. (Also fails on Solaris,
> so I doubt it's an OS issue).
>
> If this is a bug, I'll file a report.
>
> Cheers,
> Ovid
> --
> Buy the book         - http://www.oreilly.com/catalog/perlhks/
> Tech blog            - http://use.perl.org/~Ovid/journal/
> Twitter              - http://twitter.com/OvidPerl
> Official Perl 6 Wiki - http://www.perlfoundation.org/perl6
>
>


-- 
Regards,
Mikhail

Reply via email to