- Those restrictions apply even if you use the 'as' option to redirect to
- another package, and are unlikely to find a workaround as this happens
- deep inside the lexer - far from the reach of an extension.
+ sub import {
+ my $pkg = caller;
+ for (qw<Str Int>) {
+ my $type = __PACKAGE__ . '::' . $_;
+ no strict 'refs';
+ no warnings 'redefine';
+ *{$pkg.'::'.$_} = eval "sub () { '$type' }";
+ }
+ Lexical::Types->import(
+ as => sub { $_[0] => 'new' }
+ );
+ }
+
+ sub unimport {
+ Lexical::Types->unimport;
+ }
+
+ package MyTypes::Str;
+
+ sub new { ... }
+
+ package MyTypes::Int;
+
+ sub new { ... }
+
+CONSTANTS
+ "LT_THREADSAFE"
+ True iff the module could have been built with thread-safety features
+ enabled.
+
+ "LT_FORKSAFE"
+ True iff this module could have been built with fork-safety features
+ enabled. This will always be true except on Windows where it's false for
+ perl 5.10.0 and below .
+
+CAVEATS
+ The restrictions on the type (being either a defined package name or a
+ constant) apply even if you use the 'as' option to redirect to another
+ package, and are unlikely to find a workaround as this happens deep
+ inside the lexer - far from the reach of an extension.