masak / bel

An interpreter for Bel, Paul Graham's Lisp language
GNU General Public License v3.0
27 stars 1 forks source link

Three quality goals #425

Open masak opened 2 years ago

masak commented 2 years ago

I try to avoid filing roadmap or meta issues, because they tend to grow uncontrollably, and their lack of clear observable makes them hard to close. Making an exception here, because I think that talking about these three things together reveals a bigger picture, and that they are fairly well-defined already (if not entirely straightforward to achieve).

Errors

Tracked since forever in #18. What I want as a user is not just the error symbol, but the location where the error happened, plus as much of "symptom, diagnosis, treatment plan" as the system can figure out.

I can see three very short-term things that need to be implemented:

(Edit: Also, stacktraces, I guess? This is a bit challenging in a tail-calilng interpreter, but it's doable. There's a nice blog post somewhere about a circular-list-of-circular-lists kind of data structure which can keep enough stacktrace information around.)

All of that is fairly straightforward and not that hard; need to Just Do It.

There's an added level of complexity later when the compiler and the bytecode interpreter gets involved. From what I can see, any time we do an optimizing transform, we need to take special care to preserve (file, line, column) information back to the original source. Certainly possible, but it feels like the kind of thing that needs to be carefully designed up-front, not added as a distracted afterthought.

Debugging

Tracked for a pretty long time in #52. Thinking about what I want here. It comes down to three things:

Modules

Tracked in #391. The current state is a bit untenable/ridiculous, with me copy+pasting definitions of prlf and the unit testing mechanism into various other files, with the attendant denormalization pitfalls. I also wish more and more often that I had easier access to the things defined in bel-masak-prelude.

I suggest a more radical plan than in #391, just to quickly get off the path of copy+pasting:

As a final note, I'd like for import to work in the REPL as well. Basically we should define it as a dynamic construct, with all the static benefits being added on top of that when possible.

I'm wondering if we can make the following work. When you import some file in the REPL, you also set up a file change listener to that source file. If the file is saved (presumably in a nearby editor), then the REPL environment automatically re-imports the contents, adding/changing and removing imported definitions as necessary. This would require keeping a bit of extra state to track where definitions came from, but that's no big deal. I feel this might address the "reload" problem mentioned in #391.