4 ms·
What happens if there is a data structure and I make some changes to it that break different parts of the program? Does it warn about them, or do I need to plac
by ffhhj 4y ago
What happens if there is a data structure and I make some changes to it that break different parts of the program? Does it warn about them, or do I need to place some tests? Also, is it possible to revert the program state back and forth to try some idea?
- mikelevins 4y agoLisp will tell you if it can, by dropping you in a breakloop. A breakloop is a repl that includes all of the normal Lisp repl features plus the full stack and dynamic environment of the broken code (which you can inspect and edit), plus a set of restarts you can select to resume execution, abandon the broken function, or transfer control in some other way defined by the context of the breakloop (which you can customize to your heart's content). Smalltalk has equivalent features. Lisp won't catch every possible error you could possibly make, of course, so testing is good defensive programming. On the other hand, when I'm working in Lisp, testing happens almost by default. It's the majority of what I do: I write experiments in files and hit a key to send them to the repl to test what happens. Tests generally start as little experiments like this. Some of them are useful over and over. Those graduate from informal experiments to formal tests.
- dunefox 4y agoThis might be interesting for you: https://malisper.me/category/debugging-common-lisp/ https://malisper.me/category/debugging-common-lisp/
- lokedhs 4y agoThis depends on on the language of course. In Common Lisp, a generics function called REINITIALIZE-INSTANCE is called. It's possibly to implement a method for this that updates the instance based on the new definition. By default, any slots that have been added will be unbound. Attempting to access them will raise an error which will drop you in the debugger. From there you can then fix the instance and continue running.