Thanks for the comments. Unfortunately, it doesn’t work. Here is the error:
1|julia > println($op)
ERROR: UndefVarError: op not defined
in _step_expr(::ASTInterpreter.Interpreter) at /home/chobbes/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:653
in step_expr at /home/chobbes/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:666 [inlined]
in #finish!#81(::Bool, ::Bool, ::Function, ::ASTInterpreter.Interpreter) at /home/chobbes/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1720
in eval_in_interp(::ASTInterpreter.Interpreter, ::Expr, ::JuliaParser.Tokens.SourceExpr, ::String) at /home/chobbes/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1298
in eval_code(::ASTInterpreter.InterpreterState, ::String) at /home/chobbes/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1529
in (::ASTInterpreter.##72#78{ASTInterpreter.InterpreterState,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at /home/chobbes/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1654
in run_interface(::Base.Terminals.TTYTerminal, ::Base.LineEdit.ModalInterface) at ./LineEdit.jl:1579
in RunDebugREPL(::ASTInterpreter.Interpreter) at /home/chobbes/.julia/v0.5/ASTInterpreter/src/ASTInterpreter.jl:1693
Apparently, interpolation doesn’t work this way in debugger.
I think if `println($op) works, `$op should have worked too.
Metaprogramming happens at parse time, so ASTInterpreter doesn’t have access to it. The easiest way to do that is to put the macro body in a separate function and manually call that on the expression you want to debug.
Thanks for the explanation. Indeed, ASTInterpreter can’t see anything happened in the phase of metaprogramming. No doubt at all. But it’s kind of counter-intuitive since one expects to be able to see the value of every single variable using a debugger, especially when what you’re doing is not debugging your own code but trying to use debugger to step through some other’s code (sometimes it’s a massive package). But my thought may be not very reasonable.
Here is another thing I come across frequently - when I use back-tick to show the value of some variables, I got the correct value, but wrapped by Core.Box(). For example, I expect `a return me the value of a. But what is returned is something like Core.Box(a). Is this something normal?
I know you’re busy with 0.6. So don’t bother to answer me if you’re hectic. Thanks.