Message from discussion Ok, so code is data...
Received: by 10.101.97.12 with SMTP id z12mr3131478anl.15.1305005537782;
Mon, 09 May 2011 22:32:17 -0700 (PDT)
Received: by 10.101.173.23 with SMTP id a23ls780398anp.7.gmail; Mon, 09 May
2011 22:32:08 -0700 (PDT)
Received: by 10.100.60.2 with SMTP id i2mr786564ana.13.1305005528669; Mon, 09
May 2011 22:32:08 -0700 (PDT)
Received: by g12g2000yqd.googlegroups.com with HTTP; Mon, 9 May 2011 22:32:08
Date: Mon, 9 May 2011 22:32:08 -0700 (PDT)
X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7)
AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.57 Safari/534.24,gzip(gfe)
Subject: Re: Ok, so code is data...
From: Justin Kramer <jkkra...@gmail.com>
To: Clojure <email@example.com>
Content-Type: text/plain; charset=ISO-8859-1
'read' and 'read-string' are what you're looking for. They each read a
single Clojure object from an input source (PushbackReader for read,
String for read-string).
Alternatively, something like this can read all top-level forms from a
"Reads all top-level forms from f, which will be coerced by
clojure.java.io/reader into a suitable input source. Not lazy."
(with-open [pbr (java.io.PushbackReader. (clojure.java.io/reader
#(not=3D ::eof %)
(repeatedly #(read pbr false ::eof))))))
=3D> ((foo :bar) (baz))
On May 9, 11:36=A0pm, Bill Robertson <billrobertso...@gmail.com> wrote:
> How do I actually manipulate it? =A0I have some complicated logic that I
> would like to transform into html (or maybe xml) for display
> I'm generating the Clojure code by parsing some nasty Java and
> outputting s-expressions. =A0The Java is basic, but quite deeply
> nested. =A0I want to generate working Clojure to demonstrate what that
> can do for us, and get this nastiness documented of course.
> Other than going into the source files and transforming it by hand
> into a series of defs and quoted lists e.g. =A0(def my_func '(+ 1 2))
> How do I actually just load code w/o evaluating it?
> I've found the pretty printer macros, seems like that might be useful
> if I wanted to statically transform the code. =A0I found the walker,
> that looks like it might be useful in actually generating the output
> (e.g. visit things, spit out (x|ht)ml.
> I looked at the various load functions in clojure.core. =A0With the
> exception of load (http://clojure.github.com/clojure/clojure.core-
> api.html#clojure.core/load) they all seem to load and evaluate. =A0Is
> load the answer or is it something I haven't found yet?
> Once I get the code loaded, I don't think I need anything out of the
> ordinary like macros or multi-methods. =A0I think I can just manipulate
> the lists. =A0Does that sound correct?
> I'm sorry if this are a stupid questions, but I've never done anything
> in Clojure of any significance, and any helpful answers you provide
> would could save me days of stumbling about.