# \#eval\_string

**URL:** https://forum.elixirforum.com/tag/eval-string/3498.md

[Latest](https://forum.elixirforum.com/latest.md) · [Categories](https://forum.elixirforum.com/categories.md) · [Tags](https://forum.elixirforum.com/tags.md)

---

## [How to keep the Code.eval\_string environment on async execution](https://forum.elixirforum.com/t/how-to-keep-the-code-eval-string-environment-on-async-execution/71285)

<div class="topic-metadata">

**Author:** [@samuelventura](https://forum.elixirforum.com/u/samuelventura)\
**Replies:** 6\
**Last updated:** [June 15, 2025, 2:18am UTC](https://forum.elixirforum.com/t/how-to-keep-the-code-eval-string-environment-on-async-execution/71285 "2025-06-15T02:18:58Z")

</div>

What is the proper way to evaluate a string and get a stack trace that honors the provided file: script.exs environment across all the code defined in that script regardless of whether it is executed in the current proce…

---

## [ChatGPT generated code for eval\_string alternative](https://forum.elixirforum.com/t/chatgpt-generated-code-for-eval-string-alternative/52544)

<div class="topic-metadata">

**Author:** [@yolo007wizard](https://forum.elixirforum.com/u/yolo007wizard)\
**Replies:** 5\
**Last updated:** [December 15, 2022, 3:50am UTC](https://forum.elixirforum.com/t/chatgpt-generated-code-for-eval-string-alternative/52544 "2022-12-15T03:50:02Z")

</div>

Was talking with ChatGPT, is the following code a valid/good replacement for Code.eval\_string? def create\_function(name, args, code) do ast = Macro.escape(code, \[:strict\]) code = Macro.to\_string(ast) {name, Code.s…
