Skip Menu |

This queue is for tickets about the Package-Variant CPAN distribution.

Report information
The Basics
Id: 87722
Status: resolved
Priority: 0/
Queue: Package-Variant

People
Owner: Nobody in particular
Requestors: KENTNL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.001004
Fixed in: 1.002000



Subject: [FEATUREREQ] Role generation method on the variant package

Mostly, this kinda irks me:

> use Some::Long::Package;
> with Package(@args);

Because you have to be smart about it, especially with Moo Roles, as  you must declare 'use' **BEFORE** 'use Moo::Role'

> package Bar
> use Moo::Role;
> use Some::Package   # exports Package()  as a method of Bar !
> with Package(@args);

So you have to order it thusly:

> package Bar
> use Some::Package   # exports Package()  as a method of Bar !
> use Moo::Role;
> with Package(@args);

Or face the risk of a collision when the same role is aggregated into the same, despite the variant design not being an inherent problem due to exporting different method names.

=~  Please add a feature in this sort of vein:

> package Bar;
> use Moo::Role;
> require Some::Package;  # fuck imports ! :D
> with Some::Package->build_variant( @args );

Or it could even be standardised into a thing, like

> package Bar;
> use Moo::Role;
> require Some::Package;  # fuck imports ! :D
> with Some::Package->COMPOSE_ROLE( @args );

And then even Moose could support it with their `with` syntax

> package Bar;
> use Moose::Role;
> with Some::Package => { @args };

....
 

Somewhere in Moose

>  if ( $element[$i]->can('COMPOSE_ROLE') and ref $element->[$i+1] ){
>     blahblahblah( $element[$i]->COMPOSE_ROLE($element[$i+1]) )
> }

On Thu Aug 08 20:11:09 2013, KENTNL wrote: Show quoted text
> Mostly, this kinda irks me: >
> > use Some::Long::Package; > > with Package(@args);
> > Because you have to be smart about it, especially with Moo Roles, as > you must > declare 'use' **BEFORE** 'use Moo::Role' >
> > package Bar > > use Moo::Role; > > use Some::Package # exports Package() as a method of Bar ! > > with Package(@args);
> > So you have to order it thusly: >
> > package Bar > > use Some::Package # exports Package() as a method of Bar ! > > use Moo::Role; > > with Package(@args);
> > Or face the risk of a collision when the same role is aggregated into > the same, > despite the variant design not being an inherent problem due to > exporting > different method names. > > =~ Please add a feature in this sort of vein: >
> > package Bar; > > use Moo::Role; > > require Some::Package; # fuck imports ! :D > > with Some::Package->build_variant( @args );
> > Or it could even be standardised into a thing, like >
> > package Bar; > > use Moo::Role; > > require Some::Package; # fuck imports ! :D > > with Some::Package->COMPOSE_ROLE( @args );
> > And then even Moose could support it with their `with` syntax >
> > package Bar; > > use Moose::Role; > > with Some::Package => { @args };
> > .... > > Somewhere in Moose >
> > if ( $element[$i]->can('COMPOSE_ROLE') and ref $element->[$i+1] ){ > > blahblahblah( $element[$i]->COMPOSE_ROLE($element[$i+1]) ) > > }
COMPOSE_ROLE isn't an entirely appropriate name, as Package::Variant isn't specific to roles. I've added ->build_variant as a method on variable packages in git. It will be included in the next release.
Added in 1.002000.