Commit | Line | Data |
d67145ed |
1 | ----------------------------------------------------------- |
2 | -- Type Constraints refactor |
3 | ----------------------------------------------------------- |
4 | |
5 | - move the details of TC construction that are in Moose.pm and |
6 | Moose::Util::TypeConstraints into the Moose::Meta::TypeConstraint module |
7 | |
8 | This will make it much easier to generate TCs on their own, without |
9 | having to use the sugar layer. This should also clean up their APIs |
10 | as well, which will make it easier to subclass them. |
11 | |
12 | - create an official TC registry API |
13 | |
14 | Right now the registration of the TC is a by-product of creation in the sugar |
15 | layer, this is bad and make extension of TCs difficult. I am not sure if this |
16 | registry API should exist as part of Moose::Util::TypeConstraints, or of we |
17 | should create a complete registry object itself. |
18 | |
19 | This registry should be a singleton, but M::U::TC should enforce that lifecycle |
20 | choice so that you can use your own registry if you really want too. |
21 | |
22 | I mean parent of the registry. So that I can create my own registry |
23 | object for a given class, and any retrieval of a type constraint from |
24 | this object would automatically search parent registries as well. |
25 | |
26 | - refactor the various TC internals to make it more subclassing friendly |
27 | |
28 | This also includes the coercion stuff as well. This should give you what you |
29 | need to make your object/class bound stuff. |
30 | |
31 | - move the container TCs from MooseX::AttributeHelpers into Moose core |
32 | |
33 | These have proven so useful for me in the latest $work project that I think |
34 | they should really be core. |
35 | |
36 | - allow a switch of some kind to optionally turn TC checking off at runtime |
37 | |
38 | The type checks can get expensive and some people have suggested that allowing |
39 | the checks to be turned off would be helpful for deploying into performance |
40 | intensive systems. Perhaps this can actually be done as an option to make_immutable? |
41 | |
22aed3c0 |
42 | - add support for locally scoped TC |
43 | |
44 | This would borrow from MooseX::TypeLibrary to prefix the TC with the name |
45 | of the package. It would then be accesible from the outside as the fully |
46 | scoped name, but the local attributes would use it first. (this would need support |
47 | in the registry for this). |
48 | |
49 | - look into sugar extensions |
50 | |
51 | Use roles as sugar layer function providers (ala MooseX::AttributeHelpers). This |
52 | would allow custom metaclasses to provide roles to extend the sugar syntax with. |
53 | |
54 | (NOTE: Talk to phaylon a bit more on this) |
55 | |
d67145ed |
56 | - misc. minor bits |
57 | |
58 | * make the errors for TCs use ->message |
59 | * look into localizing the messages too |
60 | * make ANON TCs be lazy, so they can possibly be subsituted for the real thing later |
61 | * make ANON TCs more introspectable |
22aed3c0 |
62 | * add this ... |
63 | |
64 | # |
65 | # Type Definition |
66 | # |
67 | subtype 'Username', |
68 | from 'Str', |
69 | where { (/[a-z][a-z0-9]+/i or fail('Invalid character(s)')) |
70 | and (length($_) >= 5 or fail('Too short (less than 5 chars)')) |
71 | } |
72 | on_fail { MyException->throw(value => $_[0], message => $_[1]) }; |
73 | |
74 | # fail() will just return false unless the call is made via |
75 | $tc->check_or_fail($value); |
76 | |
77 | * and then something like this: |
78 | |
79 | subtype Foo => as Bar => where { ... } => scoped => -global; |
80 | subtype Foo => as Bar => where { ... } => scoped => -local; |
81 | |
82 | # or |
83 | |
84 | subtype Foo => as Bar => where { ... } => in __PACKAGE__ ; |
85 | |
86 | # or (not sure if it would be possible) |
87 | |
88 | my $Foo = subtype Bar => where { ... }; |
d67145ed |
89 | |
90 | |
91 | ----------------------------------------------------------- |
92 | -- Roles refactor |
93 | ----------------------------------------------------------- |
94 | |
95 | |
96 | ----------------------------------------------------------- |
97 | -- Immutable refactor |
98 | ----------------------------------------------------------- |