1Eval::TypeTiny(3)     User Contributed Perl Documentation    Eval::TypeTiny(3)
2
3
4

NAME

6       Eval::TypeTiny - utility to evaluate a string of Perl code in a clean
7       environment
8

STATUS

10       This module is considered part of Type-Tiny's internals. It is not
11       covered by the Type-Tiny stability policy.
12

DESCRIPTION

14       This module is used by Type::Tiny to compile coderefs from strings of
15       Perl code, and hashrefs of variables to close over.
16
17   Functions
18       This module exports one function, which works much like the similarly
19       named function from Eval::Closure:
20
21       "eval_closure(source => $source, environment => \%env, %opt)"
22
23   Constants
24       The following constants may be exported, but are not by default.
25
26       "HAS_LEXICAL_SUBS"
27           Boolean indicating whether Eval::TypeTiny has support for lexical
28           subs.  (This feature requires Perl 5.18.)
29
30       "ALIAS_IMPLEMENTATION"
31           Returns a string indicating what implementation of "alias => 1" is
32           being used. Eval::TypeTiny will automatically choose the best
33           implementation.  This constant can be matched against the
34           "IMPLEMENTAION_*" constants.
35
36       "IMPLEMENTATION_NATIVE"
37           If "ALIAS_IMPLEMENTATION eq IMPLEMENTATION_NATIVE" then
38           Eval::TypeTiny is currently using Perl 5.22's native alias feature.
39           This requires Perl 5.22.
40
41       "IMPLEMENTATION_DEVEL_LEXALIAS"
42           If "ALIAS_IMPLEMENTATION eq IMPLEMENTATION_DEVEL_LEXALIAS" then
43           Eval::TypeTiny is currently using Devel::LexAlias to provide
44           aliases.
45
46       "IMPLEMENTATION_PADWALKER"
47           If "ALIAS_IMPLEMENTATION eq IMPLEMENTATION_PADWALKER" then
48           Eval::TypeTiny is currently using PadWalker to provide aliases.
49
50       "IMPLEMENTATION_TIE"
51           If "ALIAS_IMPLEMENTATION eq IMPLEMENTATION_TIE" then Eval::TypeTiny
52           is using the fallback implementation of aliases using "tie". This
53           is the slowest implementation, and may cause problems in certain
54           edge cases, like trying to alias already-tied variables, but it's
55           the only way to implement "alias => 1" without a recent version of
56           Perl or one of the two optional modules mentioned above.
57

EVALUATION ENVIRONMENT

59       The evaluation is performed in the presence of strict, but the absence
60       of warnings. (This is different to Eval::Closure which enables warnings
61       for compiled closures.)
62
63       The feature pragma is not active in the evaluation environment, so the
64       following will not work:
65
66          use feature qw(say);
67          use Eval::TypeTiny qw(eval_closure);
68
69          my $say_all = eval_closure(
70             source => 'sub { say for @_ }',
71          );
72          $say_all->("Hello", "World");
73
74       The feature pragma does not "carry over" into the stringy eval. It is
75       of course possible to import pragmas into the evaluated string as part
76       of the string itself:
77
78          use Eval::TypeTiny qw(eval_closure);
79
80          my $say_all = eval_closure(
81             source => 'sub { use feature qw(say); say for @_ }',
82          );
83          $say_all->("Hello", "World");
84

BUGS

86       Please report any bugs to
87       <http://rt.cpan.org/Dist/Display.html?Queue=Type-Tiny>.
88

SEE ALSO

90       Eval::Closure, Error::TypeTiny::Compilation.
91

AUTHOR

93       Toby Inkster <tobyink@cpan.org>.
94
96       This software is copyright (c) 2013-2014, 2017-2019 by Toby Inkster.
97
98       This is free software; you can redistribute it and/or modify it under
99       the same terms as the Perl 5 programming language system itself.
100

DISCLAIMER OF WARRANTIES

102       THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
103       WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
104       MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
105
106
107
108perl v5.28.1                      2019-01-08                 Eval::TypeTiny(3)
Impressum