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