On Thu, Oct 18, 2012 at 3:17 PM, David Nolen <dnolen.li...@gmail.com> wrote:
>
> On Thu, Oct 18, 2012 at 4:15 PM, Grant Rettke <gret...@acm.org> wrote:
>>
>> On Thu, Oct 18, 2012 at 2:50 PM, Mark Engelberg
>> <mark.engelb...@gmail.com> wrote:
>> > Either way works well.  I think Evan's way results in somewhat more
>> > compact
>> > code for the common case, whereas Cgrand's way feels a little more
>> > versatile
>> > (and his "flatter cond" is what I use).  I strongly urge you to pick one
>> > of
>> > these two techniques and include it in your project.  Once you try it
>> > and
>> > see how much cleaner the code is, you'll be hooked.
>>
>> Is it poor form to do something like this inside a defn?
>>
>>  (def a 1)
>>   (println "this is a: " a)
>>   (def b 2)
>>   (println "this is b: " b)
>>   (def c 3)
>>   (println "this is c: " c)
>>   (println "Sum: " (+ a b c))
>
>
> very poor form. def is always top level.

It is poor form in that it will break things in confusing and horrible
ways or poor form from a style perspective?

When you use def inside a defn is it equivalent to a let binding like this?

(defn foo []
  (def a 1)
  (println a))

(defn foo []
  ((fn [a]
     (println a)) 1))

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