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