in reply to Moose & Moose::Object
However, When I check the source code(2) of Moose.pm, It seems to me that Moose.pm only use Moose::Object, that is , import its functions, instead of inheriting from it.
Actually Moose.pm is using Moose::Object, but it is not importing it's functions. In order for that to happen Moose::Object would have to define an import method as well as implement code to do the importing, neither of which you will see if you read the source.
Instead what happens is that Moose.pm defines an import method when it calls Moose::Exporter->setup_import_methods (about line 121 of Moose 0.94), that import method eventually calls the init_meta method defined right below that. In init_meta the "base_class" is assigned as 'Moose::Object' (assuming you didn't tell Moose to do otherwise) and eventually that will become the value of @ISA in your package. If you later call extends 'DBIx::Class' in your code, then the value of @ISA will then be DBIx::Class and no longer be Moose::Object.
The idea here is that Moose wants to provide you with the basic mechanisms needed by just about every object, such as: constructor (new), initialization mechanism (BUILDALL/BUILD), destructor (DESTROY), a teardown mechanism (DEMOLISHALL/DEMOLISH) and some introspection methods (does, DOES, meta, etc). In order to do this it makes the most sense to inherit from Moose::Object as a base class.
So, do I miss something here?
No, I think your just thinking about it too hard, and perhaps not asking the right questions. Based on your last few posts I suspect you are trying to mix Moose and DBIx::Class in some way. This has actually been done many times before to varying degrees of success, for some definition of success. The real solution is to re-write DBIx::Class in Moose and as far as I know there are some plans for doing just that (not sure how far along they are or aren't at this point).
If you want to understand the guts of Moose then I recommend first reading Class::MOP as it is simpler to digest and will give you the foundation with which to understand some of the more complex aspects of Moose. Perhaps you might also consider visiting us on IRC in #moose or #moose-dev, we will be happy to answer your detailed questions there. Myself (the original author) and the entire core development team are pretty much always in channel.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Moose & Moose::Object
by sman (Beadle) on Jan 24, 2010 at 02:55 UTC |