On Mon, May 14, 2012 at 4:41 PM, David Nolen <dnolen.li...@gmail.com> wrote:

> On Mon, May 14, 2012 at 7:27 PM, Mark Engelberg 
> <mark.engelb...@gmail.com>wrote:
>
>> (def tree (function-that-produces-an-enormous-tree 2))
>>
>
> Isn't doing this at the top level bad form?
>

The purpose of a REPL is for interactive experimentation.  I want to give
names to the things I'm building so I can play with them in the REPL.
Nothing bad form about that.


> Also I don't see how this isn't solved by modifying some habits.
>
> (defn test-tree [] (function-that-produces-an-enormous-tree 2))
> (time (test-tree))
>
>
time prints out the value that is computed.  The above example would suffer
the same problem of printing out the tree at the REPL.  You could do
something like (time (do (test-tree) nil)) to suppress printing, but if you
want to do further interactive manipulations to the tree, you'd end up
recomputing it.  So then, you get into workarounds involving delay.  It
starts to get ugly, I think.

Clojure's ability to give names to things without printing the values is a
feature I use every day in my interactive explorations.

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