> but the following one doesn't:
> has $_ => (is => 'rw', isa => 'Str') for 'a' .. 'zzz';

Something about this I find especially amusing, but to drive the point
home with today's poorly worded Double Jeopardy question? What does
the following do?

package Class;
use Moose;
package main;
Class->new->has( 'foo', {isa=>'Str', is => 'rw'} );

And the forbidden Triple Jeopardy question? What ways can you have
prevented this with a much more simplistic failure?






/* spoiler below */







package Class;
use Moose;
# stuff;
no Moose;

package Class;
use Moose;
use namespace::clean; # cleans up all things before it
# stuff;


package Class;
use namespace::autoclean; # cleans up all things
use Moose;
# stuff;

Moose pollutes your namespace with keywords (functions), which perl
can't differentiate from real object methods (functions blessed into
the package (class)). It is just part of the object model. I only
posted this diatribe because I doubt you're using
namespace::autoclean, namespace::clean, or `no Moose`ing it, and you
really should be.

Another aside, Moose provides a `meta` that does keep track of
installed attributes, which does help you differentiate between random
crap in the package and true accessors - it even provides an API for
you to get to them, without explicitly calling them by name. This
should open up the ability for you to create attributes named after
Moose keywords that are totally inaccessible to code that doesn't
explicitly use meta.
http://search.cpan.org/~flora/Class-MOP-1.03/lib/Class/MOP/Instance.pm

-- 
Evan Carroll
System Lord of the Internets

Reply via email to