# man > Eval::TypeTiny(3pm)

## NAME
    [Eval::TypeTiny](https://www.chedong.com/phpMan.php/perldoc/Eval%3A%3ATypeTiny/markdown) - utility to evaluate a string of Perl code in a clean environment

## STATUS
    This module is covered by the Type-Tiny stability policy.

## DESCRIPTION
    This module is used by [Type::Tiny](https://www.chedong.com/phpMan.php/perldoc/Type%3A%3ATiny/markdown) to compile coderefs from strings of Perl code, and hashrefs of
    variables to close over.

### Functions
    This module exports one function, which works much like the similarly named function from
    [Eval::Closure](https://www.chedong.com/phpMan.php/perldoc/Eval%3A%3AClosure/markdown):

    "eval_closure(source => $source, environment => \%env, %opt)"

### Constants
    The following constants may be exported, but are not by default.

    "HAS_LEXICAL_SUBS"
        Boolean indicating whether [Eval::TypeTiny](https://www.chedong.com/phpMan.php/perldoc/Eval%3A%3ATypeTiny/markdown) has support for lexical subs. (This feature
        requires Perl 5.18.)

    "ALIAS_IMPLEMENTATION"
        Returns a string indicating what implementation of "alias => 1" is being used.
        [Eval::TypeTiny](https://www.chedong.com/phpMan.php/perldoc/Eval%3A%3ATypeTiny/markdown) will automatically choose the best implementation. This constant can be
        matched against the "IMPLEMENTAION_*" constants.

    "IMPLEMENTATION_NATIVE"
        If "ALIAS_IMPLEMENTATION eq IMPLEMENTATION_NATIVE" then [Eval::TypeTiny](https://www.chedong.com/phpMan.php/perldoc/Eval%3A%3ATypeTiny/markdown) is currently using
        Perl 5.22's native alias feature. This requires Perl 5.22.

    "IMPLEMENTATION_DEVEL_LEXALIAS"
        If "ALIAS_IMPLEMENTATION eq IMPLEMENTATION_DEVEL_LEXALIAS" then [Eval::TypeTiny](https://www.chedong.com/phpMan.php/perldoc/Eval%3A%3ATypeTiny/markdown) is currently
        using [Devel::LexAlias](https://www.chedong.com/phpMan.php/perldoc/Devel%3A%3ALexAlias/markdown) to provide aliases.

    "IMPLEMENTATION_PADWALKER"
        If "ALIAS_IMPLEMENTATION eq IMPLEMENTATION_PADWALKER" then [Eval::TypeTiny](https://www.chedong.com/phpMan.php/perldoc/Eval%3A%3ATypeTiny/markdown) is currently using
        PadWalker to provide aliases.

    "IMPLEMENTATION_TIE"
        If "ALIAS_IMPLEMENTATION eq IMPLEMENTATION_TIE" then [Eval::TypeTiny](https://www.chedong.com/phpMan.php/perldoc/Eval%3A%3ATypeTiny/markdown) is using the fallback
        implementation of aliases using "tie". This is the slowest implementation, and may cause
        problems in certain edge cases, like trying to alias already-tied variables, but it's the
        only way to implement "alias => 1" without a recent version of Perl or one of the two
        optional modules mentioned above.

## EVALUATION ENVIRONMENT
    The evaluation is performed in the presence of strict, but the absence of warnings. (This is
    different to [Eval::Closure](https://www.chedong.com/phpMan.php/perldoc/Eval%3A%3AClosure/markdown) which enables warnings for compiled closures.)

    The feature pragma is not active in the evaluation environment, so the following will not work:

       use feature qw(say);
       use [Eval::TypeTiny](https://www.chedong.com/phpMan.php/perldoc/Eval%3A%3ATypeTiny/markdown) qw(eval_closure);

       my $say_all = eval_closure(
          source => 'sub { say for @_ }',
       );
       $say_all->("Hello", "World");

    The feature pragma does not "carry over" into the stringy eval. It is of course possible to
    import pragmas into the evaluated string as part of the string itself:

       use [Eval::TypeTiny](https://www.chedong.com/phpMan.php/perldoc/Eval%3A%3ATypeTiny/markdown) qw(eval_closure);

       my $say_all = eval_closure(
          source => 'sub { use feature qw(say); say for @_ }',
       );
       $say_all->("Hello", "World");

## BUGS
    Please report any bugs to <<https://github.com/tobyink/p5-type-tiny/issues>>.

## SEE ALSO
    [Eval::Closure](https://www.chedong.com/phpMan.php/perldoc/Eval%3A%3AClosure/markdown), [Error::TypeTiny::Compilation](https://www.chedong.com/phpMan.php/perldoc/Error%3A%3ATypeTiny%3A%3ACompilation/markdown).

## AUTHOR
    Toby Inkster <<tobyink@cpan.org>>.

## COPYRIGHT AND LICENCE
    This software is copyright (c) 2013-2014, 2017-2021 by Toby Inkster.

    This is free software; you can redistribute it and/or modify it under the same terms as the Perl
    5 programming language system itself.

## DISCLAIMER OF WARRANTIES
    THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
    WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
    PURPOSE.

