Stream: helpdesk (published)

Topic: Spoof apparent module when evaling expression


view this post on Zulip Fredrik Ekre (Jul 05 2021 at 08:35):

Is there a way to change the apparent module when evaling an expression? For Documenter we evaluate into anonymous modules, and then manually clean up stacktraces etc to make it look like it was evaluated in Main rather than Main.anon_mod. I want e.g.

anon_mod = Module(:anon_mod)
Core.eval(anon_mod, Meta.parse("print(@__MODULE__)"))

to print Main instead of Main.anon_mod.


Last updated: Oct 02 2023 at 04:34 UTC