Re: MooseX::Role::Strict + MooseX::Role::Parameterized

2010-01-05 Thread Shawn M Moore
On 1/5/10 2:15 PM, Karen Etheridge wrote:
> Will MI still be required after your refactoring, or are you saying that
> your described approach will not work until the refactoring is done?

Uploaded 0.15 with said refactoring. I don't want to take the fun out of
figuring out how all the pieces fit together. The new role is
MooseX::Role::Parameterized::Meta::Trait::Parameterized.

Have fun!

Shawn


Re: MooseX::Role::Strict + MooseX::Role::Parameterized

2010-01-05 Thread Hans Dieter Pearcey
Excerpts from Karen Etheridge's message of Tue Jan 05 14:15:40 -0500 2010:
> > You'll have multiple inheritance, which obviously sucks. I'm sorry for
> > my half of that. It will be straightforward for me to refactor the guts
> > of MooseX::Role::Parameterized::Meta::Role::Parameterizable (which is
> > just two attributes) into a role. I'll do that at some point this week.
>  
> Will MI still be required after your refactoring, or are you saying that
> your described approach will not work until the refactoring is done?

Neither.  His described approach will work but sucks because it (currently)
requires MI.  After his refactoring, you'd need to do something slightly
different, because you'll need use a role instead of MI.

hdp.


Re: MooseX::Role::Strict + MooseX::Role::Parameterized

2010-01-05 Thread Shawn M Moore
On 1/5/10 2:15 PM, Karen Etheridge wrote:
>> You'll have multiple inheritance, which obviously sucks. I'm sorry for
>> my half of that. It will be straightforward for me to refactor the guts
>> of MooseX::Role::Parameterized::Meta::Role::Parameterizable (which is
>> just two attributes) into a role. I'll do that at some point this week.
>  
> Will MI still be required after your refactoring, or are you saying that
> your described approach will not work until the refactoring is done?

MI will be required until after my refactoring, when it switches over to
single inheritance (of MooseX::Meta::Role::Strict) plus role application
(of whatever role I factor out of
MooseX::Role::Parameterized::Meta::Role::Parameterized).

Shawn


Re: MooseX::Role::Strict + MooseX::Role::Parameterized

2010-01-05 Thread Karen Etheridge
On Tue, Jan 05, 2010 at 01:33:41PM -0500, Shawn M Moore wrote:
> Hopefully that makes some amount of sense. You have a lot of
> metaprogramming ahead of you. Good luck and feel free to ask plenty more
> questions.

Awesome! When I get this nasty deadline out of the way I'll play around and
see what happens :)

> You'll have multiple inheritance, which obviously sucks. I'm sorry for
> my half of that. It will be straightforward for me to refactor the guts
> of MooseX::Role::Parameterized::Meta::Role::Parameterizable (which is
> just two attributes) into a role. I'll do that at some point this week.
 
Will MI still be required after your refactoring, or are you saying that
your described approach will not work until the refactoring is done?

thanks again!


-- 
   Vote Cthulhu: "For when you're tired of the lesser evil"
. ... .
Karen Etheridge, ka...@etheridge.ca   GCS C+++$ USL+++$ P+++$ w--- M++
http://etheridge.ca/  PS++ PE-- b++ DI e++ h(-)


Re: MooseX::Role::Strict + MooseX::Role::Parameterized

2010-01-05 Thread Shawn M Moore
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 1/4/10 10:38 PM, Karen Etheridge wrote:
> What would it take to gain the properties of MooseX::Role::Strict in
> MooseX::Role::Parameterized?  I've been using strict roles everywhere and
> love them -- they've caught a few bugs that I'm sure would have been
> dreadful to track down otherwise; now I'm parameterizing a few of my roles
> and I'm mourning the loss of strict checking.

MooseX::Role::Parameterized is designed to be as extensible as Moose, so
I would hope that it can support this.

When you say "package Foo; use MooseX::Role::Parameterized;" it creates
a role metaobject for Foo, the class of which is
MooseX::Role::Parameterized::Meta::Role::Parameterizable (quite a
mouthful). In MXRPMRP there is a constant:

use constant parameterized_role_metaclass =>
'MooseX::Role::Parameterized::Meta::Role::Parameterized';

This constant decides the class of the role metaobject created when you
apply the parameterized role. So, to get what you want, I think you need to:

1. define a class (for now let's call it Role::Strict::Parameterized)
   1a. subclass MooseX::Role::Parameterized::Meta::Role::Parameterized
   1b. also subclass MooseX::Meta::Role::Strict
2. subclass MooseX::Role::Parameterized::Meta::Role::Parameterizable
   2a. use constant parameterized_role_metaclass =>
'Role::Strict::Parameterized';

You'll have multiple inheritance, which obviously sucks. I'm sorry for
my half of that. It will be straightforward for me to refactor the guts
of MooseX::Role::Parameterized::Meta::Role::Parameterizable (which is
just two attributes) into a role. I'll do that at some point this week.

Hopefully that makes some amount of sense. You have a lot of
metaprogramming ahead of you. Good luck and feel free to ask plenty more
questions.

Shawn
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (Darwin)

iEYEARECAAYFAktDhgUACgkQsxfQtHhyRPosIwCdER+flH5ar2QKXAYM9N9q9lZC
E2oAn3Q/KWHR3xJX9zSQqGStghhLBFHT
=CN+X
-END PGP SIGNATURE-


Re: MooseX::Role::Strict + MooseX::Role::Parameterized

2010-01-05 Thread Ovid
--- On Tue, 5/1/10, Karen Etheridge  wrote:

> From: Karen Etheridge 

> What would it take to gain the properties of
> MooseX::Role::Strict in
> MooseX::Role::Parameterized?  I've been using strict
> roles everywhere and
> love them -- they've caught a few bugs that I'm sure would
> have been
> dreadful to track down otherwise; now I'm parameterizing a
> few of my roles
> and I'm mourning the loss of strict checking.
> 
> I've been meaning to find the time to just sit down and do
> some experiments
> myself (I've done a bit of meta hacking with traits and
> Moose::Exporter),
> but I'd like to toss the question out there in case anyone
> else has thought
> along similar lines.

I haven't tried it, but have you tried this?

  package Force::Strict::Roles;
  use MooseX::Strict::Role;
  1;

And then in your parameterized role:

  package SOme::Param::Role;
  use MooseX::Role::Parameterized;
  with 'Force::Strict::Roles';
  ...

???

Again, that's not tested, but it might work for you.

That being said, I need to write MooseX::Role::Warning.  That's less safe, but 
it scales better for roles released to the CPAN.

Cheers,
Ovid
--
Buy the book - http://www.oreilly.com/catalog/perlhks/
Tech blog- http://use.perl.org/~Ovid/journal/
Twitter  - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6