ExprRules.jl icon indicating copy to clipboard operation
ExprRules.jl copied to clipboard

Why extend Core.eval vs. Base.MainInclude.eval?

Open jamgochiana opened this issue 2 years ago • 3 comments

What is the benefit of extending Core.eval instead of Base.MainInclude.eval? I.e. could these lines instead be Base.MainInclude.eval(rulenode::RuleNode, grammar::Grammar) = Core.eval(Main, get_executable(rulenode, grammar))? This might make more sense with the desired usage eval(rulenode, grammar) extending eval(expr) rather than Core.eval(rulenode, grammar) extending Core.eval(m::Module, expr).

jamgochiana avatar May 31 '23 14:05 jamgochiana

I think you are right. Can you elaborate a bit on the benefit of doing it that way?

mykelk avatar May 31 '23 14:05 mykelk

:smile:

julia> Core.eval === Base.MainInclude.eval
true

xref https://github.com/JuliaLang/julia/issues/54532

nsajko avatar May 21 '24 13:05 nsajko

https://github.com/JuliaLang/julia/issues/54057#issuecomment-2051353859 recommends using Core.eval directly.

nsajko avatar May 21 '24 14:05 nsajko