A nice evening with the Clojure REPL
I’ve been working on Seesaw a lot lately. It’s a Swing wrapper/dsl/whatever for Clojure and I’ve had a great time working on it. Tonight, I was testing some very simple graphics stuff I added (namely, the (push) macro) and I had a nice moment with the REPL. Here’s my session where I paint some text to an image and display it in a JFrame:
Clojure user=> (use 'seesaw.core) nil user=> (use 'seesaw.graphics) nil user=> (use 'seesaw.color) nil user=> (def image (buffered-image 200 200)) #'user/image user=> (let [g (.getGraphics image)] (.setColor g (to-color "#FF0000")) (.drawString g "This is RED" 5 20) (push g (.setColor g (to-color "#0000FF")) (.drawString g "This is BLUE" 5 40)) (.drawString g "This is RED again" 5 60)) nil user=> (frame :content (label :icon image)) #<JFrame ...> user=>
and up pops:
All the yucky Java-y graphics calls need to be cleaned up, but I would never be able to type in the equivalent code in Java without liberal use of ctrl+space.
Ok, back to work.