Actually, the 'deny' vs. 'allowed' issue re: legal_options_for_inheritance was brought up in this thread:

http://thread.gmane.org/gmane.comp.lang.perl.moose/989/focus=990

Seemed like there was some consensus about using something like a 'deny' list instead.

chris

On Aug 29, 2009, at 7:29 PM, Tuomas Jormola wrote:

Hi,

This was discussed about attribute options inheritance on IRC:

00:03 < tj> hi, any moose gurus around who could try explaining about the attribute options inheritance to a novice?
00:04 <@mst> start with which doc you've read and what wasn't clear
00:04 <@mst> we'll trade an explanation for a write-up for thre next guy :) 00:06 < tj> well i've read Moose::Manual::Attributes and read Moose::Meta::Attributes code 00:07 < tj> the docs and code states that you can only inherit a certain set of attributes defined in moose core
00:07 <@mst> yeah
00:07 < tj> why such an arbitrary limitation?
00:07 <+shadowpaste> "tj" at 217.168.144.84 pasted "sample code for question about @legal_options_for_inheritance" (21 lines) at http://scsys.co.uk:8001/33209
00:07 < tj> i'd like to do something like that
00:08 <@mst> hrm
00:08 <@mst> I wonder if the MXMD stuff gets to add entries
00:09 < tj> i was wondering why attribute metaclasses can't define additional attribute options that are valid for inheritance
00:09 <@doy> they can
00:09 <@doy> this one just doesn't, apparently
00:10 < tj> ah ok
00:10 <@mst> honestly
00:10 <@mst> I think I'd much rather have a deny list than an allow list
00:10 <@doy> yeah
00:10 <@mst> wonder if we can covnince stevan of that :)
00:10 < tj> would save some trouble for module writers
00:10 <@mst> sure
00:10 <@mst> it'd also make it easier to shoot yourself in the foot
00:10 <@doy> i think we did at one point, and then nobody did anything about it
00:11 <@doy> but i might be misremembering
00:11 < tj> heh
00:11 < tj> someone care pointing the docs how to do that, i could patch MooseX::MetaDescription::Meta::Attribute and send it to upstream
00:12 < tj> just override legal_options_for_inheritance() ?
00:12 <@doy> around legal_options_for_inheritance => sub {
00:12 <@doy> yeah
00:13 < tj> let me try
00:20 < tj> ah but in my case it won't ever work, of course
00:21 < tj> since 'bar' is just an instance of Moose::Meta::Attribute metaclass, it doesn't magically become MooseX::MetaDescription::Meta::Attribute even if a subclass redefines the metaclass option 00:21 <@perigrin> mst: stevan has already said "yes" for making it a deny list
00:22 <@perigrin> nobody has done the work yet.
00:22 <@perigrin> well volunteered.
00:25 <@mst> tj: so there you go
00:26 <@mst> tj: all you have to do is invert the implementation and tweak the tests
00:26 <@rjbs> tj: you will win the accolades of all
00:27 <@perigrin> tj: information on patching Moose is in Moose::Manual::Contribution
00:27 < tj> ok could take a look

So here's my try on this:
http://scm.solitudo.net/gitweb?p=Moose.git;a=commitdiff;h=topics/inversed-legal-attribute-option-inheritance

Feel free to merge/steal ideas from http://scm.solitudo.net/git/Moose.git
branch topics/inversed-legal-attribute-option-inheritance.

--
Tuomas Jormola <t...@solitudo.net>

Reply via email to