2009/6/26 Kai <poki...@gmail.com>:
>
> Hi all,
>
> I'm new to this discussion group and Clojure. I'm sharing the first
> "bigger-than-REPL" script that I've written because I haven't seen
> anything else like it for Clojure. It's a script that takes Clojure
> code as input and generates a pretty HTML version. You can view it
> here (I ran the script through itself):
>
> http://kai.myownsiteonline.com/clojure/html.clj.html
>
> The style sheet is kept separate for cases with more than one Clojure
> script shown on a page. Also, it still formats just as well without
> the javascript; the javascript only contains code that highlights
> Clojure script as you mouse over it.
>
> I don't have any particular intention by creating this script, it was
> just a warmup into Clojure. Feel free to use it for whatever purpose.
> I'd appreciate comments on the coding style as well as how to make it
> faster - core.clj takes a good 10 minutes! It was a pain and a
> pleasure to code :)

Cute!

Though I've spent a lot of time over the last 6 months reading about
and toying with clojure, I've not yet found the time to write anything
even as substantial as this.  I did however take a quick look at the
code, and it seems reasonably easy for a noob such as myself to
follow.

That said, it did remind of something I was meaning to ask which
concerns large function definitions (here and elsewhere e.g.
clojure.core).

Your parse-code function definition seems quite long and it seems
counter to the way I think I would write this program; as I would be
inclined to write lots of smaller functions responsible for emitting
the different spans for comments, strings, etc; and then tie them up
into a larger function.  That way I could evaluate them all separately
and combine them later.

I have seen similar large functions elsewhere e.g. a few in
clojure.core, and my question is:

How do you go about writing a large function like this?  What is the
process involved?  I realise referential transparency means that
almost every s-exp is evaluatable separately (providing the necessary
bindings are in scope) but is it not a hassle to build such things?
How is it you compose a large function and get the benefits of the
REPL and lisps interactive development model?  Do you evaluate these
snippets in a let bind?  If so what tools support this?

I'm also curious as to what the pro's are in writing large functions
like this.  There are several in clojure.core, I think gen-class is
the one that springs to mind; why is this not defined as a series of
smaller functions?

Thanks again for the HTML pretty printer!

R.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to