Stevan Little wrote: > A truely *pure* object system would not have classes at all, a class > would itself be just an *instance* of $Class which itself would be an > instance of $Class (http://www.iinteractive.com/moose/images/ > class_mop_model.jpg). In that sense, you don't ever distinguish the > difference between class and instance data, it is just obvious that > "class" data is means instance data in the metaclass. > > I try to mimic this in Class::MOP as best I can, but in order to make > it useable and not full of AUTOLOAD crack, it has to bind itself to > the Perl notion of packages, classes and blessed instances. Once I > have the ability to overload -> (*wink*) then I can abandon the > (broken) packages == classes idea and be able to implement that more > pure system I speak about above (*cough* Moose 2.0 *cough*). > I can appreciate the difficulty of wrangling Perl's object model, etc., and I have nothing but admiration for those who do that for the rest of us. Just in case, I'm not demanding (as if I could anyway) that this or that feature be implemented. I'm only trying to figure out what the current limits of Moose are, and whether there are alternative ways to accomplish what I need, in a sort of trial-and-error way ("can this be done", "if not, could it be implemented easily").
>> Now, I know that this may be a bit of a lame argument, since Perl >> is so lousy >> about distinguishing class and instance methods, so I will not >> insert a >> dramatic sting and an "AHA!" here. I just think that it's one bit >> of evidence >> that roles affect class behavior as well as instance behavior. > >> If that's the case, class attributes should be able to be provided >> by a role. > > Hmm, not sure that the argument for adding a feature should be "so > that it can match the other broken features" :P In my simplistic view of the world, the reasoning goes something like this: - I want an attribute that will have the same value across all objects of a class; - then I read "[MooseX::ClassAttribute] allows you to declare class attributes in exactly the same way as you declare object attributes, except using class_has() instead of has()"; - then I read "Moose::Role currently supports all of the functions that Moose exports, but differs slightly [...]"; - and finally a lightbulb turns on in my head... :-) Of course, class attributes are not supported by Moose, but by Dave's MooseX::ClassAttributes; but still. > My personal feeling is that class level data and methods are bad, and > that they should generally be avoided in a design. Quite often a > Singleton or even just a regular old instance will be enough to > replace that need. Of course, this is *my* approach and TIMTOWTDI so > feel free to ignore. OK, more food for thought. Thanks again, Stevan. Bernardo