[html-formfu] moose?

Carl Franks fireartist at gmail.com
Fri Mar 6 11:46:37 GMT 2009


2009/3/5 Octavian Râsnita <orasnita at gmail.com>:
> From: "Carl Franks" <fireartist at gmail.com>
>>
>> I think Any::Moose is a bad idea.
>> Unless all your dependencies use it - which isn't going to happen as
>> it's not mentioned in the Moose docs - it will cause problems.
>> If a dependency starts to "use Moose", then everything using "use
>> Any::Moose" will silently switch from using Mouse to Moose.
>
> This is something good, not bad. If a dependency uses Moose, the program
> will also use Moose, which would be a little slower, but if no dependency
> uses Moose, then it will use Mouse, which would be faster.

Sorry, I've just realised that my original description wasn't very
well written - the problem is that everything *won't* magically switch
to using Moose.
Take the following as an example:

package MyA;
use Any::Moose;
1;

package MyB;
use Moose;
1;

package MyC;
use Any::Moose;
1;

package main;
use Data::Dumper;
use MyA;
use MyB;
use MyC;

sub using {
    my ($class) = @_;
    no warnings;
    print Data::Dumper->Dump([ eval "\\\%{${class}::}->{has}" ], [$class]);
}

using('MyA');
using('MyB');
using('MyC');

### This prints the following...
$MyA = \*Mouse::has;
$MyB = \*MyB::has;
$MyC = \*Mouse::has;
###

MyA uses Any::Moose which loads Mouse
MyB uses Moose
MyC uses Any::Moose which still uses Mouse

Take the instance that one of your dependencies starts using Moose:
unless you get really lucky and it happens to load before anything
using Any::Moose,
then the only way to ensure Any::Moose correctly uses Moose rather
than Mouse is to keep track of all your dependencies, and every time
you update any cpan module, check whether 'Moose.pm' has sneaked into
your %INC.
And then add "use Moose" to your main program, to ensure it's loaded
before any "use Any::Moose" statement.

Now, if you have a thorough application test suite which you run after
any upgrade, it's arguable whether or not it's really a problem that
parts of the code uses Moose, and other parts Mouse.

But I would argue that Mouse + Any::Moose only have a legitimate place
in end-users' application code, and not cpan modules.

Cheers,
Carl



More information about the HTML-FormFu mailing list