On Sun, Oct 25, 2009 at 11:56 PM, MarkSwanson <mark.swanson...@gmail.com>wrote:

> I'm curious (general Clojure question) about your use of the quoted
> form. The Clojure docs state that this results in an unevaluated form,
> but I had trouble finding more details on this. F.E. I'd like to run
> count-nodes against a compiled fn that I've previously defined, but I
> could not get an existing fn into quoted form - and (count-nodes a-fn)
> always returns 1. Is using a macro the only way to get an expression's
> unevaluated form?
>

Basically. Compiled functions don't have source. The
clojure.contrib.repl-utils namespace has a (source foo) function, but this
relies on .clj files in the classpath so won't work for functions defined at
the REPL. It also uses println and returns nil; you'd have to rebind *out*
to a pipe and scrape the text that comes out the other end of the pipe.


> Do you (or anyone) believe some general guidelines could be gathered
> from running count-nodes against all of the individual fns in a
> project. F.E. a number > X(?) for a fn means you might be using an
> imperative style and should be looking at breaking up the fn or
> looking for ways to use map/reduce/other idiomatic Clojure fns to
> simplify your code?
>

I'd expect that to depend on the function's responsibility, but 100 might be
a reasonable guideline. Of course, it's sometimes useful to break a function
up by using internal letfns in a bigger function -- I have one 300-line
function in one project but it's mostly a bunch of internal letfns. The
internal functions have no other use so don't need to be top-level, and
making them top-level complicates things because a lot of them use the
parent function's arguments and some computed values as a context; all of
them would gain many more parameters, or else require top-level vars rebound
by the parent function.

Every time I engage a company for contract work I wonder what I'm in
> for ( the same goes when I dive in to another open source project). I
> think it's possible that viewing this metric by fn and by file would
> give some insight.
>

Try it and let us all know what you find.

--~--~---------~--~----~------------~-------~--~----~
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