Reading and Evaluating

To make all this theory a bit more real, let’s dive into the machinery that Clojure uses to read data and execute code. Actually, calling it machinery is overstating things since we’re talking about two functions, one mundane and one wonderful. The mundane function is read and it does exactly what its name suggests: it reads data. Feed read a character-producing input stream—perhaps an open file or a network connection or your terminal—and it will read and return one Clojure value. Conveniently, if you just call read without any parameters, it will read from standard input. So if you call (read) in the REPL like this:

 user=>​ (read)

then read will sit there quietly, waiting for you to type something in. So enter 55

Get Getting Clojure now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.