Sartak wrote:
> On Tue, Sep 9, 2008 at 4:20 AM, Michael G Schwern <[EMAIL PROTECTED]> wrote:
>> I looked at just copying in Mouse, but Mouse has dependencies which 
>> themselves
>> have dependencies, some of them with XS.  Ideally, what I want is 
>> Mouse::Tiny,
>> or as I like to put it, "Muscle". [2]  A stand-alone, single file, no 
>> non-core
>> dependencies, 5.6 compatible implementation of 80% of Moose.  That way I can
>> just copy it into the Test::Builder2 distribution and have a real OO system.
> 
> I'd love to see Mouse itself go this way. There's little point in
> having a lightweight Moose that has a number of dependencies
> (especially XS). It looks like we could make all the dependencies
> optional, and only required if you use the features.

Excellent.


> Here are Mouse's direct dependencies, and why we have them:
> 
> * Sub::Exporter is used for a more powerful export. I use its extra
> features (as a user of a Sub::Exporter module) very infrequently, so
> being able to drop down to regular Exporter would be useful.

It looks like extends(), has() and with() all depend on Sub::Exporter's
ability to customize by caller.  However, that's easily emulated.


> * Scalar::Util is used for blessed, weaken, looks_like_number, and
> openhandle. It's in core as of 5.8, but if we need 5.6 then I think we
> can make it work:
> 
> - looks_like_number and openhandle are used only for the Num and
> FileHandle type constraints. These aren't used very often as far as I
> know, so perhaps we can delay-require Scalar::Util.
> 
> - weaken is only used whenever you want weak refs for an attribute. I
> personally do this with some frequency. But if you don't use it
> 
> - blessed is used a lot. "use Mouse" also exports it. We could
> probably provide an alternate implementation that uses ref and makes
> sure it isn't a builtin type.

looks_like_number(), openhandle() and blessed() all have short, pure Perl
versions that can be easily copied.

weaken requires XS and weak ref support, but it's perfectly fine to load that
on demand.


> * MRO::Compat is used for get_linear_isa. We could implement this in
> Perl (and using mro::get_linear_isa if $] >= 5.10).

It looks like that can all be separated from Class::C3.  I wonder what the
performance hit will be?


> * Class::Method::Modifiers are used for before/after/around. I wrote
> this one, so we have more flexibility here. It's only a few pages of
> code, so we could just add it into Mouse::OneFile, or again delay-load
> it.

That appears to only depend on MRO::Compat which we have to deal with anyway,
so it looks like a straight copy is possible.  before, after and around will
be useful for TB2.


-- 
E: "Would you want to maintain a 5000 line Perl program?"
d: "Why would you write a 5000 line program?"

Reply via email to