{
    "mode": "perldoc",
    "parameter": "Eval::TypeTiny",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Eval%3A%3ATypeTiny/json",
    "generated": "2026-09-17T13:09:16Z",
    "sections": {
        "NAME": {
            "content": "Eval::TypeTiny - utility to evaluate a string of Perl code in a clean environment\n",
            "subsections": []
        },
        "STATUS": {
            "content": "This module is covered by the Type-Tiny stability policy.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module is used by Type::Tiny to compile coderefs from strings of Perl code, and hashrefs of\nvariables to close over.\n",
            "subsections": [
                {
                    "name": "Functions",
                    "content": "By default this module exports one function, which works much like the similarly named function\nfrom Eval::Closure:\n\n\"evalclosure(source => $source, environment => \\%env, %opt)\"\n\nOther functions can be imported on request:\n\n\"setsubname( $fullyqualifiedname, $coderef )\"\nWorks like the similarly named function from Sub::Util, but will fallback to doing nothing\nif neither Sub::Util nor Sub::Name are available. Also will cowardly refuse the set the name\nof a coderef a second time if it's already named it.\n\n\"typetocoderef( $type, %options )\"\nTurns a Type::Tiny object into a coderef, suitable for installing into a symbol table to\ncreate a function like \"ArrayRef\" or \"Int\". (Actually should work for any object which\nprovides \"isparameterizable\", \"parameterize\", and \"qualifiedname\" methods, such as\nType::Coercion.)\n\n$options{postmethod} can be a string of Perl indicating a method to call on the type\nconstraint before returning it. For example '->moosetype'.\n\n$options{description} can be a description of the coderef which may be shown in stack\ntraces, etc.\n\nThe coderef will be named using \"setsubname\" unless $options{anonymous} is true.\n\nIf $type is undef, then it is assumed that the type constraint hasn't been defined yet but\nwill later, yet you still want a function now. $options{typelibrary} and\n$options{typename} will be used to find the type constraint when the function gets called.\n"
                },
                {
                    "name": "Constants",
                    "content": "The following constants may be exported, but are not by default.\n\n\"HASLEXICALSUBS\"\nBoolean indicating whether Eval::TypeTiny has support for lexical subs. (This feature\nrequires Perl 5.18.)\n\n\"ALIASIMPLEMENTATION\"\nReturns a string indicating what implementation of \"alias => 1\" is being used.\nEval::TypeTiny will automatically choose the best implementation. This constant can be\nmatched against the \"IMPLEMENTAION*\" constants.\n\n\"IMPLEMENTATIONNATIVE\"\nIf \"ALIASIMPLEMENTATION eq IMPLEMENTATIONNATIVE\" then Eval::TypeTiny is currently using\nPerl 5.22's native alias feature. This requires Perl 5.22.\n\n\"IMPLEMENTATIONDEVELLEXALIAS\"\nIf \"ALIASIMPLEMENTATION eq IMPLEMENTATIONDEVELLEXALIAS\" then Eval::TypeTiny is currently\nusing Devel::LexAlias to provide aliases.\n\n\"IMPLEMENTATIONPADWALKER\"\nIf \"ALIASIMPLEMENTATION eq IMPLEMENTATIONPADWALKER\" then Eval::TypeTiny is currently using\nPadWalker to provide aliases.\n\n\"IMPLEMENTATIONTIE\"\nIf \"ALIASIMPLEMENTATION eq IMPLEMENTATIONTIE\" then Eval::TypeTiny is using the fallback\nimplementation of aliases using \"tie\". This is the slowest implementation, and may cause\nproblems in certain edge cases, like trying to alias already-tied variables, but it's the\nonly way to implement \"alias => 1\" without a recent version of Perl or one of the two\noptional modules mentioned above.\n\n\"NICEPROTOTYPES\"\nIf this is true, then typetocoderef will give parameterizable type constraints the\nslightly nicer prototype of \"(;$)\" instead of the default \"(;@)\". This allows constructs\nlike:\n\nArrayRef[Int] | HashRef[Int]\n\n... to \"just work\".\n"
                }
            ]
        },
        "EVALUATION ENVIRONMENT": {
            "content": "The evaluation is performed in the presence of strict, but the absence of warnings. (This is\ndifferent to Eval::Closure which enables warnings for compiled closures.)\n\nThe feature pragma is not active in the evaluation environment, so the following will not work:\n\nuse feature qw(say);\nuse Eval::TypeTiny qw(evalclosure);\n\nmy $sayall = evalclosure(\nsource => 'sub { say for @ }',\n);\n$sayall->(\"Hello\", \"World\");\n\nThe feature pragma does not \"carry over\" into the stringy eval. It is of course possible to\nimport pragmas into the evaluated string as part of the string itself:\n\nuse Eval::TypeTiny qw(evalclosure);\n\nmy $sayall = evalclosure(\nsource => 'sub { use feature qw(say); say for @ }',\n);\n$sayall->(\"Hello\", \"World\");\n",
            "subsections": []
        },
        "BUGS": {
            "content": "Please report any bugs to <https://github.com/tobyink/p5-type-tiny/issues>.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Eval::Closure, Error::TypeTiny::Compilation.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Toby Inkster <tobyink@cpan.org>.\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENCE": {
            "content": "This software is copyright (c) 2013-2014, 2017-2023 by Toby Inkster.\n\nThis is free software; you can redistribute it and/or modify it under the same terms as the Perl\n5 programming language system itself.\n",
            "subsections": []
        },
        "DISCLAIMER OF WARRANTIES": {
            "content": "THIS PACKAGE IS PROVIDED \"AS IS\" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\nWITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.\n",
            "subsections": []
        }
    },
    "summary": "Eval::TypeTiny - utility to evaluate a string of Perl code in a clean environment",
    "flags": [],
    "examples": [],
    "see_also": []
}