Added a todo item for 2.04
[gitmo/Moose.git] / TODO
1 == Todo for 2.0400
2
3 === RT Tickets
4
5 RT#67731 - Union types reports spurious parent types - https://rt.cpan.org/Ticket/Display.html?id=67731
6
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
18 If the $meta is a class, we apply the roles to the class. If it's a role, we
19 hold onto them and apply them as part of applying the role to a class.
20
21 To make this all work nicely, we'll probably want to track the original role
22 where a method was defined, just like we do with attributes currently. We'll
23 also need to store method modifiers with their original role, which may mean
24 adding some sort of Moose::Meta::Role::MethodModifier class.
25
26 For each role-specific thing (methods, attributes, etc.) we should allow a
27 role_attribute, role_method, etc. key. The common case will be that the
28 metaroles are intended for the consuming class, but we should allow for
29 metaroles on the role's metaobjects as well.
30
31 === Deprecate old-style Moose extensions
32
33 Moose extensions that work by calling Moose->init_meta(metaclass =>
34 'Some::Custom::Metaclass', ...) during their own init_meta should be
35 deprecated, so they can be removed later (this should fix the issues with
36 init_meta generation in Moose::Exporter, see RT51561)
37
38 === Register implicitly created class/role types
39
40 When you do has foo => (isa => 'Bar'), it returns a class_type for Bar, but
41 doesn'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
43 one. We should register the implicitly created ones so that trying to redefine
44 it after it's used throws an error.
45
46 === Attributes in roles need to be able to participate in role composition
47
48 Right 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
63 Role attributes really need to be able to participate in role-role combination.
64 This should also fix "with 'Role1', 'Role2'" being broken when Role1 implements
65 a method as an accessor and Role2 requires that method, but at least in that
66 case you can split it into two 'with' statements with minimal loss of
67 functionality.
68
69 === Method modifiers in roles should silently add 'requires' for them
70
71 This shouldn't be a functionality change, just a better error message (and
72 better introspectability). This shouldn't happen if the role already contains a
73 method 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
78 or at least, don't break existing overloading support
79
80 This shouldn't treat the overloading stuff as actual methods, since that's just
81 an implementation detail, but we should provide an API for add_overload,
82 get_overload, get_overload_list, etc. In particular, this would allow
83 namespace::autoclean to not break things.
84
85 Also, MooseX::Role::WithOverloading should probably be cored.
86
87
88 == Todo for later
89
90 === Actual API for metaclass extensions
91
92 Right now, the only way to bundle multiple metaclass traits is via
93 Moose::Exporter. This is unhelpful if you want to apply the extension to a
94 metaclass object rather than a class you're actually writing. We should come up
95 with an API for doing this.
96
97 === MooseX::NonMoose in core
98
99 I think all of the actual issues are solved at this point. The only issue is
100 the (necessary) implementation weirdness - it sets up multiple inheritance
101 between the non-Moose class and Moose::Object, and it installs a custom
102 constructor method at 'extends' time (although perhaps this could be solved by
103 moving some of the logic back into Moose::Object::new?). Other than that, it
104 handles everything transparently as far as I can tell.
105
106 === Fix attribute and method metaclass compatibility
107
108 So i got this wrong when rewriting it last year - right now, metaclass compat
109 checks the default attribute and method metaclasses, which is wrong. This means
110 that if a parent class does "use MooseX::FollowPBP", then attributes declared
111 in a subclass will get PBP-style accessors, which is quite surprising.
112
113 On the other hand, sometimes metaclasses might need to be able to say "I'm
114 going to assume that all of my attributes at least inherit from this custom
115 class", 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?
117 I'm not actually sure this is a valid use case though.
118
119 Something that probably should be taken into account though is attributes and
120 methods that extend existing attributes or methods from a superclass should
121 inherit the metaclass of the existing one. Also not sure if this is correct,
122 but something to think about.
123
124 === Rename a bunch of the public API methods
125
126 Right now the public API is kind of a mess - we have things like get_method vs
127 find_method_by_name (you almost always want to use the latter), there being no
128 has_method equivalent that checks superclasses, get_method_list being public
129 but only returning method names, while _get_local_methods is private (returning
130 method objects), and yet neither of those looks at superclasses, and basically
131 none of this naming follows any kind of consistent pattern.
132
133 What we really need is a consistent and easy to remember API where the method
134 that people would think to use first is the method that they actually mean.
135 Something like renaming find_method_by_name to find_method, and get_method to
136 find_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
143 Seems like the logic that's actually necessary is already contained in
144 rebless_instance, and not reinitializing means that existing attributes and
145 methods won't be blown away when metaroles are applied.
146
147 === Do we want to core namespace::autoclean behavior somehow?
148
149 This would add Variable::Magic as a required XS dep (not a huge deal at the
150 moment, since Sub::Name is also a required XS dep, but it'd be nice for Moose
151 to be able to be pure perl again at some point in the future, and I'm not sure
152 what the relative chances of Sub::Name vs Variable::Magic making it into core
153 are). If we enabled it by default, this would also break things for people who
154 have introduced Moose into legacy-ish systems where roles are faked using
155 exporters (since those imported methods would be cleaned).
156
157 If we decide we want this, we may want to core it as an option first ("use
158 Moose -clean" or so), and move to making it the default later.
159
160 === Fix the error system
161
162 oh god it's terrible
163
164 More specifically, we really want exception objects.
165
166 === Should using -excludes with a role add 'requires' for excluded methods?
167
168 It seems to make sense, since otherwise you're violating the role's API
169 contract.
170
171
172 == Old todo (does anyone look at this?)
173
174 -------------------------------------------------------------------------------
175 BUGS
176 -------------------------------------------------------------------------------
177
178 -------------------------------------------------------------------------------
179 FEATURES
180 -------------------------------------------------------------------------------
181
182 - DDuncan's Str types
183
184 subtype 'Str'
185     => as 'Value'
186     => where { Encode::is_utf8( $_[0] ) or $_[0] !~ m/[^0x00-0x7F]/x }
187     => optimize_as { defined($_[0]) && !ref($_[0]) };
188
189 subtype 'Blob'
190     => as 'Value'
191     => where { !Encode::is_utf8( $_[0] ) }
192     => optimize_as { defined($_[0]) && !ref($_[0]) };
193
194 - type unions
195
196 Add support for doing it with Classes which do not have
197 a type constraint yet created
198
199 - type intersections
200
201 Mostly just for Roles
202
203 - inherited slot specs
204
205 'does' can be added to,.. but not changed
206 (need type unions for this)
207
208 - proxy attributes
209
210 a proxied attribute is an attribute
211 which looks like an attribute,
212 talks like an attribute, smells
213 like an attribute,.. but if you
214 look behind the curtain,.. its
215 over there.. in that other object
216
217 (... probably be a custom metaclass)
218
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
226 [13:17]         stevan  they are not class specific
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.
245 [13:53]         stevan  hmm
246
247 -----------------------------------------------------------
248 -- Type Constraints refactor
249 -----------------------------------------------------------
250
251 - add support for locally scoped TC
252
253 This would borrow from MooseX::TypeLibrary to prefix the TC with the name
254 of the package. It would then be accesible from the outside as the fully
255 scoped name, but the local attributes would use it first. (this would need support
256 in the registry for this).
257
258 - look into sugar extensions
259
260 Use roles as sugar layer function providers (ala MooseX::AttributeHelpers). This
261 would 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
267 The type checks can get expensive and some people have suggested that allowing
268 the checks to be turned off would be helpful for deploying into performance
269 intensive 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 #
282 subtype '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         }
287 on_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
294 subtype Foo => as Bar => where { ... } => scoped => -global;
295 subtype Foo => as Bar => where { ... } => scoped => -local;
296
297 # or
298
299 subtype Foo => as Bar => where { ... } => in __PACKAGE__ ;
300
301 # or (not sure if it would be possible)
302
303 my $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
319 coerce_deeply => 1 # reads better
320
321 -------------------------------------------------------------------------------
322 INTERNALS
323 -------------------------------------------------------------------------------
324
325 - rationalize all the get_X methods for classes (and roles)
326
327 We have get_attribute, get_attributes_list, get_all_attributes,
328 etc. First, we need to make the method names consistent. If something
329 returns an attribute vs a name, that needs to be clear from the method
330 name. We also need to make sure that local vs. "entire inheritance
331 chain" is clear from the name.
332
333 This is mostly a CMOP change.
334
335 - Metaclass constructors
336
337 There'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
343 - Moose::Meta::TypeConstraint::Parameter{izable,ized}
344
345 The relationship between these two classes is very odd. In particular,
346 this line in Parameterized is insane:
347
348     foreach my $type (Moose::Util::TypeConstraints::get_all_parameterizable_types()) {
349
350 Why does it need to loop through all parameterizable types? Shouldn't
351 it know which parameterizable type it "came from"?
352
353 - Moose::Util::TypeConstraints vs Moose::Meta::Type{Coercion,Constraint}
354
355 The Util module has _way_ too much functionality. It needs to be
356 refactored so it's a thin sugar layer on top of the meta API. As it
357 stands now, it does things like parse type names (and determine if
358 they're valid), manage the registry, and much more.
359
360 - Anything with a _(meta)?class method
361
362 Every method that returns a class name needs to become a rw attribute
363 that can be set via the constructor.
364
365 - The Moose::Error stuff
366
367 This is sort of half-implemented. We still use Carp directly, and the
368 internals can't decide how to throw an error (is it
369 Moose->throw_error, __PACKAGE__->throw_error, what?).
370
371 The internals need to be made consistent before we expose this to the
372 rest of the world.
373
374 -------------------------------------------------------------------------------
375 TO PONDER
376 -------------------------------------------------------------------------------
377
378 - Moose "strict" mode
379
380 use Moose 'strict'; This would allow us to have all sort of expensive tests
381 which can be turned off in prod.
382
383 - Moose::Philosophy.pod
384
385 To explain Moose from a very high level
386
387 - moosedoc
388
389 We certainly have enough meta-information to make pretty complete POD docs.
390
391
392