Ability to step through expressions
This is a great tool! I've been toying with a similar technology, generating nested functions with callbacks even before generators, but run into an issue with expressions that do not have a return type.
Does debugjs have an ability to step through complex expressions? E.g. in this example
if(param>2
&& param<5) {
alert(param);
}
From a test on debugjs.com it looks like the entire if() condition is checked in a single step.
right now it's statement based https://github.com/amasad/debugjs/blob/master/lib/transform.js#L147 But I don't think it will take too much effort to make it expression based, however, performance would be the issue. The more 'steps' we add the less performant it is.
It should probably be configurable or even better - have an ability to dynamically drill down into a specific statement if it was stopped on via a breakpoint or debugger step. I.e. normally for performance reasons it would operate on per-statement level, but if somebody stops on a given statement, then you switch to expression-based mode and allow to step into the statement.
I guess it's not that easy to do since the instrumented code is prepared before the debugger starts and it may be hard to regenerate more detailed version for a specific statement and inject it on the fly? Would be cool though
yeah it'd be great to have both. Maybe it's possible. Feel free to hack on it.
On Fri, May 2, 2014 at 3:15 PM, apalskoi [email protected] wrote:
It should probably be configurable or even better - have an ability to dynamically drill down into a specific statement if it was stopped on via a breakpoint or debugger step. I.e. normally for performance reasons it would operate on per-statement level, but if somebody stops on a given statement, then you switch to expression-based mode and allow to step into the statement.
I guess it's not that easy to do since the instrumented code is prepared before the debugger starts and it may be hard to regenerate more detailed version for a specific statement and inject it on the fly? Would be cool though
— Reply to this email directly or view it on GitHubhttps://github.com/amasad/debugjs/issues/7#issuecomment-42067577 .
Thanks! I'll try researching it further once I get a chance. For now I am using a little home-grown debugger library in my project but your tool is much more powerful. Thanks again for creating it!
you got it. Do you have a link to your library?
It's a part of a larger project that is work in progress. I only have a link to the future users guide - https://github.com/GraspIO/docs-users-guide/blob/master/Editor/Panels.md#test-panel. It describes debugger for a model-driven code generator, but if the target code is Javascript, you can run/debug the code itself and it will highlight corresponding parts of the original model.
Looks cool! And you were thinking of using debugjs for this project?
Yes, I would love to use it and also explore the ideas from Learnable Programming but take it from the coding-land to something that is easier for regular people to understand - forms, diagrams, etc.
Here is a simple example of a graphical formula editor with code generation/execution - http://www.grasp.io/workbench?repositoryID=publicExamples&anonymous=true#!/exampleFormula (open the "testing tab" and try running it twice - first run generates the code and second run steps through it, maintaining the link to the original model)