Hi, the new debugging tools are just awesome. Thanks to all who have contributed to them!!
Particularly, I am using the debugger in Juno and it works like a charm; I love it.
One nice feature is that you cannot only inspect, but also change the contents of the variables with a lot of freedom (including changing types, etc.)., and see what happens with those changes. Now, I wonder if it would be also possible to add new variables, i.e. binding them to variable names that have not been defined in the code that is being debugged.
I mean: while debugging some code, you can do:
debug> a = 1
But then tyring to access
a results in and
a already existed). Maybe that
a is hidden in some module I don’t know of?
Being able to define new variables while debugging is not crucial, but might be useful in some circumstances. If that makes sense, what is the package where the feature request should be submitted?
Neither Debugger.jl nor Juno support adding new local variables while debugging. You can however add new globals to the module the current function lives in with
julia> @enter gcd(2,3)
In gcd(a, b) at intfuncs.jl:31
>31 a == 0 && return abs(b)
32 b == 0 && return abs(a)
33 za = trailing_zeros(a)
34 zb = trailing_zeros(b)
35 k = min(za, zb)
About to run: (==)(2, 0)
1|julia> global testme = 3
or to some other module with
eval(Main, :(somevariable = 123)).
It is currently not possible to introduce new local variables because before the function is executed we look at the function and make room for all variables that the function will possibly use. In other words, there is currently no space to put the new local variable. It is also not trivial to figure out the whole scope story, e.g. if you are inside a
let block and create the variable should it only exist in that block etc. AFAIK, it is currently not a priority to implement this.