From: Vincent Pit Date: Sat, 7 Mar 2009 12:19:51 +0000 (+0100) Subject: Talk about $_[0] in 'as' callbacks for constant types X-Git-Tag: v0.04~4 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FLexical-Types.git;a=commitdiff_plain;h=7a753d187ec273e873d5d8a8afb9e48fed7d1955 Talk about $_[0] in 'as' callbacks for constant types --- diff --git a/lib/Lexical/Types.pm b/lib/Lexical/Types.pm index c5c416b..c5bca1e 100644 --- a/lib/Lexical/Types.pm +++ b/lib/Lexical/Types.pm @@ -125,6 +125,14 @@ or the desired package and method name, in that order (if any of those is C will be set to the I of constant and not to its name. + + use Lexical::Types as => sub { $_[0] => 'new' }; + use constant Str => 'MyStr'; + my Str $x; # calls MyStr->new + +This means in particular that you can't both use constant types and redirect several types to different methods of the same package, because then you can't distinguish between the original types with C<$_[0]>. + =back =cut