Clojure, Quil: Printing in draw function

Asked by At

I am a Clojure and Quil beginner.
As part of development, I would like to print information to the REPL in the draw function.
However, the following implementation doesn't work. There are no error generated, but it doesn't print anything either.
Why doesn't it work, and how can I print to the REPL from Quil draw functions?

Thank you in advance.

(ns quil-learning.core
  (:use quil.core))

(defn setup []
  (frame-rate 60)
  (background 255))

(def saved-out *out*)

(defn draw []
  (println "test 1") ; doesn't work
  (let [*out* saved-out] (println "test 2")) ; doesn't work either
  (stroke 0)
  (stroke-weight 2)
  (ellipse (mouse-x) (mouse-y) 2 2))

 (defsketch example
   :title "print test"
   :setup setup
   :draw draw)

1 Answers

Arthur Ulfeldt On Best Solutions

nrepl is writing your output to the wrong buffer, this was supposed to be fixed for most contexts in nrepl 0.1.4 I suggest using emacs24+ and using it's built in packaging system to keep nrepl up to date. see the Emacs starter kit for details. Or you can take a look at my fork of it which adds nrepl and clojure-mode to the default package list

check the terminal from which you started emacs, sometimes it lands there.