=head1 SYNOPSIS
+ { package Str; }
+
+ {
+ package My::Types::Str;
+
+ sub new { bless { }, shift }
+ }
+
+ use Lexical::Types as => sub { 'My::Types::' . $_[0] => 'new' };
+
+ my Str $x; # $x is now a My::Types::Str object
+
{
- package Str;
+ package My::Types::Int;
- sub TYPEDSCALAR { Some::String::Implementation->new }
+ sub TYPEDSCALAR { bless { }, shift }
}
use Lexical::Types;
- my Str $x; # $x is now a Some::String::Implementation object
+ use constant Int => 'My::Types::Int';
+
+ my Int $y; # $y is now a My::Types::Int object
=head1 DESCRIPTION
use strict;
use warnings;
+use blib;
+
+{ package Str; }
+
+{
+ package My::Types::Str;
+
+ sub new { bless { }, shift }
+}
+
+use Lexical::Types as => sub { 'My::Types::' . $_[0] => 'new' };
+
+my Str $x; # $x is now a My::Types::Str object
+print ref($x), "\n"; # My::Types::Str;
+
{
- package Str;
+ package My::Types::Int;
- sub TYPEDSCALAR { $_[1] = ' ' x 10 }
+ sub TYPEDSCALAR { bless { }, shift }
}
use Lexical::Types;
-my Str $x;
+use constant Int => 'My::Types::Int';
-print length($x), "\n"; # 10
+my Int $y; # $y is now a My::Types::Int object
+print ref($y), "\n"; # My::Types::Int;