I found a curious style of debugging that I call "Epicsauce Debugging Level 2."
First you type this:
x = 0;
Then you highlight the
Dynamic[x] and press Ctrl+Shift+Enter. Then you execute the cell and BE AMAZED!!! It's quite hilarious, but I wonder how useful it would be for more serious code.
I've already been using this for some minor things, like to check that a value is actually being modified. The fact that you can place it right by the variable itself is conceptually significant, I think.
Edit: This is actually pretty cool. Here's one practical use. You know when you compose a bunch of stuff, like a graphics expression:
And then your script starts getting a little complicated, and you aren't even sure if the issue is with one of your small components or it's an issue with the final composition? Well you can do this:
Remember that's a live, rotatable object in the comment. One that auto-updates. The nice thing here is that you can debug individual components without breaking out of the flow of your program as a whole.
Edit2: You can highlight the line where the cuboid is being defined and hit Ctrl+Shift+Enter to only evaluate that line and not the whole expression, and see your changes in the comment. It appears that expressions that return
Null (such as those ending with
;) aren't replaced when you Ctrl+Shift+Enter on them. Also remember that Ctrl+. will let you quickly select whole expressions.