lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

2013/9/23 Ignacio Burgueño <>:
> I'd like to announce StackTracePlus.

Timing is interesting, I worked on something similar in the last few weeks.

I usually can interpret Lua traces without knowing the locals value,
since I can re-compute their value mentally by following the code
path. There is one exception though, it's when a loop is involved,
since the default traces don't tell at what iteration the error
happened. So my version of the improved debug.traceback adds just
that, iterator values in "for" loops (because "while" and "repeat"
loops are too generic).

I started with a pure Lua implementation there:

Then I back-ported the feature in the Lua sources so that I don't have
to require my module in every place I want improved traces:

It's much more simple (or streamlined depending on the point of view)
than your implementation, but it might be of interest to some. It
introduces lines of the form:

    in iteration i=1
    in iteration k="a"

in the traces. Note that while it shows the user variable name (i, k),
the value is that of the internal "for" control/index variable (so if
you re-assign to the variable inside the loop, you still see the value
at the beginning of the iteration).