more type system hacking and tests
[gitmo/Moose.git] / PLANS
CommitLineData
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
8This will make it much easier to generate TCs on their own, without
9having to use the sugar layer. This should also clean up their APIs
10as well, which will make it easier to subclass them.
11
12- create an official TC registry API
13
14Right now the registration of the TC is a by-product of creation in the sugar
15layer, this is bad and make extension of TCs difficult. I am not sure if this
16registry API should exist as part of Moose::Util::TypeConstraints, or of we
17should create a complete registry object itself.
18
19This registry should be a singleton, but M::U::TC should enforce that lifecycle
20choice so that you can use your own registry if you really want too.
21
22I mean parent of the registry. So that I can create my own registry
23object for a given class, and any retrieval of a type constraint from
24this object would automatically search parent registries as well.
25
26- refactor the various TC internals to make it more subclassing friendly
27
28This also includes the coercion stuff as well. This should give you what you
29need to make your object/class bound stuff.
30
31- move the container TCs from MooseX::AttributeHelpers into Moose core
32
33These have proven so useful for me in the latest $work project that I think
34they should really be core.
35
36- allow a switch of some kind to optionally turn TC checking off at runtime
37
38The type checks can get expensive and some people have suggested that allowing
39the checks to be turned off would be helpful for deploying into performance
40intensive systems. Perhaps this can actually be done as an option to make_immutable?
41
22aed3c0 42- add support for locally scoped TC
43
44This would borrow from MooseX::TypeLibrary to prefix the TC with the name
45of the package. It would then be accesible from the outside as the fully
46scoped name, but the local attributes would use it first. (this would need support
47in the registry for this).
48
49- look into sugar extensions
50
51Use roles as sugar layer function providers (ala MooseX::AttributeHelpers). This
52would 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#
67subtype '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 }
72on_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
79subtype Foo => as Bar => where { ... } => scoped => -global;
80subtype Foo => as Bar => where { ... } => scoped => -local;
81
82# or
83
84subtype Foo => as Bar => where { ... } => in __PACKAGE__ ;
85
86# or (not sure if it would be possible)
87
88my $Foo = subtype Bar => where { ... };
d67145ed 89
90
91-----------------------------------------------------------
92-- Roles refactor
93-----------------------------------------------------------
94
95
96-----------------------------------------------------------
97-- Immutable refactor
98-----------------------------------------------------------