5 ms·
Injecting a REPL into a given section of code is my favorite means of debugging and interactively developing. I've gotten into the habit of building up a class
by Dangeranger 9y ago
Injecting a REPL into a given section of code is my favorite means of debugging and interactively developing. I've gotten into the habit of building up a class interactively within Emacs and re-evaluating files after they have been changed.
It feels a bit like test driven development, but much more concrete. When I don't really know what I want to build, or what is possible, it's a fun way to spike out some functionality.
Then after you see what sort of path could exist from your interactive session you can use the code as a scaffold and re-implement the functionality by writing a test and implementing the code to satisfy it.
- zitterbewegung 9y agoEven just knowing the variables in the Stack frame is useful also. The error pages for Django and pyramid have this. Also, at a previous job someone created a toolbar that had all of the relevant server variables in your session.
- majewsky 9y agoAt a previous job, I built a server-side debugging tool which would record the requests that you made. For each request, you could see the HTTP request, the HTTP response, and events like SQL statements and log messages. (Sort of like Sentry.) There was also a button that re-ran the same request under a profiler. Sadly the tool was never merged into mainline, so the feature branch has probaly rotten away by now.
- vog 9y agoShlightly off-topic: Maybe it's just me, but this is exactly why I'm not a fan of feature branches. I do like to have local branches which sometimes serve as feature branches. But those are short-lived, so these either make it into mainline within a few days, or are deliberately marked as dead ends. (Or developed into a separate project, but this is very seldom and even then quickly moved into a new repository.)
- Ono-Sendai 9y agoA decent debugger will show all the local variables and their values.
- Mic92 9y agoMany variables are marked as optimized in debuggers - never in Inspector. This even happen sometimes to me, when compiler optimizations are disabled.
- weavie 9y agoHow well does it work with class redefinition? Do your instances created with the old definition automatically update to become instances of the new definition, or do you need to recreate them? Common Lisp goes to a lot of trouble to ensure old instances automatically become new instances - given the repl is a first class feature, the whole language is built around this concept. But with C++ I can't quite picture how it would work.
- Mic92 9y agoIt is not supported. You can only define each type once.
- Dangeranger 9y agoThe variables and references need to be re-initialized. It would be absolutely amazing if instances updated themselves but I think only Lisps and Smalltalk are capable of what you are saying. Correct me if I am wrong.