changelog
[gitmo/Moose.git] / TODO
CommitLineData
5dbb47c8 1== Todo for 2.0400
85910734 2
3=== Revise MetaRole API to reunify class/role metaroles:
4
5 apply_metaroles(
6 for => $meta,
7 roles => {
8 attribute => [...],
9 class => [...],
10 role_attribute => [ ... ],
11 }
12 );
13
14If the $meta is a class, we apply the roles to the class. If it's a role, we
15hold onto them and apply them as part of applying the role to a class.
16
17To make this all work nicely, we'll probably want to track the original role
18where a method was defined, just like we do with attributes currently. We'll
19also need to store method modifiers with their original role, which may mean
20adding some sort of Moose::Meta::Role::MethodModifier class.
21
22For each role-specific thing (methods, attributes, etc.) we should allow a
23role_attribute, role_method, etc. key. The common case will be that the
24metaroles are intended for the consuming class, but we should allow for
25metaroles on the role's metaobjects as well.
26
24b9aca7 27=== Deprecate old-style Moose extensions
28
29Moose extensions that work by calling Moose->init_meta(metaclass =>
30'Some::Custom::Metaclass', ...) during their own init_meta should be
31deprecated, so they can be removed later (this should fix the issues with
32init_meta generation in Moose::Exporter, see RT51561)
33
34=== Register implicitly created class/role types
35
36When you do has foo => (isa => 'Bar'), it returns a class_type for Bar, but
37doesn't register it. This means that later you can declare "subtype 'Bar', as
38'Str', ..." and it'll work, and later instances of the 'Bar' type will use that
39one. We should register the implicitly created ones so that trying to redefine
40it after it's used throws an error.
41
42=== Attributes in roles need to be able to participate in role composition
43
44Right now, this fails with no decent workaround:
45
46 package R1;
47 use Moose::Role;
48 has foo => (is => 'ro');
49
50 package R2;
51 use Moose::Role;
52 with 'R1';
53 requires 'foo';
54
55 package C;
56 use Moose;
57 with 'R2';
58
59Role attributes really need to be able to participate in role-role combination.
60This should also fix "with 'Role1', 'Role2'" being broken when Role1 implements
61a method as an accessor and Role2 requires that method, but at least in that
62case you can split it into two 'with' statements with minimal loss of
63functionality.
64
65=== Method modifiers in roles should silently add 'requires' for them
66
67This shouldn't be a functionality change, just a better error message (and
68better introspectability). This shouldn't happen if the role already contains a
69method by that name, so it'll depend on the previous fix going in (so "has foo
70=> (is => 'ro'); around foo => sub { }" doesn't produce a 'requires' entry).
71
72=== Add overloading support
73
74or at least, don't break existing overloading support
75
76This shouldn't treat the overloading stuff as actual methods, since that's just
77an implementation detail, but we should provide an API for add_overload,
78get_overload, get_overload_list, etc. In particular, this would allow
79namespace::autoclean to not break things.
80
81Also, MooseX::Role::WithOverloading should probably be cored.
82
83
84== Todo for later
85
86=== Actual API for metaclass extensions
87
88Right now, the only way to bundle multiple metaclass traits is via
89Moose::Exporter. This is unhelpful if you want to apply the extension to a
90metaclass object rather than a class you're actually writing. We should come up
91with an API for doing this.
92
93=== MooseX::NonMoose in core
94
95I think all of the actual issues are solved at this point. The only issue is
96the (necessary) implementation weirdness - it sets up multiple inheritance
97between the non-Moose class and Moose::Object, and it installs a custom
98constructor method at 'extends' time (although perhaps this could be solved by
99moving some of the logic back into Moose::Object::new?). Other than that, it
100handles everything transparently as far as I can tell.
101
102=== Fix attribute and method metaclass compatibility
103
104So i got this wrong when rewriting it last year - right now, metaclass compat
105checks the default attribute and method metaclasses, which is wrong. This means
106that if a parent class does "use MooseX::FollowPBP", then attributes declared
107in a subclass will get PBP-style accessors, which is quite surprising.
108
109On the other hand, sometimes metaclasses might need to be able to say "I'm
110going to assume that all of my attributes at least inherit from this custom
111class", so we might need to split it into "default specified by the user" and
112"default specified by the metaclass" and only do compat checking on the second?
113I'm not actually sure this is a valid use case though.
114
115Something that probably should be taken into account though is attributes and
116methods that extend existing attributes or methods from a superclass should
117inherit the metaclass of the existing one. Also not sure if this is correct,
118but something to think about.
119
120=== Rename a bunch of the public API methods
121
122Right now the public API is kind of a mess - we have things like get_method vs
123find_method_by_name (you almost always want to use the latter), there being no
124has_method equivalent that checks superclasses, get_method_list being public
125but only returning method names, while _get_local_methods is private (returning
126method objects), and yet neither of those looks at superclasses, and basically
127none of this naming follows any kind of consistent pattern.
128
129What we really need is a consistent and easy to remember API where the method
130that people would think to use first is the method that they actually mean.
131Something like renaming find_method_by_name to find_method, and get_method to
132find_local_method or something along those lines.
133
134
135== Things to contemplate
136
137=== Does applying metaroles really need to reinitialize the metaclass?
138
139Seems like the logic that's actually necessary is already contained in
140rebless_instance, and not reinitializing means that existing attributes and
141methods won't be blown away when metaroles are applied.
142
143=== Do we want to core namespace::autoclean behavior somehow?
144
145This would add Variable::Magic as a required XS dep (not a huge deal at the
146moment, since Sub::Name is also a required XS dep, but it'd be nice for Moose
147to be able to be pure perl again at some point in the future, and I'm not sure
148what the relative chances of Sub::Name vs Variable::Magic making it into core
149are). If we enabled it by default, this would also break things for people who
150have introduced Moose into legacy-ish systems where roles are faked using
151exporters (since those imported methods would be cleaned).
152
153If we decide we want this, we may want to core it as an option first ("use
154Moose -clean" or so), and move to making it the default later.
155
156=== Fix the error system
157
158oh god it's terrible
159
160More specifically, we really want exception objects.
161
162=== Should using -excludes with a role add 'requires' for excluded methods?
163
164It seems to make sense, since otherwise you're violating the role's API
165contract.
166
167
85910734 168== Old todo (does anyone look at this?)
169
8b59f8d6 170-------------------------------------------------------------------------------
7af2c1d2 171BUGS
d03bd989 172-------------------------------------------------------------------------------
43d599e5 173
174-------------------------------------------------------------------------------
7af2c1d2 175FEATURES
8b59f8d6 176-------------------------------------------------------------------------------
177
d4967760 178- DDuncan's Str types
179
d03bd989 180subtype 'Str'
181 => as 'Value'
182 => where { Encode::is_utf8( $_[0] ) or $_[0] !~ m/[^0x00-0x7F]/x }
d4967760 183 => optimize_as { defined($_[0]) && !ref($_[0]) };
184
d03bd989 185subtype 'Blob'
186 => as 'Value'
187 => where { !Encode::is_utf8( $_[0] ) }
d4967760 188 => optimize_as { defined($_[0]) && !ref($_[0]) };
189
8b59f8d6 190- type unions
191
d03bd989 192Add support for doing it with Classes which do not have
8b59f8d6 193a type constraint yet created
194
195- type intersections
196
197Mostly just for Roles
198
199- inherited slot specs
200
db1ab48d 201'does' can be added to,.. but not changed
202(need type unions for this)
8b59f8d6 203
8b59f8d6 204- proxy attributes
205
db1ab48d 206a proxied attribute is an attribute
d03bd989 207which looks like an attribute,
208talks like an attribute, smells
209like an attribute,.. but if you
210look behind the curtain,.. its
db1ab48d 211over there.. in that other object
212
213(... probably be a custom metaclass)
8b59f8d6 214
f90e052d 215- local coerce
216
217[13:16] mst stevan: slight problem with coerce
218[13:16] mst I only get to declare it once
219[13:17] mst so if I'm trying to declare it cast-style per-source-class rather than per-target-class
220[13:17] mst I am extremely screwed
221[13:17] stevan yes
d03bd989 222[13:17] stevan they are not class specific
f90e052d 223[13:18] stevan they are attached to the type constraint itself
224[13:18] * stevan ponders anon-coercion-metaobjects
225[13:18] mst yes, that's fine
226[13:19] mst but when I declare a class
227[13:19] mst I want to be able to say "this class coerces to X type via <this>"
228[13:19] stevan yeah something like that
229[13:19] stevan oh,.. hmm
230[13:20] stevan sort of like inflate/deflate?
231[13:20] stevan around the accessors?
232[13:25] * bluefeet has quit (Remote host closed the connection)
233[13:27] mst no
234[13:27] mst nothing like that
235[13:27] mst like a cast
236[13:31] mst stevan: $obj->foo($bar); where 'foo' expects a 'Foo' object
237[13:31] mst stevan: is effectively <Foo>$bar, right?
238[13:32] mst stevan: I want to be able to say in package Bar
239[13:32] mst stevan: coerce_to 'Foo' via { ... };
240[13:32] mst etc.
d03bd989 241[13:53] stevan hmm
242
f3dc2e80 243-----------------------------------------------------------
244-- Type Constraints refactor
245-----------------------------------------------------------
246
247- add support for locally scoped TC
248
249This would borrow from MooseX::TypeLibrary to prefix the TC with the name
250of the package. It would then be accesible from the outside as the fully
251scoped name, but the local attributes would use it first. (this would need support
252in the registry for this).
253
254- look into sugar extensions
255
256Use roles as sugar layer function providers (ala MooseX::AttributeHelpers). This
257would allow custom metaclasses to provide roles to extend the sugar syntax with.
258
259(NOTE: Talk to phaylon a bit more on this)
260
261- allow a switch of some kind to optionally turn TC checking off at runtime
262
263The type checks can get expensive and some people have suggested that allowing
264the checks to be turned off would be helpful for deploying into performance
265intensive systems. Perhaps this can actually be done as an option to make_immutable?
266
267- misc. minor bits
268
269* make the errors for TCs use ->message
270* look into localizing the messages too
271* make ANON TCs be lazy, so they can possibly be subsituted for the real thing later
272* make ANON TCs more introspectable
273* add this ...
274
275#
276# Type Definition
277#
278subtype 'Username',
279 from 'Str',
280 where { (/[a-z][a-z0-9]+/i or fail('Invalid character(s)'))
281 and (length($_) >= 5 or fail('Too short (less than 5 chars)'))
282 }
283on_fail { MyException->throw(value => $_[0], message => $_[1]) };
284
285# fail() will just return false unless the call is made via
286$tc->check_or_fail($value);
287
288* and then something like this:
289
290subtype Foo => as Bar => where { ... } => scoped => -global;
291subtype Foo => as Bar => where { ... } => scoped => -local;
292
293# or
294
295subtype Foo => as Bar => where { ... } => in __PACKAGE__ ;
296
297# or (not sure if it would be possible)
298
299my $Foo = subtype Bar => where { ... };
300
301# ----------
302
303[17:10] <autarch> stevan: it should do it if I pass coerce => 1 as part of the attribute definition
304[17:12] <stevan> autarch: what I am not 100% sure of is how to tell it to deep coerce and when to not
305[17:13] <stevan> cause a basic coerce is from A to B
306[17:13] <autarch> hmm
307[17:13] <stevan> which is valid for collection types too
308[17:13] <stevan> deep coercion is what you are asking for
309[17:13] <autarch> yeah
310[17:13] <stevan> so perhaps we add deep_coerce => 1
311[17:13] <stevan> which will do it
312[17:13] <autarch> that's fine for me
313[17:13] <stevan> k
314
315coerce_deeply => 1 # reads better
316
7af2c1d2 317-------------------------------------------------------------------------------
318INTERNALS
319-------------------------------------------------------------------------------
320
321- rationalize all the get_X methods for classes (and roles)
322
323We have get_attribute, get_attributes_list, get_all_attributes,
324etc. First, we need to make the method names consistent. If something
325returns an attribute vs a name, that needs to be clear from the method
326name. We also need to make sure that local vs. "entire inheritance
327chain" is clear from the name.
328
7af2c1d2 329This is mostly a CMOP change.
330
331- Metaclass constructors
332
333There's a _lot_ of different conventions in here. Some things to consider:
334
335* new vs _new
336* allowing new( 'name', %args ) vs ( name => 'name', %args )
337* Method->wrap vs Method->new
338
7af2c1d2 339- Moose::Meta::TypeConstraint::Parameter{izable,ized}
340
341The relationship between these two classes is very odd. In particular,
342this line in Parameterized is insane:
343
344 foreach my $type (Moose::Util::TypeConstraints::get_all_parameterizable_types()) {
345
346Why does it need to loop through all parameterizable types? Shouldn't
347it know which parameterizable type it "came from"?
348
349- Moose::Util::TypeConstraints vs Moose::Meta::Type{Coercion,Constraint}
350
351The Util module has _way_ too much functionality. It needs to be
352refactored so it's a thin sugar layer on top of the meta API. As it
353stands now, it does things like parse type names (and determine if
354they're valid), manage the registry, and much more.
355
7af2c1d2 356- Anything with a _(meta)?class method
357
358Every method that returns a class name needs to become a rw attribute
359that can be set via the constructor.
d03bd989 360
cac484fa 361- The Moose::Error stuff
362
363This is sort of half-implemented. We still use Carp directly, and the
364internals can't decide how to throw an error (is it
365Moose->throw_error, __PACKAGE__->throw_error, what?).
366
367The internals need to be made consistent before we expose this to the
368rest of the world.
369
8b59f8d6 370-------------------------------------------------------------------------------
371TO PONDER
372-------------------------------------------------------------------------------
373
374- Moose "strict" mode
375
376use Moose 'strict'; This would allow us to have all sort of expensive tests
d03bd989 377which can be turned off in prod.
378
8b59f8d6 379- Moose::Philosophy.pod
380
381To explain Moose from a very high level
382
687e52bb 383- moosedoc
8b59f8d6 384
687e52bb 385We certainly have enough meta-information to make pretty complete POD docs.
d03bd989 386
387
388