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 covered by the Type-Tiny stability policy.
11

DESCRIPTION

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

EVALUATION ENVIRONMENT

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

BUGS

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

SEE ALSO

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

AUTHOR

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

DISCLAIMER OF WARRANTIES

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