Skip to content

Instantly share code, notes, and snippets.

@amalloy
Created August 27, 2011 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amalloy/1175034 to your computer and use it in GitHub Desktop.
Save amalloy/1175034 to your computer and use it in GitHub Desktop.
(let [in *in* ; capture dynamic binding to lexical scope
lying-in (proxy [clojure.lang.LineNumberingPushbackReader] [in]
(getLineNumber [] (.getLineNumber in))
(read [] (.read in))
(unread [c] (.unread in c))
(atLineStart [] (.atLineStart in))
(readLine []
(let [line (.readLine in)]
(if (= (doto line prn) "1 + 1")
"(+ 1 1)"
line))))]
(binding [*in* lying-in]
(read)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment