bobbicodes / bobbi-lisp

Interactive Lisp environment for learning Clojure
https://bobbicodes.github.io/bobbi-lisp/
0 stars 0 forks source link

Implement crude pretty-printing #27

Closed bobbicodes closed 11 months ago

bobbicodes commented 11 months ago

Uses the printer from the MAL project. Started porting things from clojure.pprint to learn how to make it better.

This led me to implement a print buffer, which is prepended to the eval output, so now we can do stuff like this:

(+ (do (pr "hello" "kitty") (+ 1 1)) 1)
=> 
hello kitty3 

The print buffer is used by pr, prn, print and println, so their arguments are rendered along with the evaluation output without affecting the return value.

The biggest drawback of this pretty printer is that it always prints 1 item per line for seqs, and 2 for maps. But this is an improvement over the previous behavior which had the opposite problem, where the output was all on one line which pretty much always required horizontally scrolling the editor to see the result.

bobbicodes commented 11 months ago

I also tried to address #15 but I might have actually made it worse. It's confusing keeping track of evaluations and cursor positions between the 2 editors.

The idea is to create a stronger separation between the code editor and the test editor. But it's still not quite right.