Closed ghost closed 9 years ago
There are some problems with this pr, in ascending order of severity (ie here goes "critique"):
Debugger
has the same problem so both should be fixedfail
)
is generally not a good idea. The more (not) so for a Tracer
or Debugger
- at least if it aims to deserve the name... (with this pr it looks like a simple failure to parse and does NOT give an indication of the exception)Tracer
it happens to be the only one) of a more general problem - which is not at all fixed by this prThe real problem is:
Both Tracer
and Debugger
have state like current call-depth (~> indent), declared / manual breakpoints, auto-continue/single-step etc.
This, in itself is fine and need be. However, the question is with what to associate this state?.
Currently it's associated with the meta-class, which means that there's only one state, for each and every grammar, and instance thereof, plus - even worse - one state only for the whole program's live-time!
This has several implications:
So(lutions):
parse
, subparse
or parsefile
is called:
False
/True
, resp.False
bp add <name>
should be all deletedis breakpoint
or will break {...}
) should be reset to what's been declaredTracer
's functionality is a subset of Debugger
's" (ref first pt in critique): in order to handle this properly there's quite some refactoring needed. In the end there should be an "EventEmitter" (Observer pattern), or layers of such, to which Tracer
and Debugger
are just different subscribers that react differently to events. For the time being there'll be just enough to avoid dead-stupid copy&paste but not the full-blown Observer pattern.I'll soon provide a pull-request implementing pr #7 implements pt 2 and - hence safely - pt 3, by just enough of pt 4. Plus a bit of preparation for pt 1.
Once that's ready I think I'll move much of Maybe I should move this rationale over there or maybe into a new issue?
(of course leaving a link here)
Any input/comment/advice/critique is very much welcomed, as always :)
Grammar::Tracer gets kinda confused if a traced
.parse
throws an exception followed by another trace in the same process.This fix doesn't appear to have any unwanted side effects, though I haven't tried it with anything crazy.